diff options
author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
commit | 5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch) | |
tree | afde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/strings/basic.string/string.nonmembers | |
parent | f11e8eab527fba316c64112f6e05de1a79693a3e (diff) | |
download | bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip |
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.nonmembers')
32 files changed, 2509 insertions, 0 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp new file mode 100644 index 00000000000..4a912eaec6f --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::istringstream in(" abc\n def\n ghij"); + std::string s("initial text"); + getline(in, s); + assert(in.good()); + assert(s == " abc"); + getline(in, s); + assert(in.good()); + assert(s == " def"); + getline(in, s); + assert(in.eof()); + assert(s == " ghij"); + } + { + std::wistringstream in(L" abc\n def\n ghij"); + std::wstring s(L"initial text"); + getline(in, s); + assert(in.good()); + assert(s == L" abc"); + getline(in, s); + assert(in.good()); + assert(s == L" def"); + getline(in, s); + assert(in.eof()); + assert(s == L" ghij"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::istringstream in(" abc\n def\n ghij"); + S s("initial text"); + getline(in, s); + assert(in.good()); + assert(s == " abc"); + getline(in, s); + assert(in.good()); + assert(s == " def"); + getline(in, s); + assert(in.eof()); + assert(s == " ghij"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::wistringstream in(L" abc\n def\n ghij"); + S s(L"initial text"); + getline(in, s); + assert(in.good()); + assert(s == L" abc"); + getline(in, s); + assert(in.good()); + assert(s == L" def"); + getline(in, s); + assert(in.eof()); + assert(s == L" ghij"); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp new file mode 100644 index 00000000000..6596f2fffa7 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str, charT delim); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::istringstream in(" abc* def** ghij"); + std::string s("initial text"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " abc"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " def"); + getline(in, s, '*'); + assert(in.good()); + assert(s == ""); + getline(in, s, '*'); + assert(in.eof()); + assert(s == " ghij"); + } + { + std::wistringstream in(L" abc* def** ghij"); + std::wstring s(L"initial text"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" abc"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" def"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L""); + getline(in, s, L'*'); + assert(in.eof()); + assert(s == L" ghij"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::istringstream in(" abc* def** ghij"); + S s("initial text"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " abc"); + getline(in, s, '*'); + assert(in.good()); + assert(s == " def"); + getline(in, s, '*'); + assert(in.good()); + assert(s == ""); + getline(in, s, '*'); + assert(in.eof()); + assert(s == " ghij"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::wistringstream in(L" abc* def** ghij"); + S s(L"initial text"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" abc"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L" def"); + getline(in, s, L'*'); + assert(in.good()); + assert(s == L""); + getline(in, s, L'*'); + assert(in.eof()); + assert(s == L" ghij"); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp new file mode 100644 index 00000000000..84f52bb2e50 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>&& is, +// basic_string<charT,traits,Allocator>& str, charT delim); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::string s("initial text"); + getline(std::istringstream(" abc* def* ghij"), s, '*'); + assert(s == " abc"); + } + { + std::wstring s(L"initial text"); + getline(std::wistringstream(L" abc* def* ghij"), s, L'*'); + assert(s == L" abc"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s("initial text"); + getline(std::istringstream(" abc* def* ghij"), s, '*'); + assert(s == " abc"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + S s(L"initial text"); + getline(std::wistringstream(L" abc* def* ghij"), s, L'*'); + assert(s == L" abc"); + } +#endif +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp new file mode 100644 index 00000000000..a3c9911abe9 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// getline(basic_istream<charT,traits>&& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + std::string s("initial text"); + getline(std::istringstream(" abc\n def\n ghij"), s); + assert(s == " abc"); + } + { + std::wstring s(L"initial text"); + getline(std::wistringstream(L" abc\n def\n ghij"), s); + assert(s == L" abc"); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + S s("initial text"); + getline(std::istringstream(" abc\n def\n ghij"), s); + assert(s == " abc"); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + S s(L"initial text"); + getline(std::wistringstream(L" abc\n def\n ghij"), s); + assert(s == L" abc"); + } +#endif +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp new file mode 100644 index 00000000000..af806bc0457 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp @@ -0,0 +1,117 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_istream<charT,traits>& +// operator>>(basic_istream<charT,traits>& is, +// basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::istringstream in("a bc defghij"); + std::string s("initial text"); + in >> s; + assert(in.good()); + assert(s == "a"); + assert(in.peek() == ' '); + in >> s; + assert(in.good()); + assert(s == "bc"); + assert(in.peek() == ' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == "def"); + assert(in.peek() == 'g'); + in >> s; + assert(in.eof()); + assert(s == "ghij"); + in >> s; + assert(in.fail()); + } + { + std::wistringstream in(L"a bc defghij"); + std::wstring s(L"initial text"); + in >> s; + assert(in.good()); + assert(s == L"a"); + assert(in.peek() == L' '); + in >> s; + assert(in.good()); + assert(s == L"bc"); + assert(in.peek() == L' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == L"def"); + assert(in.peek() == L'g'); + in >> s; + assert(in.eof()); + assert(s == L"ghij"); + in >> s; + assert(in.fail()); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::istringstream in("a bc defghij"); + S s("initial text"); + in >> s; + assert(in.good()); + assert(s == "a"); + assert(in.peek() == ' '); + in >> s; + assert(in.good()); + assert(s == "bc"); + assert(in.peek() == ' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == "def"); + assert(in.peek() == 'g'); + in >> s; + assert(in.eof()); + assert(s == "ghij"); + in >> s; + assert(in.fail()); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::wistringstream in(L"a bc defghij"); + S s(L"initial text"); + in >> s; + assert(in.good()); + assert(s == L"a"); + assert(in.peek() == L' '); + in >> s; + assert(in.good()); + assert(s == L"bc"); + assert(in.peek() == L' '); + in.width(3); + in >> s; + assert(in.good()); + assert(s == L"def"); + assert(in.peek() == L'g'); + in >> s; + assert(in.eof()); + assert(s == L"ghij"); + in >> s; + assert(in.fail()); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp new file mode 100644 index 00000000000..102e8ea0815 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp @@ -0,0 +1,91 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>& os, +// const basic_string<charT,traits,Allocator>& str); + +#include <string> +#include <sstream> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + { + std::ostringstream out; + std::string s("some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + std::ostringstream out; + std::string s("some text"); + out.width(12); + out << s; + assert(out.good()); + assert(" " + s == out.str()); + } + { + std::wostringstream out; + std::wstring s(L"some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + std::wostringstream out; + std::wstring s(L"some text"); + out.width(12); + out << s; + assert(out.good()); + assert(L" " + s == out.str()); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s("some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s("some text"); + out.width(12); + out << s; + assert(out.good()); + assert(" " + s == out.str()); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s(L"some text"); + out << s; + assert(out.good()); + assert(s == out.str()); + } + { + typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S; + std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out; + S s(L"some text"); + out.width(12); + out << s; + assert(out.good()); + assert(L" " + s == out.str()); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp new file mode 100644 index 00000000000..cee538800dd --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp @@ -0,0 +1,78 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// void swap(basic_string<charT,traits,Allocator>& lhs, +// basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <stdexcept> +#include <algorithm> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(S s1, S s2) +{ + S s1_ = s1; + S s2_ = s2; + swap(s1, s2); + assert(s1.__invariants()); + assert(s2.__invariants()); + assert(s1 == s2_); + assert(s2 == s1_); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S("")); + test(S(""), S("12345")); + test(S(""), S("1234567890")); + test(S(""), S("12345678901234567890")); + test(S("abcde"), S("")); + test(S("abcde"), S("12345")); + test(S("abcde"), S("1234567890")); + test(S("abcde"), S("12345678901234567890")); + test(S("abcdefghij"), S("")); + test(S("abcdefghij"), S("12345")); + test(S("abcdefghij"), S("1234567890")); + test(S("abcdefghij"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), S("")); + test(S("abcdefghijklmnopqrst"), S("12345")); + test(S("abcdefghijklmnopqrst"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), S("12345678901234567890")); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S("")); + test(S(""), S("12345")); + test(S(""), S("1234567890")); + test(S(""), S("12345678901234567890")); + test(S("abcde"), S("")); + test(S("abcde"), S("12345")); + test(S("abcde"), S("1234567890")); + test(S("abcde"), S("12345678901234567890")); + test(S("abcdefghij"), S("")); + test(S("abcdefghij"), S("12345")); + test(S("abcdefghij"), S("1234567890")); + test(S("abcdefghij"), S("12345678901234567890")); + test(S("abcdefghijklmnopqrst"), S("")); + test(S("abcdefghijklmnopqrst"), S("12345")); + test(S("abcdefghijklmnopqrst"), S("1234567890")); + test(S("abcdefghijklmnopqrst"), S("12345678901234567890")); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp new file mode 100644 index 00000000000..4d5d79693d0 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// void swap(basic_string& c) +// noexcept(!allocator_type::propagate_on_container_swap::value || +// __is_nothrow_swappable<allocator_type>::value); + +// This tests a conforming extension + +#include <string> +#include <cassert> + +#include "test_allocator.h" + +template <class T> +struct some_alloc +{ + typedef T value_type; + + some_alloc() {} + some_alloc(const some_alloc&); + void deallocate(void*, unsigned) {} + + typedef std::true_type propagate_on_container_swap; +}; + +int main() +{ +#if __has_feature(cxx_noexcept) + { + typedef std::string C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C; + C c1, c2; + static_assert(noexcept(swap(c1, c2)), ""); + } + { + typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C; + C c1, c2; + static_assert(!noexcept(swap(c1, c2)), ""); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp new file mode 100644 index 00000000000..cc08982a5ca --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs != rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp new file mode 100644 index 00000000000..b496d70dc2f --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator!=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs != rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp new file mode 100644 index 00000000000..069b305111d --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator!=(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs != rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp new file mode 100644 index 00000000000..4e09bf2464c --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(typename S::value_type lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(typename S::value_type lhs, S&& rhs, const S& x) +{ + assert(lhs + move(rhs) == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0('a', S(""), S("a")); + test0('a', S("12345"), S("a12345")); + test0('a', S("1234567890"), S("a1234567890")); + test0('a', S("12345678901234567890"), S("a12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1('a', S(""), S("a")); + test1('a', S("12345"), S("a12345")); + test1('a', S("1234567890"), S("a1234567890")); + test1('a', S("12345678901234567890"), S("a12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0('a', S(""), S("a")); + test0('a', S("12345"), S("a12345")); + test0('a', S("1234567890"), S("a1234567890")); + test0('a', S("12345678901234567890"), S("a12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1('a', S(""), S("a")); + test1('a', S("12345"), S("a12345")); + test1('a', S("1234567890"), S("a1234567890")); + test1('a', S("12345678901234567890"), S("a12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp new file mode 100644 index 00000000000..9dc8a510beb --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp @@ -0,0 +1,127 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const typename S::value_type* lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(const typename S::value_type* lhs, S&& rhs, const S& x) +{ + assert(lhs + move(rhs) == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0("", S(""), S("")); + test0("", S("12345"), S("12345")); + test0("", S("1234567890"), S("1234567890")); + test0("", S("12345678901234567890"), S("12345678901234567890")); + test0("abcde", S(""), S("abcde")); + test0("abcde", S("12345"), S("abcde12345")); + test0("abcde", S("1234567890"), S("abcde1234567890")); + test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test0("abcdefghij", S(""), S("abcdefghij")); + test0("abcdefghij", S("12345"), S("abcdefghij12345")); + test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1("", S(""), S("")); + test1("", S("12345"), S("12345")); + test1("", S("1234567890"), S("1234567890")); + test1("", S("12345678901234567890"), S("12345678901234567890")); + test1("abcde", S(""), S("abcde")); + test1("abcde", S("12345"), S("abcde12345")); + test1("abcde", S("1234567890"), S("abcde1234567890")); + test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test1("abcdefghij", S(""), S("abcdefghij")); + test1("abcdefghij", S("12345"), S("abcdefghij12345")); + test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0("", S(""), S("")); + test0("", S("12345"), S("12345")); + test0("", S("1234567890"), S("1234567890")); + test0("", S("12345678901234567890"), S("12345678901234567890")); + test0("abcde", S(""), S("abcde")); + test0("abcde", S("12345"), S("abcde12345")); + test0("abcde", S("1234567890"), S("abcde1234567890")); + test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test0("abcdefghij", S(""), S("abcdefghij")); + test0("abcdefghij", S("12345"), S("abcdefghij12345")); + test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1("", S(""), S("")); + test1("", S("12345"), S("12345")); + test1("", S("1234567890"), S("1234567890")); + test1("", S("12345678901234567890"), S("12345678901234567890")); + test1("abcde", S(""), S("abcde")); + test1("abcde", S("12345"), S("abcde12345")); + test1("abcde", S("1234567890"), S("abcde1234567890")); + test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890")); + test1("abcdefghij", S(""), S("abcdefghij")); + test1("abcdefghij", S("12345"), S("abcdefghij12345")); + test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890")); + test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst")); + test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345")); + test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp new file mode 100644 index 00000000000..4d72db595b1 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const S& lhs, typename S::value_type rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(S&& lhs, typename S::value_type rhs, const S& x) +{ + assert(move(lhs) + rhs == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0(S(""), '1', S("1")); + test0(S("abcde"), '1', S("abcde1")); + test0(S("abcdefghij"), '1', S("abcdefghij1")); + test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), '1', S("1")); + test1(S("abcde"), '1', S("abcde1")); + test1(S("abcdefghij"), '1', S("abcdefghij1")); + test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0(S(""), '1', S("1")); + test0(S("abcde"), '1', S("abcde1")); + test0(S("abcdefghij"), '1', S("abcdefghij1")); + test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), '1', S("1")); + test1(S("abcde"), '1', S("abcde1")); + test1(S("abcdefghij"), '1', S("abcdefghij1")); + test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp new file mode 100644 index 00000000000..47fc1ca51b8 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp @@ -0,0 +1,127 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const S& lhs, const typename S::value_type* rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(S&& lhs, const typename S::value_type* rhs, const S& x) +{ + assert(move(lhs) + rhs == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0(S(""), "", S("")); + test0(S(""), "12345", S("12345")); + test0(S(""), "1234567890", S("1234567890")); + test0(S(""), "12345678901234567890", S("12345678901234567890")); + test0(S("abcde"), "", S("abcde")); + test0(S("abcde"), "12345", S("abcde12345")); + test0(S("abcde"), "1234567890", S("abcde1234567890")); + test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test0(S("abcdefghij"), "", S("abcdefghij")); + test0(S("abcdefghij"), "12345", S("abcdefghij12345")); + test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), "", S("")); + test1(S(""), "12345", S("12345")); + test1(S(""), "1234567890", S("1234567890")); + test1(S(""), "12345678901234567890", S("12345678901234567890")); + test1(S("abcde"), "", S("abcde")); + test1(S("abcde"), "12345", S("abcde12345")); + test1(S("abcde"), "1234567890", S("abcde1234567890")); + test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test1(S("abcdefghij"), "", S("abcdefghij")); + test1(S("abcdefghij"), "12345", S("abcdefghij12345")); + test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0(S(""), "", S("")); + test0(S(""), "12345", S("12345")); + test0(S(""), "1234567890", S("1234567890")); + test0(S(""), "12345678901234567890", S("12345678901234567890")); + test0(S("abcde"), "", S("abcde")); + test0(S("abcde"), "12345", S("abcde12345")); + test0(S("abcde"), "1234567890", S("abcde1234567890")); + test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test0(S("abcdefghij"), "", S("abcdefghij")); + test0(S("abcdefghij"), "12345", S("abcdefghij12345")); + test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), "", S("")); + test1(S(""), "12345", S("12345")); + test1(S(""), "1234567890", S("1234567890")); + test1(S(""), "12345678901234567890", S("12345678901234567890")); + test1(S("abcde"), "", S("abcde")); + test1(S("abcde"), "12345", S("abcde12345")); + test1(S("abcde"), "1234567890", S("abcde1234567890")); + test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890")); + test1(S("abcdefghij"), "", S("abcdefghij")); + test1(S("abcdefghij"), "12345", S("abcdefghij12345")); + test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890")); + test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp new file mode 100644 index 00000000000..bf2ddd51f72 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp @@ -0,0 +1,221 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator> +// operator+(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const basic_string<charT,traits,Allocator>&& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>&& rhs); + +// template<class charT, class traits, class Allocator> +// basic_string<charT,traits,Allocator>&& +// operator+(const basic_string<charT,traits,Allocator>&& lhs, +// const basic_string<charT,traits,Allocator>&& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test0(const S& lhs, const S& rhs, const S& x) +{ + assert(lhs + rhs == x); +} + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + +template <class S> +void +test1(S&& lhs, const S& rhs, const S& x) +{ + assert(move(lhs) + rhs == x); +} + +template <class S> +void +test2(const S& lhs, S&& rhs, const S& x) +{ + assert(lhs + move(rhs) == x); +} + +template <class S> +void +test3(S&& lhs, S&& rhs, const S& x) +{ + assert(move(lhs) + move(rhs) == x); +} + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + +int main() +{ + { + typedef std::string S; + test0(S(""), S(""), S("")); + test0(S(""), S("12345"), S("12345")); + test0(S(""), S("1234567890"), S("1234567890")); + test0(S(""), S("12345678901234567890"), S("12345678901234567890")); + test0(S("abcde"), S(""), S("abcde")); + test0(S("abcde"), S("12345"), S("abcde12345")); + test0(S("abcde"), S("1234567890"), S("abcde1234567890")); + test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test0(S("abcdefghij"), S(""), S("abcdefghij")); + test0(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), S(""), S("")); + test1(S(""), S("12345"), S("12345")); + test1(S(""), S("1234567890"), S("1234567890")); + test1(S(""), S("12345678901234567890"), S("12345678901234567890")); + test1(S("abcde"), S(""), S("abcde")); + test1(S("abcde"), S("12345"), S("abcde12345")); + test1(S("abcde"), S("1234567890"), S("abcde1234567890")); + test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test1(S("abcdefghij"), S(""), S("abcdefghij")); + test1(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test2(S(""), S(""), S("")); + test2(S(""), S("12345"), S("12345")); + test2(S(""), S("1234567890"), S("1234567890")); + test2(S(""), S("12345678901234567890"), S("12345678901234567890")); + test2(S("abcde"), S(""), S("abcde")); + test2(S("abcde"), S("12345"), S("abcde12345")); + test2(S("abcde"), S("1234567890"), S("abcde1234567890")); + test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test2(S("abcdefghij"), S(""), S("abcdefghij")); + test2(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test3(S(""), S(""), S("")); + test3(S(""), S("12345"), S("12345")); + test3(S(""), S("1234567890"), S("1234567890")); + test3(S(""), S("12345678901234567890"), S("12345678901234567890")); + test3(S("abcde"), S(""), S("abcde")); + test3(S("abcde"), S("12345"), S("abcde12345")); + test3(S("abcde"), S("1234567890"), S("abcde1234567890")); + test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test3(S("abcdefghij"), S(""), S("abcdefghij")); + test3(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test0(S(""), S(""), S("")); + test0(S(""), S("12345"), S("12345")); + test0(S(""), S("1234567890"), S("1234567890")); + test0(S(""), S("12345678901234567890"), S("12345678901234567890")); + test0(S("abcde"), S(""), S("abcde")); + test0(S("abcde"), S("12345"), S("abcde12345")); + test0(S("abcde"), S("1234567890"), S("abcde1234567890")); + test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test0(S("abcdefghij"), S(""), S("abcdefghij")); + test0(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + + test1(S(""), S(""), S("")); + test1(S(""), S("12345"), S("12345")); + test1(S(""), S("1234567890"), S("1234567890")); + test1(S(""), S("12345678901234567890"), S("12345678901234567890")); + test1(S("abcde"), S(""), S("abcde")); + test1(S("abcde"), S("12345"), S("abcde12345")); + test1(S("abcde"), S("1234567890"), S("abcde1234567890")); + test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test1(S("abcdefghij"), S(""), S("abcdefghij")); + test1(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test2(S(""), S(""), S("")); + test2(S(""), S("12345"), S("12345")); + test2(S(""), S("1234567890"), S("1234567890")); + test2(S(""), S("12345678901234567890"), S("12345678901234567890")); + test2(S("abcde"), S(""), S("abcde")); + test2(S("abcde"), S("12345"), S("abcde12345")); + test2(S("abcde"), S("1234567890"), S("abcde1234567890")); + test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test2(S("abcdefghij"), S(""), S("abcdefghij")); + test2(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + + test3(S(""), S(""), S("")); + test3(S(""), S("12345"), S("12345")); + test3(S(""), S("1234567890"), S("1234567890")); + test3(S(""), S("12345678901234567890"), S("12345678901234567890")); + test3(S("abcde"), S(""), S("abcde")); + test3(S("abcde"), S("12345"), S("abcde12345")); + test3(S("abcde"), S("1234567890"), S("abcde1234567890")); + test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890")); + test3(S("abcdefghij"), S(""), S("abcdefghij")); + test3(S("abcdefghij"), S("12345"), S("abcdefghij12345")); + test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890")); + test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst")); + test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345")); + test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp new file mode 100644 index 00000000000..19a5bdd977e --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs == rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp new file mode 100644 index 00000000000..22006bb1be6 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs == rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp new file mode 100644 index 00000000000..0bff70a977a --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator==(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs == rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp new file mode 100644 index 00000000000..f9fa204b9ee --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator>(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs > rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), false); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), false); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp new file mode 100644 index 00000000000..daa6f40ae3c --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator>(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs > rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", false); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", false); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp new file mode 100644 index 00000000000..95073bf7644 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator>(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs > rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), false); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), false); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp new file mode 100644 index 00000000000..eab117a843f --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator>=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs >= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), true); + test("", S("abcde"), false); + test("", S("abcdefghij"), false); + test("", S("abcdefghijklmnopqrst"), false); + test("abcde", S(""), true); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), false); + test("abcde", S("abcdefghijklmnopqrst"), false); + test("abcdefghij", S(""), true); + test("abcdefghij", S("abcde"), true); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), false); + test("abcdefghijklmnopqrst", S(""), true); + test("abcdefghijklmnopqrst", S("abcde"), true); + test("abcdefghijklmnopqrst", S("abcdefghij"), true); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp new file mode 100644 index 00000000000..56b3b35b3d9 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs >= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", true); + test(S(""), "abcde", false); + test(S(""), "abcdefghij", false); + test(S(""), "abcdefghijklmnopqrst", false); + test(S("abcde"), "", true); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", false); + test(S("abcde"), "abcdefghijklmnopqrst", false); + test(S("abcdefghij"), "", true); + test(S("abcdefghij"), "abcde", true); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", false); + test(S("abcdefghijklmnopqrst"), "", true); + test(S("abcdefghijklmnopqrst"), "abcde", true); + test(S("abcdefghijklmnopqrst"), "abcdefghij", true); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp new file mode 100644 index 00000000000..c02b202c49e --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator>=(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs >= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), true); + test(S(""), S("abcde"), false); + test(S(""), S("abcdefghij"), false); + test(S(""), S("abcdefghijklmnopqrst"), false); + test(S("abcde"), S(""), true); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), false); + test(S("abcde"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghij"), S(""), true); + test(S("abcdefghij"), S("abcde"), true); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); + test(S("abcdefghijklmnopqrst"), S(""), true); + test(S("abcdefghijklmnopqrst"), S("abcde"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp new file mode 100644 index 00000000000..86f6a2db119 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator<(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs < rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), false); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), false); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), false); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp new file mode 100644 index 00000000000..b935da5426f --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator<(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs < rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", false); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", false); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", false); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp new file mode 100644 index 00000000000..487e2056f2c --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator<(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs < rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), false); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), false); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), false); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp new file mode 100644 index 00000000000..21959405194 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator<=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const typename S::value_type* lhs, const S& rhs, bool x) +{ + assert((lhs <= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test("", S(""), true); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test("", S(""), true); + test("", S("abcde"), true); + test("", S("abcdefghij"), true); + test("", S("abcdefghijklmnopqrst"), true); + test("abcde", S(""), false); + test("abcde", S("abcde"), true); + test("abcde", S("abcdefghij"), true); + test("abcde", S("abcdefghijklmnopqrst"), true); + test("abcdefghij", S(""), false); + test("abcdefghij", S("abcde"), false); + test("abcdefghij", S("abcdefghij"), true); + test("abcdefghij", S("abcdefghijklmnopqrst"), true); + test("abcdefghijklmnopqrst", S(""), false); + test("abcdefghijklmnopqrst", S("abcde"), false); + test("abcdefghijklmnopqrst", S("abcdefghij"), false); + test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp new file mode 100644 index 00000000000..bb1bce8d404 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const typename S::value_type* rhs, bool x) +{ + assert((lhs <= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), "", true); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), "", true); + test(S(""), "abcde", true); + test(S(""), "abcdefghij", true); + test(S(""), "abcdefghijklmnopqrst", true); + test(S("abcde"), "", false); + test(S("abcde"), "abcde", true); + test(S("abcde"), "abcdefghij", true); + test(S("abcde"), "abcdefghijklmnopqrst", true); + test(S("abcdefghij"), "", false); + test(S("abcdefghij"), "abcde", false); + test(S("abcdefghij"), "abcdefghij", true); + test(S("abcdefghij"), "abcdefghijklmnopqrst", true); + test(S("abcdefghijklmnopqrst"), "", false); + test(S("abcdefghijklmnopqrst"), "abcde", false); + test(S("abcdefghijklmnopqrst"), "abcdefghij", false); + test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true); + } +#endif +} diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp new file mode 100644 index 00000000000..2b975f160d5 --- /dev/null +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<class charT, class traits, class Allocator> +// bool operator<=(const basic_string<charT,traits,Allocator>& lhs, +// const basic_string<charT,traits,Allocator>& rhs); + +#include <string> +#include <cassert> + +#include "min_allocator.h" + +template <class S> +void +test(const S& lhs, const S& rhs, bool x) +{ + assert((lhs <= rhs) == x); +} + +int main() +{ + { + typedef std::string S; + test(S(""), S(""), true); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#if __cplusplus >= 201103L + { + typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; + test(S(""), S(""), true); + test(S(""), S("abcde"), true); + test(S(""), S("abcdefghij"), true); + test(S(""), S("abcdefghijklmnopqrst"), true); + test(S("abcde"), S(""), false); + test(S("abcde"), S("abcde"), true); + test(S("abcde"), S("abcdefghij"), true); + test(S("abcde"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), S(""), false); + test(S("abcdefghij"), S("abcde"), false); + test(S("abcdefghij"), S("abcdefghij"), true); + test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), S(""), false); + test(S("abcdefghijklmnopqrst"), S("abcde"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true); + } +#endif +} |