diff --git a/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp b/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.access/at.pass.cpp @@ -54,27 +54,22 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), 0); + test(S("123"), 0); + test(S("123"), 1); + test(S("123"), 2); + test(S("123"), 3); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), 0); - test(S("123"), 0); - test(S("123"), 1); - test(S("123"), 2); - test(S("123"), 3); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), 0); - test(S("123"), 0); - test(S("123"), 1); - test(S("123"), 2); - test(S("123"), 3); - } + test_string, min_allocator>>(); #endif - return true; + return true; } int main(int, char**) diff --git a/libcxx/test/std/strings/basic.string/string.access/back.pass.cpp b/libcxx/test/std/strings/basic.string/string.access/back.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.access/back.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.access/back.pass.cpp @@ -32,18 +32,16 @@ assert(s.back() == typename S::value_type('z')); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S("1")); + test(S("1234567890123456789012345678901234567890")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S("1")); - test(S("1234567890123456789012345678901234567890")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S("1")); - test(S("1234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.access/front.pass.cpp b/libcxx/test/std/strings/basic.string/string.access/front.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.access/front.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.access/front.pass.cpp @@ -32,18 +32,16 @@ assert(s.front() == typename S::value_type('z')); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S("1")); + test(S("1234567890123456789012345678901234567890")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S("1")); - test(S("1234567890123456789012345678901234567890")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S("1")); - test(S("1234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.access/index.pass.cpp b/libcxx/test/std/strings/basic.string/string.access/index.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.access/index.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.access/index.pass.cpp @@ -17,42 +17,28 @@ #include "test_macros.h" #include "min_allocator.h" -TEST_CONSTEXPR_CXX20 bool test() { +template +TEST_CONSTEXPR_CXX20 void test_string() { + S s("0123456789"); + const S& cs = s; + ASSERT_SAME_TYPE(decltype( s[0]), typename S::reference); + ASSERT_SAME_TYPE(decltype(cs[0]), typename S::const_reference); + LIBCPP_ASSERT_NOEXCEPT( s[0]); + LIBCPP_ASSERT_NOEXCEPT( cs[0]); + for (typename S::size_type i = 0; i < cs.size(); ++i) { - typedef std::string S; - S s("0123456789"); - const S& cs = s; - ASSERT_SAME_TYPE(decltype( s[0]), typename S::reference); - ASSERT_SAME_TYPE(decltype(cs[0]), typename S::const_reference); - LIBCPP_ASSERT_NOEXCEPT( s[0]); - LIBCPP_ASSERT_NOEXCEPT( cs[0]); - for (S::size_type i = 0; i < cs.size(); ++i) - { - assert(s[i] == static_cast('0' + i)); - assert(cs[i] == s[i]); - } - assert(cs[cs.size()] == '\0'); - const S s2 = S(); - assert(s2[0] == '\0'); + assert(s[i] == static_cast('0' + i)); + assert(cs[i] == s[i]); } + assert(cs[cs.size()] == '\0'); + const S s2 = S(); + assert(s2[0] == '\0'); +} + +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - S s("0123456789"); - const S& cs = s; - ASSERT_SAME_TYPE(decltype( s[0]), typename S::reference); - ASSERT_SAME_TYPE(decltype(cs[0]), typename S::const_reference); - LIBCPP_ASSERT_NOEXCEPT( s[0]); - LIBCPP_ASSERT_NOEXCEPT( cs[0]); - for (S::size_type i = 0; i < cs.size(); ++i) - { - assert(s[i] == static_cast('0' + i)); - assert(cs[i] == s[i]); - } - assert(cs[cs.size()] == '\0'); - const S s2 = S(); - assert(s2[0] == '\0'); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/clear.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/clear.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/clear.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/clear.pass.cpp @@ -24,34 +24,24 @@ assert(s.size() == 0); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - S s; - test(s); - - s.assign(10, 'a'); - s.erase(5); - test(s); +template +TEST_CONSTEXPR_CXX20 void test_string() { + S s; + test(s); - s.assign(100, 'a'); - s.erase(50); - test(s); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - S s; - test(s); + s.assign(10, 'a'); + s.erase(5); + test(s); - s.assign(10, 'a'); - s.erase(5); - test(s); + s.assign(100, 'a'); + s.erase(50); + test(s); +} - s.assign(100, 'a'); - s.erase(50); - test(s); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/empty.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/empty.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/empty.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/empty.pass.cpp @@ -24,20 +24,17 @@ assert(s.empty() == (s.size() == 0)); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S()); + test(S("123")); + test(S("12345678901234567890123456789012345678901234567890")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/length.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/length.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/length.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/length.pass.cpp @@ -23,20 +23,17 @@ assert(s.length() == s.size()); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S()); + test(S("123")); + test(S("12345678901234567890123456789012345678901234567890")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/max_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/max_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/max_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/max_size.pass.cpp @@ -55,21 +55,20 @@ test2(s); } -void test() { - { - typedef std::string S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S()); + test(S("123")); + test(S("12345678901234567890123456789012345678901234567890")); +} + +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif + + return true; } #if TEST_STD_VER > 17 diff --git a/libcxx/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp @@ -37,20 +37,17 @@ assert ( false ); } +template +void test_string() { + test(S()); + test(S("123")); + test(S("12345678901234567890123456789012345678901234567890")); +} + bool test() { - { - typedef std::string S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S()); - test(S("123")); - test(S("12345678901234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/reserve.pass.cpp @@ -37,24 +37,17 @@ assert(s.capacity() >= s.size()); } +template +void test_string() { + test(0, 0); + test(10, 5); + test(100, 50); +} + bool test() { - { - typedef std::string S; - { - test(0, 0); - test(10, 5); - test(100, 50); - } - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - { - test(0, 0); - test(10, 5); - test(100, 50); - } - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/reserve_size.pass.cpp @@ -62,40 +62,27 @@ #endif } -TEST_CONSTEXPR_CXX20 bool test() { +template +TEST_CONSTEXPR_CXX20 void test_string() { { - typedef std::string S; - { - test(0, 0, 5); - test(0, 0, 10); - test(0, 0, 50); - } - { - test(100, 50, 5); - test(100, 50, 10); - test(100, 50, 50); - test(100, 50, 100); - test(100, 50, 1000); - test(100, 50, S::npos); - } + test(0, 0, 5); + test(0, 0, 10); + test(0, 0, 50); } -#if TEST_STD_VER >= 11 { - typedef std::basic_string, min_allocator> S; - { - test(0, 0, 5); - test(0, 0, 10); - test(0, 0, 50); - } - { - test(100, 50, 5); - test(100, 50, 10); - test(100, 50, 50); - test(100, 50, 100); - test(100, 50, 1000); - test(100, 50, S::npos); - } + test(100, 50, 5); + test(100, 50, 10); + test(100, 50, 50); + test(100, 50, 100); + test(100, 50, 1000); + test(100, 50, S::npos); } +} + +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp @@ -43,46 +43,30 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), 0, S()); + test(S(), 1, S(1, '\0')); + test(S(), 10, S(10, '\0')); + test(S(), 100, S(100, '\0')); + test(S("12345"), 0, S()); + test(S("12345"), 2, S("12")); + test(S("12345"), 5, S("12345")); + test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15)); + test(S("12345678901234567890123456789012345678901234567890"), 0, S()); + test(S("12345678901234567890123456789012345678901234567890"), 10, + S("1234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 50, + S("12345678901234567890123456789012345678901234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 60, + S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60)); + test(S(), S::npos, S("not going to happen")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), 0, S()); - test(S(), 1, S(1, '\0')); - test(S(), 10, S(10, '\0')); - test(S(), 100, S(100, '\0')); - test(S("12345"), 0, S()); - test(S("12345"), 2, S("12")); - test(S("12345"), 5, S("12345")); - test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15)); - test(S("12345678901234567890123456789012345678901234567890"), 0, S()); - test(S("12345678901234567890123456789012345678901234567890"), 10, - S("1234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 50, - S("12345678901234567890123456789012345678901234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 60, - S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60)); - test(S(), S::npos, S("not going to happen")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), 0, S()); - test(S(), 1, S(1, '\0')); - test(S(), 10, S(10, '\0')); - test(S(), 100, S(100, '\0')); - test(S("12345"), 0, S()); - test(S("12345"), 2, S("12")); - test(S("12345"), 5, S("12345")); - test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15)); - test(S("12345678901234567890123456789012345678901234567890"), 0, S()); - test(S("12345678901234567890123456789012345678901234567890"), 10, - S("1234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 50, - S("12345678901234567890123456789012345678901234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 60, - S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60)); - test(S(), S::npos, S("not going to happen")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp @@ -43,46 +43,30 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), 0, 'a', S()); + test(S(), 1, 'a', S("a")); + test(S(), 10, 'a', S(10, 'a')); + test(S(), 100, 'a', S(100, 'a')); + test(S("12345"), 0, 'a', S()); + test(S("12345"), 2, 'a', S("12")); + test(S("12345"), 5, 'a', S("12345")); + test(S("12345"), 15, 'a', S("12345aaaaaaaaaa")); + test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S()); + test(S("12345678901234567890123456789012345678901234567890"), 10, 'a', + S("1234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 50, 'a', + S("12345678901234567890123456789012345678901234567890")); + test(S("12345678901234567890123456789012345678901234567890"), 60, 'a', + S("12345678901234567890123456789012345678901234567890aaaaaaaaaa")); + test(S(), S::npos, 'a', S("not going to happen")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S("a")); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - test(S("12345"), 0, 'a', S()); - test(S("12345"), 2, 'a', S("12")); - test(S("12345"), 5, 'a', S("12345")); - test(S("12345"), 15, 'a', S("12345aaaaaaaaaa")); - test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S()); - test(S("12345678901234567890123456789012345678901234567890"), 10, 'a', - S("1234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 50, 'a', - S("12345678901234567890123456789012345678901234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 60, 'a', - S("12345678901234567890123456789012345678901234567890aaaaaaaaaa")); - test(S(), S::npos, 'a', S("not going to happen")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S("a")); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - test(S("12345"), 0, 'a', S()); - test(S("12345"), 2, 'a', S("12")); - test(S("12345"), 5, 'a', S("12345")); - test(S("12345"), 15, 'a', S("12345aaaaaaaaaa")); - test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S()); - test(S("12345678901234567890123456789012345678901234567890"), 10, 'a', - S("1234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 50, 'a', - S("12345678901234567890123456789012345678901234567890")); - test(S("12345678901234567890123456789012345678901234567890"), 60, 'a', - S("12345678901234567890123456789012345678901234567890aaaaaaaaaa")); - test(S(), S::npos, 'a', S("not going to happen")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp @@ -29,34 +29,24 @@ assert(s.capacity() >= s.size()); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - S s; - test(s); - - s.assign(10, 'a'); - s.erase(5); - test(s); +template +TEST_CONSTEXPR_CXX20 void test_string() { + S s; + test(s); - s.assign(100, 'a'); - s.erase(50); - test(s); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - S s; - test(s); + s.assign(10, 'a'); + s.erase(5); + test(s); - s.assign(10, 'a'); - s.erase(5); - test(s); + s.assign(100, 'a'); + s.erase(50); + test(s); +} - s.assign(100, 'a'); - s.erase(50); - test(s); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.capacity/size.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.capacity/size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.capacity/size.pass.cpp @@ -23,20 +23,17 @@ assert(s.size() == c); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), 0); + test(S("123"), 3); + test(S("12345678901234567890123456789012345678901234567890"), 50); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), 0); - test(S("123"), 3); - test(S("12345678901234567890123456789012345678901234567890"), 50); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), 0); - test(S("123"), 3); - test(S("12345678901234567890123456789012345678901234567890"), 50); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/char_assignment.pass.cpp @@ -28,22 +28,18 @@ assert(s1.capacity() >= s1.size()); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), 'a'); + test(S("1"), 'a'); + test(S("123456789"), 'a'); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a'); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), 'a'); - test(S("1"), 'a'); - test(S("123456789"), 'a'); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a'); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), 'a'); - test(S("1"), 'a'); - test(S("123456789"), 'a'); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a'); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/copy_assignment.pass.cpp @@ -27,47 +27,32 @@ assert(s1.capacity() >= s1.size()); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), S()); - test(S("1"), S()); - test(S(), S("1")); - test(S("1"), S("2")); - test(S("1"), S("2")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), S()); + test(S("1"), S()); + test(S(), S("1")); + test(S("1"), S("2")); + test(S("1"), S("2")); - test(S(), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("123456789"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), S()); - test(S("1"), S()); - test(S(), S("1")); - test(S("1"), S("2")); - test(S("1"), S("2")); + test(S(), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("123456789"), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890"), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); +} - test(S(), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("123456789"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s; s = {"abc", 1}; diff --git a/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/move_assignment.pass.cpp @@ -32,43 +32,30 @@ assert(s1.capacity() >= s1.size()); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), S()); - test(S("1"), S()); - test(S(), S("1")); - test(S("1"), S("2")); - test(S("1"), S("2")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), S()); + test(S("1"), S()); + test(S(), S("1")); + test(S("1"), S("2")); + test(S("1"), S("2")); - test(S(), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("123456789"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - } - { - typedef std::basic_string, min_allocator> S; - test(S(), S()); - test(S("1"), S()); - test(S(), S("1")); - test(S("1"), S("2")); - test(S("1"), S("2")); + test(S(), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("123456789"), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890"), + S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); +} - test(S(), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("123456789"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); +#endif return true; } diff --git a/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp @@ -29,44 +29,29 @@ assert(s1.capacity() >= s1.size()); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), ""); - test(S("1"), ""); - test(S(), "1"); - test(S("1"), "2"); - test(S("1"), "2"); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), ""); + test(S("1"), ""); + test(S(), "1"); + test(S("1"), "2"); + test(S("1"), "2"); - test(S(), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - test(S("123456789"), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), ""); - test(S("1"), ""); - test(S(), "1"); - test(S("1"), "2"); - test(S("1"), "2"); + test(S(), + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); + test(S("123456789"), + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890"), + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +} - test(S(), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - test(S("123456789"), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp @@ -82,7 +82,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s({"abc", 1}); assert(s.size() == 1); diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/string_view_assignment.pass.cpp @@ -28,46 +28,30 @@ assert(s1.capacity() >= s1.size()); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string_view SV; - test(S(), SV("")); - test(S("1"), SV("")); - test(S(), SV("1")); - test(S("1"), SV("2")); - test(S("1"), SV("2")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(S(), SV("")); + test(S("1"), SV("")); + test(S(), SV("1")); + test(S("1"), SV("2")); + test(S("1"), SV("2")); - test(S(), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("123456789"), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - typedef std::string_view SV; - test(S(), SV("")); - test(S("1"), SV("")); - test(S(), SV("1")); - test(S("1"), SV("2")); - test(S("1"), SV("2")); + test(S(), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("123456789"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + test(S("1234567890123456789012345678901234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890123456789012345678901234567890"), + SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); +} - test(S(), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("123456789"), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - test(S("1234567890123456789012345678901234567890123456789012345678901234567890" - "1234567890123456789012345678901234567890123456789012345678901234567890"), - SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp @@ -71,59 +71,38 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(S(), SV(), 0, 0, S()); + test(S(), SV(), 1, 0, S()); + test(S(), SV("12345"), 0, 3, S("123")); + test(S(), SV("12345"), 1, 4, S("2345")); + test(S(), SV("12345"), 3, 15, S("45")); + test(S(), SV("12345"), 5, 15, S("")); + test(S(), SV("12345"), 6, 15, S("not happening")); + test(S(), SV("12345678901234567890"), 0, 0, S()); + test(S(), SV("12345678901234567890"), 1, 1, S("2")); + test(S(), SV("12345678901234567890"), 2, 3, S("345")); + test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); + test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); + + test(S("12345"), SV(), 0, 0, S("12345")); + test(S("12345"), SV("12345"), 2, 2, S("1234534")); + test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890")); + + test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890")); + test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234")); + test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, + S("123456789012345678906789012345")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string_view SV; - test(S(), SV(), 0, 0, S()); - test(S(), SV(), 1, 0, S()); - test(S(), SV("12345"), 0, 3, S("123")); - test(S(), SV("12345"), 1, 4, S("2345")); - test(S(), SV("12345"), 3, 15, S("45")); - test(S(), SV("12345"), 5, 15, S("")); - test(S(), SV("12345"), 6, 15, S("not happening")); - test(S(), SV("12345678901234567890"), 0, 0, S()); - test(S(), SV("12345678901234567890"), 1, 1, S("2")); - test(S(), SV("12345678901234567890"), 2, 3, S("345")); - test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); - test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), SV(), 0, 0, S("12345")); - test(S("12345"), SV("12345"), 2, 2, S("1234534")); - test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string , min_allocator> S; - typedef std::basic_string_view > SV; - test(S(), SV(), 0, 0, S()); - test(S(), SV(), 1, 0, S()); - test(S(), SV("12345"), 0, 3, S("123")); - test(S(), SV("12345"), 1, 4, S("2345")); - test(S(), SV("12345"), 3, 15, S("45")); - test(S(), SV("12345"), 5, 15, S("")); - test(S(), SV("12345"), 6, 15, S("not happening")); - test(S(), SV("12345678901234567890"), 0, 0, S()); - test(S(), SV("12345678901234567890"), 1, 1, S("2")); - test(S(), SV("12345678901234567890"), 2, 3, S("345")); - test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); - test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), SV(), 0, 0, S("12345")); - test(S("12345"), SV("12345"), 2, 2, S("1234534")); - test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } + test_string, min_allocator>>(); #endif + { typedef std::string S; typedef std::string_view SV; @@ -195,7 +174,6 @@ s.append(sv, 0, std::string::npos); assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); } - return true; } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp @@ -52,125 +52,71 @@ } #endif +template +TEST_CONSTEXPR_CXX20 void test_string() { + const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + test(S(), s, s, S()); + test(S(), s, s+1, S("A")); + test(S(), s, s+10, S("ABCDEFGHIJ")); + test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), s, s, S("12345")); + test(S("12345"), s, s+1, S("12345A")); + test(S("12345"), s, s+10, S("12345ABCDEFGHIJ")); + test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), s, s, S("1234567890")); + test(S("1234567890"), s, s+1, S("1234567890A")); + test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), s, s, S("12345678901234567890")); + test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A")); + test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ")); + test(S("12345678901234567890"), s, s+52, + S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s), S()); + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s), + S("12345")); + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), + S("12345A")); + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("12345ABCDEFGHIJ")); + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), + S("1234567890")); + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), + S("1234567890A")); + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), + S("12345678901234567890")); + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), + S("12345678901234567890""A")); + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("12345678901234567890""ABCDEFGHIJ")); + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), s, s, S()); - test(S(), s, s+1, S("A")); - test(S(), s, s+10, S("ABCDEFGHIJ")); - test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), s, s, S("12345")); - test(S("12345"), s, s+1, S("12345A")); - test(S("12345"), s, s+10, S("12345ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S("1234567890")); - test(S("1234567890"), s, s+1, S("1234567890A")); - test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S("12345678901234567890")); - test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A")); - test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s), S()); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S("12345")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("12345A")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("12345ABCDEFGHIJ")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S("1234567890")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("1234567890A")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S("12345678901234567890")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("12345678901234567890""A")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), s, s, S()); - test(S(), s, s+1, S("A")); - test(S(), s, s+10, S("ABCDEFGHIJ")); - test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), s, s, S("12345")); - test(S("12345"), s, s+1, S("12345A")); - test(S("12345"), s, s+10, S("12345ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S("1234567890")); - test(S("1234567890"), s, s+1, S("1234567890A")); - test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S("12345678901234567890")); - test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A")); - test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s), S()); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S("12345")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("12345A")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("12345ABCDEFGHIJ")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S("1234567890")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("1234567890A")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S("12345678901234567890")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("12345678901234567890""A")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } + test_string, min_allocator>>(); #endif + #ifndef TEST_HAS_NO_EXCEPTIONS if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw typedef std::string S; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp @@ -26,38 +26,26 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "12345678901234567890", S("12345678901234567890")); - - test(S("12345"), "", S("12345")); - test(S("12345"), "12345", S("1234512345")); - test(S("12345"), "1234567890", S("123451234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), "", S()); + test(S(), "12345", S("12345")); + test(S(), "12345678901234567890", S("12345678901234567890")); + + test(S("12345"), "", S("12345")); + test(S("12345"), "12345", S("1234512345")); + test(S("12345"), "1234567890", S("123451234567890")); + + test(S("12345678901234567890"), "", S("12345678901234567890")); + test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); + test(S("12345678901234567890"), "12345678901234567890", + S("1234567890123456789012345678901234567890")); +} - test(S("12345678901234567890"), "", S("12345678901234567890")); - test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", - S("1234567890123456789012345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "12345678901234567890", S("12345678901234567890")); - - test(S("12345"), "", S("12345")); - test(S("12345"), "12345", S("1234512345")); - test(S("12345"), "1234567890", S("123451234567890")); - - test(S("12345678901234567890"), "", S("12345678901234567890")); - test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", - S("1234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif { // test appending to self @@ -75,7 +63,6 @@ s_long.append(s_long.c_str()); assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/"); } - return true; } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp @@ -27,46 +27,30 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), "", 0, S()); - test(S(), "12345", 3, S("123")); - test(S(), "12345", 4, S("1234")); - test(S(), "12345678901234567890", 0, S()); - test(S(), "12345678901234567890", 1, S("1")); - test(S(), "12345678901234567890", 3, S("123")); - test(S(), "12345678901234567890", 20, S("12345678901234567890")); - - test(S("12345"), "", 0, S("12345")); - test(S("12345"), "12345", 5, S("1234512345")); - test(S("12345"), "1234567890", 10, S("123451234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), "", 0, S()); + test(S(), "12345", 3, S("123")); + test(S(), "12345", 4, S("1234")); + test(S(), "12345678901234567890", 0, S()); + test(S(), "12345678901234567890", 1, S("1")); + test(S(), "12345678901234567890", 3, S("123")); + test(S(), "12345678901234567890", 20, S("12345678901234567890")); + + test(S("12345"), "", 0, S("12345")); + test(S("12345"), "12345", 5, S("1234512345")); + test(S("12345"), "1234567890", 10, S("123451234567890")); + + test(S("12345678901234567890"), "", 0, S("12345678901234567890")); + test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345")); + test(S("12345678901234567890"), "12345678901234567890", 20, + S("1234567890123456789012345678901234567890")); +} - test(S("12345678901234567890"), "", 0, S("12345678901234567890")); - test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("1234567890123456789012345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), "", 0, S()); - test(S(), "12345", 3, S("123")); - test(S(), "12345", 4, S("1234")); - test(S(), "12345678901234567890", 0, S()); - test(S(), "12345678901234567890", 1, S("1")); - test(S(), "12345678901234567890", 3, S("123")); - test(S(), "12345678901234567890", 20, S("12345678901234567890")); - - test(S("12345"), "", 0, S("12345")); - test(S("12345"), "12345", 5, S("1234512345")); - test(S("12345"), "1234567890", 10, S("123451234567890")); - - test(S("12345678901234567890"), "", 0, S("12345678901234567890")); - test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("1234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif { // test appending to self diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp @@ -26,38 +26,26 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S(1, 'a')); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - - test(S("12345"), 0, 'a', S("12345")); - test(S("12345"), 1, 'a', S("12345a")); - test(S("12345"), 10, 'a', S("12345aaaaaaaaaa")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), 0, 'a', S()); + test(S(), 1, 'a', S(1, 'a')); + test(S(), 10, 'a', S(10, 'a')); + test(S(), 100, 'a', S(100, 'a')); + + test(S("12345"), 0, 'a', S("12345")); + test(S("12345"), 1, 'a', S("12345a")); + test(S("12345"), 10, 'a', S("12345aaaaaaaaaa")); + + test(S("12345678901234567890"), 0, 'a', S("12345678901234567890")); + test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a")); + test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa")); +} - test(S("12345678901234567890"), 0, 'a', S("12345678901234567890")); - test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a")); - test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S(1, 'a')); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - - test(S("12345"), 0, 'a', S("12345")); - test(S("12345"), 1, 'a', S("12345a")); - test(S("12345"), 10, 'a', S("12345aaaaaaaaaa")); - - test(S("12345678901234567890"), 0, 'a', S("12345678901234567890")); - test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a")); - test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp @@ -26,57 +26,37 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S("12345")); - test(S("12345"), S("12345"), S("1234512345")); - test(S("12345"), S("1234567890"), S("123451234567890")); - test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), S(), S("1234567890")); - test(S("1234567890"), S("12345"), S("123456789012345")); - test(S("1234567890"), S("1234567890"), S("12345678901234567890")); - test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), S(), S()); + test(S(), S("12345"), S("12345")); + test(S(), S("1234567890"), S("1234567890")); + test(S(), S("12345678901234567890"), S("12345678901234567890")); + + test(S("12345"), S(), S("12345")); + test(S("12345"), S("12345"), S("1234512345")); + test(S("12345"), S("1234567890"), S("123451234567890")); + test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); + + test(S("1234567890"), S(), S("1234567890")); + test(S("1234567890"), S("12345"), S("123456789012345")); + test(S("1234567890"), S("1234567890"), S("12345678901234567890")); + test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); + + test(S("12345678901234567890"), S(), S("12345678901234567890")); + test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); + test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); + test(S("12345678901234567890"), S("12345678901234567890"), + S("1234567890123456789012345678901234567890")); +} - test(S("12345678901234567890"), S(), S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S("12345")); - test(S("12345"), S("12345"), S("1234512345")); - test(S("12345"), S("1234567890"), S("123451234567890")); - test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), S(), S("1234567890")); - test(S("1234567890"), S("12345"), S("123456789012345")); - test(S("1234567890"), S("1234567890"), S("12345678901234567890")); - test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); - - test(S("12345678901234567890"), S(), S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s; s.append({"abc", 1}); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp @@ -71,57 +71,37 @@ #endif } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), S(), 0, 0, S()); - test(S(), S(), 1, 0, S()); - test(S(), S("12345"), 0, 3, S("123")); - test(S(), S("12345"), 1, 4, S("2345")); - test(S(), S("12345"), 3, 15, S("45")); - test(S(), S("12345"), 5, 15, S("")); - test(S(), S("12345"), 6, 15, S("not happening")); - test(S(), S("12345678901234567890"), 0, 0, S()); - test(S(), S("12345678901234567890"), 1, 1, S("2")); - test(S(), S("12345678901234567890"), 2, 3, S("345")); - test(S(), S("12345678901234567890"), 12, 13, S("34567890")); - test(S(), S("12345678901234567890"), 21, 13, S("not happening")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), S(), 0, 0, S()); + test(S(), S(), 1, 0, S()); + test(S(), S("12345"), 0, 3, S("123")); + test(S(), S("12345"), 1, 4, S("2345")); + test(S(), S("12345"), 3, 15, S("45")); + test(S(), S("12345"), 5, 15, S("")); + test(S(), S("12345"), 6, 15, S("not happening")); + test(S(), S("12345678901234567890"), 0, 0, S()); + test(S(), S("12345678901234567890"), 1, 1, S("2")); + test(S(), S("12345678901234567890"), 2, 3, S("345")); + test(S(), S("12345678901234567890"), 12, 13, S("34567890")); + test(S(), S("12345678901234567890"), 21, 13, S("not happening")); - test(S("12345"), S(), 0, 0, S("12345")); - test(S("12345"), S("12345"), 2, 2, S("1234534")); - test(S("12345"), S("1234567890"), 0, 100, S("123451234567890")); + test(S("12345"), S(), 0, 0, S("12345")); + test(S("12345"), S("12345"), 2, 2, S("1234534")); + test(S("12345"), S("1234567890"), 0, 100, S("123451234567890")); - test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), S(), 0, 0, S()); - test(S(), S(), 1, 0, S()); - test(S(), S("12345"), 0, 3, S("123")); - test(S(), S("12345"), 1, 4, S("2345")); - test(S(), S("12345"), 3, 15, S("45")); - test(S(), S("12345"), 5, 15, S("")); - test(S(), S("12345"), 6, 15, S("not happening")); - test(S(), S("12345678901234567890"), 0, 0, S()); - test(S(), S("12345678901234567890"), 1, 1, S("2")); - test(S(), S("12345678901234567890"), 2, 3, S("345")); - test(S(), S("12345678901234567890"), 12, 13, S("34567890")); - test(S(), S("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), S(), 0, 0, S("12345")); - test(S("12345"), S("12345"), 2, 2, S("1234534")); - test(S("12345"), S("1234567890"), 0, 100, S("123451234567890")); + test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890")); + test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234")); + test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, + S("123456789012345678906789012345")); +} - test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif + { typedef std::string S; test_npos(S(), S(), 0, S()); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp @@ -27,56 +27,35 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string_view SV; - test(S(), SV(), S()); - test(S(), SV("12345"), S("12345")); - test(S(), SV("1234567890"), S("1234567890")); - test(S(), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), SV(), S("12345")); - test(S("12345"), SV("12345"), S("1234512345")); - test(S("12345"), SV("1234567890"), S("123451234567890")); - test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(S(), SV(), S()); + test(S(), SV("12345"), S("12345")); + test(S(), SV("1234567890"), S("1234567890")); + test(S(), SV("12345678901234567890"), S("12345678901234567890")); - test(S("1234567890"), SV(), S("1234567890")); - test(S("1234567890"), SV("12345"), S("123456789012345")); - test(S("1234567890"), SV("1234567890"), S("12345678901234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890")); - - test(S("12345678901234567890"), SV(), S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string , min_allocator> S; - typedef std::basic_string_view > SV; - test(S(), SV(), S()); - test(S(), SV("12345"), S("12345")); - test(S(), SV("1234567890"), S("1234567890")); - test(S(), SV("12345678901234567890"), S("12345678901234567890")); + test(S("12345"), SV(), S("12345")); + test(S("12345"), SV("12345"), S("1234512345")); + test(S("12345"), SV("1234567890"), S("123451234567890")); + test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890")); - test(S("12345"), SV(), S("12345")); - test(S("12345"), SV("12345"), S("1234512345")); - test(S("12345"), SV("1234567890"), S("123451234567890")); - test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890")); + test(S("1234567890"), SV(), S("1234567890")); + test(S("1234567890"), SV("12345"), S("123456789012345")); + test(S("1234567890"), SV("1234567890"), S("12345678901234567890")); + test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890")); - test(S("1234567890"), SV(), S("1234567890")); - test(S("1234567890"), SV("12345"), S("123456789012345")); - test(S("1234567890"), SV("1234567890"), S("12345678901234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890")); + test(S("12345678901234567890"), SV(), S("12345678901234567890")); + test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345")); + test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890")); + test(S("12345678901234567890"), SV("12345678901234567890"), + S("1234567890123456789012345678901234567890")); +} - test(S("12345678901234567890"), SV(), S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp @@ -70,59 +70,38 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(S(), SV(), 0, 0, S()); + test(S(), SV(), 1, 0, S()); + test(S(), SV("12345"), 0, 3, S("123")); + test(S(), SV("12345"), 1, 4, S("2345")); + test(S(), SV("12345"), 3, 15, S("45")); + test(S(), SV("12345"), 5, 15, S("")); + test(S(), SV("12345"), 6, 15, S("not happening")); + test(S(), SV("12345678901234567890"), 0, 0, S()); + test(S(), SV("12345678901234567890"), 1, 1, S("2")); + test(S(), SV("12345678901234567890"), 2, 3, S("345")); + test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); + test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); + + test(S("12345"), SV(), 0, 0, S()); + test(S("12345"), SV("12345"), 2, 2, S("34")); + test(S("12345"), SV("1234567890"), 0, 100, S("1234567890")); + + test(S("12345678901234567890"), SV(), 0, 0, S()); + test(S("12345678901234567890"), SV("12345"), 1, 3, S("234")); + test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, + S("6789012345")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string_view SV; - test(S(), SV(), 0, 0, S()); - test(S(), SV(), 1, 0, S()); - test(S(), SV("12345"), 0, 3, S("123")); - test(S(), SV("12345"), 1, 4, S("2345")); - test(S(), SV("12345"), 3, 15, S("45")); - test(S(), SV("12345"), 5, 15, S("")); - test(S(), SV("12345"), 6, 15, S("not happening")); - test(S(), SV("12345678901234567890"), 0, 0, S()); - test(S(), SV("12345678901234567890"), 1, 1, S("2")); - test(S(), SV("12345678901234567890"), 2, 3, S("345")); - test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); - test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), SV(), 0, 0, S()); - test(S("12345"), SV("12345"), 2, 2, S("34")); - test(S("12345"), SV("1234567890"), 0, 100, S("1234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S()); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("6789012345")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string , min_allocator> S; - typedef std::basic_string_view > SV; - test(S(), SV(), 0, 0, S()); - test(S(), SV(), 1, 0, S()); - test(S(), SV("12345"), 0, 3, S("123")); - test(S(), SV("12345"), 1, 4, S("2345")); - test(S(), SV("12345"), 3, 15, S("45")); - test(S(), SV("12345"), 5, 15, S("")); - test(S(), SV("12345"), 6, 15, S("not happening")); - test(S(), SV("12345678901234567890"), 0, 0, S()); - test(S(), SV("12345678901234567890"), 1, 1, S("2")); - test(S(), SV("12345678901234567890"), 2, 3, S("345")); - test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); - test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), SV(), 0, 0, S()); - test(S("12345"), SV("12345"), 2, 2, S("34")); - test(S("12345"), SV("1234567890"), 0, 100, S("1234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S()); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("6789012345")); - } + test_string, min_allocator>>(); #endif + { typedef std::string S; typedef std::string_view SV; @@ -190,7 +169,6 @@ s.assign(sv, 0, std::string::npos); assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); } - return true; } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp @@ -52,125 +52,71 @@ } #endif +template +TEST_CONSTEXPR_CXX20 void test_string() { + const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + test(S(), s, s, S()); + test(S(), s, s+1, S("A")); + test(S(), s, s+10, S("ABCDEFGHIJ")); + test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), s, s, S()); + test(S("12345"), s, s+1, S("A")); + test(S("12345"), s, s+10, S("ABCDEFGHIJ")); + test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), s, s, S()); + test(S("1234567890"), s, s+1, S("A")); + test(S("1234567890"), s, s+10, S("ABCDEFGHIJ")); + test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), s, s, S()); + test(S("12345678901234567890"), s, s+1, S("A")); + test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ")); + test(S("12345678901234567890"), s, s+52, + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s), S()); + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s), + S()); + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), + S("A")); + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), + S()); + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), + S("A")); + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), + S()); + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), + S("A")); + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), + S("ABCDEFGHIJ")); + test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), s, s, S()); - test(S(), s, s+1, S("A")); - test(S(), s, s+10, S("ABCDEFGHIJ")); - test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), s, s, S()); - test(S("12345"), s, s+1, S("A")); - test(S("12345"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S()); - test(S("1234567890"), s, s+1, S("A")); - test(S("1234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S()); - test(S("12345678901234567890"), s, s+1, S("A")); - test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s), S()); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S()); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("A")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S()); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("A")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S()); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("A")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), s, s, S()); - test(S(), s, s+1, S("A")); - test(S(), s, s+10, S("ABCDEFGHIJ")); - test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), s, s, S()); - test(S("12345"), s, s+1, S("A")); - test(S("12345"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S()); - test(S("1234567890"), s, s+1, S("A")); - test(S("1234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S()); - test(S("12345678901234567890"), s, s+1, S("A")); - test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s), S()); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S(), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S()); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("A")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S("12345"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S()); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("A")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S("1234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s), - S()); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+1), - S("A")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+10), - S("ABCDEFGHIJ")); - test(S("12345678901234567890"), cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } + test_string, min_allocator>>(); #endif + #ifndef TEST_HAS_NO_EXCEPTIONS if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw typedef std::string S; @@ -222,7 +168,6 @@ std::string expected = sneaky + std::string(1, '\0'); test(sneaky, sneaky.data(), sneaky.data() + sneaky.size() + 1, expected); } - return true; } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp @@ -26,38 +26,26 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "12345678901234567890", S("12345678901234567890")); - - test(S("12345"), "", S()); - test(S("12345"), "12345", S("12345")); - test(S("12345"), "1234567890", S("1234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), "", S()); + test(S(), "12345", S("12345")); + test(S(), "12345678901234567890", S("12345678901234567890")); + + test(S("12345"), "", S()); + test(S("12345"), "12345", S("12345")); + test(S("12345"), "1234567890", S("1234567890")); + + test(S("12345678901234567890"), "", S()); + test(S("12345678901234567890"), "12345", S("12345")); + test(S("12345678901234567890"), "12345678901234567890", + S("12345678901234567890")); +} - test(S("12345678901234567890"), "", S()); - test(S("12345678901234567890"), "12345", S("12345")); - test(S("12345678901234567890"), "12345678901234567890", - S("12345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "12345678901234567890", S("12345678901234567890")); - - test(S("12345"), "", S()); - test(S("12345"), "12345", S("12345")); - test(S("12345"), "1234567890", S("1234567890")); - - test(S("12345678901234567890"), "", S()); - test(S("12345678901234567890"), "12345", S("12345")); - test(S("12345678901234567890"), "12345678901234567890", - S("12345678901234567890")); - } + test_string, min_allocator>>(); #endif { // test assignment to self diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp @@ -27,47 +27,32 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), "", 0, S()); - test(S(), "12345", 3, S("123")); - test(S(), "12345", 4, S("1234")); - test(S(), "12345678901234567890", 0, S()); - test(S(), "12345678901234567890", 1, S("1")); - test(S(), "12345678901234567890", 3, S("123")); - test(S(), "12345678901234567890", 20, S("12345678901234567890")); - - test(S("12345"), "", 0, S()); - test(S("12345"), "12345", 5, S("12345")); - test(S("12345"), "1234567890", 10, S("1234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), "", 0, S()); + test(S(), "12345", 3, S("123")); + test(S(), "12345", 4, S("1234")); + test(S(), "12345678901234567890", 0, S()); + test(S(), "12345678901234567890", 1, S("1")); + test(S(), "12345678901234567890", 3, S("123")); + test(S(), "12345678901234567890", 20, S("12345678901234567890")); + + test(S("12345"), "", 0, S()); + test(S("12345"), "12345", 5, S("12345")); + test(S("12345"), "1234567890", 10, S("1234567890")); + + test(S("12345678901234567890"), "", 0, S()); + test(S("12345678901234567890"), "12345", 5, S("12345")); + test(S("12345678901234567890"), "12345678901234567890", 20, + S("12345678901234567890")); +} - test(S("12345678901234567890"), "", 0, S()); - test(S("12345678901234567890"), "12345", 5, S("12345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("12345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), "", 0, S()); - test(S(), "12345", 3, S("123")); - test(S(), "12345", 4, S("1234")); - test(S(), "12345678901234567890", 0, S()); - test(S(), "12345678901234567890", 1, S("1")); - test(S(), "12345678901234567890", 3, S("123")); - test(S(), "12345678901234567890", 20, S("12345678901234567890")); - - test(S("12345"), "", 0, S()); - test(S("12345"), "12345", 5, S("12345")); - test(S("12345"), "1234567890", 10, S("1234567890")); - - test(S("12345678901234567890"), "", 0, S()); - test(S("12345678901234567890"), "12345", 5, S("12345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("12345678901234567890")); - } + test_string, min_allocator>>(); #endif + { // test assign to self typedef std::string S; S s_short = "123/"; @@ -84,7 +69,6 @@ s_long.assign(s_long.data() + 2, 8 ); assert(s_long == "rem ipsu"); } - return true; } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp @@ -27,54 +27,34 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S()); - test(S("12345"), S("12345"), S("12345")); - test(S("12345"), S("1234567890"), S("1234567890")); - test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), S(), S()); - test(S("1234567890"), S("12345"), S("12345")); - test(S("1234567890"), S("1234567890"), S("1234567890")); - test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), S(), S()); + test(S(), S("12345"), S("12345")); + test(S(), S("1234567890"), S("1234567890")); + test(S(), S("12345678901234567890"), S("12345678901234567890")); - test(S("12345678901234567890"), S(), S()); - test(S("12345678901234567890"), S("12345"), S("12345")); - test(S("12345678901234567890"), S("1234567890"), S("1234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("12345678901234567890")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); + test(S("12345"), S(), S()); + test(S("12345"), S("12345"), S("12345")); + test(S("12345"), S("1234567890"), S("1234567890")); + test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); - test(S("12345"), S(), S()); - test(S("12345"), S("12345"), S("12345")); - test(S("12345"), S("1234567890"), S("1234567890")); - test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); + test(S("1234567890"), S(), S()); + test(S("1234567890"), S("12345"), S("12345")); + test(S("1234567890"), S("1234567890"), S("1234567890")); + test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); - test(S("1234567890"), S(), S()); - test(S("1234567890"), S("12345"), S("12345")); - test(S("1234567890"), S("1234567890"), S("1234567890")); - test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); + test(S("12345678901234567890"), S(), S()); + test(S("12345678901234567890"), S("12345"), S("12345")); + test(S("12345678901234567890"), S("1234567890"), S("1234567890")); + test(S("12345678901234567890"), S("12345678901234567890"), + S("12345678901234567890")); +} - test(S("12345678901234567890"), S(), S()); - test(S("12345678901234567890"), S("12345"), S("12345")); - test(S("12345678901234567890"), S("1234567890"), S("1234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("12345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp @@ -26,38 +26,26 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S(1, 'a')); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - - test(S("12345"), 0, 'a', S()); - test(S("12345"), 1, 'a', S(1, 'a')); - test(S("12345"), 10, 'a', S(10, 'a')); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), 0, 'a', S()); + test(S(), 1, 'a', S(1, 'a')); + test(S(), 10, 'a', S(10, 'a')); + test(S(), 100, 'a', S(100, 'a')); + + test(S("12345"), 0, 'a', S()); + test(S("12345"), 1, 'a', S(1, 'a')); + test(S("12345"), 10, 'a', S(10, 'a')); + + test(S("12345678901234567890"), 0, 'a', S()); + test(S("12345678901234567890"), 1, 'a', S(1, 'a')); + test(S("12345678901234567890"), 10, 'a', S(10, 'a')); +} - test(S("12345678901234567890"), 0, 'a', S()); - test(S("12345678901234567890"), 1, 'a', S(1, 'a')); - test(S("12345678901234567890"), 10, 'a', S(10, 'a')); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S(1, 'a')); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - - test(S("12345"), 0, 'a', S()); - test(S("12345"), 1, 'a', S(1, 'a')); - test(S("12345"), 10, 'a', S(10, 'a')); - - test(S("12345678901234567890"), 0, 'a', S()); - test(S("12345678901234567890"), 1, 'a', S(1, 'a')); - test(S("12345678901234567890"), 10, 'a', S(10, 'a')); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp @@ -71,57 +71,37 @@ #endif } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), S(), 0, 0, S()); - test(S(), S(), 1, 0, S()); - test(S(), S("12345"), 0, 3, S("123")); - test(S(), S("12345"), 1, 4, S("2345")); - test(S(), S("12345"), 3, 15, S("45")); - test(S(), S("12345"), 5, 15, S("")); - test(S(), S("12345"), 6, 15, S("not happening")); - test(S(), S("12345678901234567890"), 0, 0, S()); - test(S(), S("12345678901234567890"), 1, 1, S("2")); - test(S(), S("12345678901234567890"), 2, 3, S("345")); - test(S(), S("12345678901234567890"), 12, 13, S("34567890")); - test(S(), S("12345678901234567890"), 21, 13, S("not happening")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), S(), 0, 0, S()); + test(S(), S(), 1, 0, S()); + test(S(), S("12345"), 0, 3, S("123")); + test(S(), S("12345"), 1, 4, S("2345")); + test(S(), S("12345"), 3, 15, S("45")); + test(S(), S("12345"), 5, 15, S("")); + test(S(), S("12345"), 6, 15, S("not happening")); + test(S(), S("12345678901234567890"), 0, 0, S()); + test(S(), S("12345678901234567890"), 1, 1, S("2")); + test(S(), S("12345678901234567890"), 2, 3, S("345")); + test(S(), S("12345678901234567890"), 12, 13, S("34567890")); + test(S(), S("12345678901234567890"), 21, 13, S("not happening")); - test(S("12345"), S(), 0, 0, S()); - test(S("12345"), S("12345"), 2, 2, S("34")); - test(S("12345"), S("1234567890"), 0, 100, S("1234567890")); + test(S("12345"), S(), 0, 0, S()); + test(S("12345"), S("12345"), 2, 2, S("34")); + test(S("12345"), S("1234567890"), 0, 100, S("1234567890")); - test(S("12345678901234567890"), S(), 0, 0, S()); - test(S("12345678901234567890"), S("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("6789012345")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), S(), 0, 0, S()); - test(S(), S(), 1, 0, S()); - test(S(), S("12345"), 0, 3, S("123")); - test(S(), S("12345"), 1, 4, S("2345")); - test(S(), S("12345"), 3, 15, S("45")); - test(S(), S("12345"), 5, 15, S("")); - test(S(), S("12345"), 6, 15, S("not happening")); - test(S(), S("12345678901234567890"), 0, 0, S()); - test(S(), S("12345678901234567890"), 1, 1, S("2")); - test(S(), S("12345678901234567890"), 2, 3, S("345")); - test(S(), S("12345678901234567890"), 12, 13, S("34567890")); - test(S(), S("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), S(), 0, 0, S()); - test(S("12345"), S("12345"), 2, 2, S("34")); - test(S("12345"), S("1234567890"), 0, 100, S("1234567890")); + test(S("12345678901234567890"), S(), 0, 0, S()); + test(S("12345678901234567890"), S("12345"), 1, 3, S("234")); + test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, + S("6789012345")); +} - test(S("12345678901234567890"), S(), 0, 0, S()); - test(S("12345678901234567890"), S("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("6789012345")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif + { typedef std::string S; test_npos(S(), S(), 0, S()); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp @@ -38,67 +38,42 @@ assert(s.get_allocator() == a); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string_view SV; - test(S(), SV(), S()); - test(S(), SV("12345"), S("12345")); - test(S(), SV("1234567890"), S("1234567890")); - test(S(), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), SV(), S()); - test(S("12345"), SV("12345"), S("12345")); - test(S("12345"), SV("1234567890"), S("1234567890")); - test(S("12345"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), SV(), S()); - test(S("1234567890"), SV("12345"), S("12345")); - test(S("1234567890"), SV("1234567890"), S("1234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), SV(), S()); - test(S("12345678901234567890"), SV("12345"), S("12345")); - test(S("12345678901234567890"), SV("1234567890"), S("1234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("12345678901234567890")); - - testAlloc(S(), SV(), std::allocator()); - testAlloc(S(), SV("12345"), std::allocator()); - testAlloc(S(), SV("1234567890"), std::allocator()); - testAlloc(S(), SV("12345678901234567890"), std::allocator()); - } +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(S(), SV(), S()); + test(S(), SV("12345"), S("12345")); + test(S(), SV("1234567890"), S("1234567890")); + test(S(), SV("12345678901234567890"), S("12345678901234567890")); + + test(S("12345"), SV(), S()); + test(S("12345"), SV("12345"), S("12345")); + test(S("12345"), SV("1234567890"), S("1234567890")); + test(S("12345"), SV("12345678901234567890"), S("12345678901234567890")); + + test(S("1234567890"), SV(), S()); + test(S("1234567890"), SV("12345"), S("12345")); + test(S("1234567890"), SV("1234567890"), S("1234567890")); + test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890")); + + test(S("12345678901234567890"), SV(), S()); + test(S("12345678901234567890"), SV("12345"), S("12345")); + test(S("12345678901234567890"), SV("1234567890"), S("1234567890")); + test(S("12345678901234567890"), SV("12345678901234567890"), + S("12345678901234567890")); + + using A = typename S::allocator_type; + + testAlloc(S(), SV(), A()); + testAlloc(S(), SV("12345"), A()); + testAlloc(S(), SV("1234567890"), A()); + testAlloc(S(), SV("12345678901234567890"), A()); +} +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string , min_allocator> S; - typedef std::basic_string_view > SV; - test(S(), SV(), S()); - test(S(), SV("12345"), S("12345")); - test(S(), SV("1234567890"), S("1234567890")); - test(S(), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), SV(), S()); - test(S("12345"), SV("12345"), S("12345")); - test(S("12345"), SV("1234567890"), S("1234567890")); - test(S("12345"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), SV(), S()); - test(S("1234567890"), SV("12345"), S("12345")); - test(S("1234567890"), SV("1234567890"), S("1234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), SV(), S()); - test(S("12345678901234567890"), SV("12345"), S("12345")); - test(S("12345678901234567890"), SV("1234567890"), S("1234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("12345678901234567890")); - - testAlloc(S(), SV(), min_allocator()); - testAlloc(S(), SV("12345"), min_allocator()); - testAlloc(S(), SV("1234567890"), min_allocator()); - testAlloc(S(), SV("12345678901234567890"), min_allocator()); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp @@ -49,132 +49,73 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + char s[50]; + test(S(""), s, 0, 0); + test(S(""), s, 0, 1); + test(S(""), s, 1, 0); + test(S("abcde"), s, 0, 0); + test(S("abcde"), s, 0, 1); + test(S("abcde"), s, 0, 2); + test(S("abcde"), s, 0, 4); + test(S("abcde"), s, 0, 5); + test(S("abcde"), s, 0, 6); + test(S("abcde"), s, 1, 0); + test(S("abcde"), s, 1, 1); + test(S("abcde"), s, 1, 2); + test(S("abcde"), s, 1, 4); + test(S("abcde"), s, 1, 5); + test(S("abcde"), s, 2, 0); + test(S("abcde"), s, 2, 1); + test(S("abcde"), s, 2, 2); + test(S("abcde"), s, 2, 4); + test(S("abcde"), s, 4, 0); + test(S("abcde"), s, 4, 1); + test(S("abcde"), s, 4, 2); + test(S("abcde"), s, 5, 0); + test(S("abcde"), s, 5, 1); + test(S("abcde"), s, 6, 0); + test(S("abcdefghijklmnopqrst"), s, 0, 0); + test(S("abcdefghijklmnopqrst"), s, 0, 1); + test(S("abcdefghijklmnopqrst"), s, 0, 2); + test(S("abcdefghijklmnopqrst"), s, 0, 10); + test(S("abcdefghijklmnopqrst"), s, 0, 19); + test(S("abcdefghijklmnopqrst"), s, 0, 20); + test(S("abcdefghijklmnopqrst"), s, 0, 21); + test(S("abcdefghijklmnopqrst"), s, 1, 0); + test(S("abcdefghijklmnopqrst"), s, 1, 1); + test(S("abcdefghijklmnopqrst"), s, 1, 2); + test(S("abcdefghijklmnopqrst"), s, 1, 9); + test(S("abcdefghijklmnopqrst"), s, 1, 18); + test(S("abcdefghijklmnopqrst"), s, 1, 19); + test(S("abcdefghijklmnopqrst"), s, 1, 20); + test(S("abcdefghijklmnopqrst"), s, 2, 0); + test(S("abcdefghijklmnopqrst"), s, 2, 1); + test(S("abcdefghijklmnopqrst"), s, 2, 2); + test(S("abcdefghijklmnopqrst"), s, 2, 9); + test(S("abcdefghijklmnopqrst"), s, 2, 17); + test(S("abcdefghijklmnopqrst"), s, 2, 18); + test(S("abcdefghijklmnopqrst"), s, 2, 19); + test(S("abcdefghijklmnopqrst"), s, 10, 0); + test(S("abcdefghijklmnopqrst"), s, 10, 1); + test(S("abcdefghijklmnopqrst"), s, 10, 2); + test(S("abcdefghijklmnopqrst"), s, 10, 5); + test(S("abcdefghijklmnopqrst"), s, 10, 9); + test(S("abcdefghijklmnopqrst"), s, 10, 10); + test(S("abcdefghijklmnopqrst"), s, 10, 11); + test(S("abcdefghijklmnopqrst"), s, 19, 0); + test(S("abcdefghijklmnopqrst"), s, 19, 1); + test(S("abcdefghijklmnopqrst"), s, 19, 2); + test(S("abcdefghijklmnopqrst"), s, 20, 0); + test(S("abcdefghijklmnopqrst"), s, 20, 1); + test(S("abcdefghijklmnopqrst"), s, 21, 0); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - char s[50]; - test(S(""), s, 0, 0); - test(S(""), s, 0, 1); - test(S(""), s, 1, 0); - test(S("abcde"), s, 0, 0); - test(S("abcde"), s, 0, 1); - test(S("abcde"), s, 0, 2); - test(S("abcde"), s, 0, 4); - test(S("abcde"), s, 0, 5); - test(S("abcde"), s, 0, 6); - test(S("abcde"), s, 1, 0); - test(S("abcde"), s, 1, 1); - test(S("abcde"), s, 1, 2); - test(S("abcde"), s, 1, 4); - test(S("abcde"), s, 1, 5); - test(S("abcde"), s, 2, 0); - test(S("abcde"), s, 2, 1); - test(S("abcde"), s, 2, 2); - test(S("abcde"), s, 2, 4); - test(S("abcde"), s, 4, 0); - test(S("abcde"), s, 4, 1); - test(S("abcde"), s, 4, 2); - test(S("abcde"), s, 5, 0); - test(S("abcde"), s, 5, 1); - test(S("abcde"), s, 6, 0); - test(S("abcdefghijklmnopqrst"), s, 0, 0); - test(S("abcdefghijklmnopqrst"), s, 0, 1); - test(S("abcdefghijklmnopqrst"), s, 0, 2); - test(S("abcdefghijklmnopqrst"), s, 0, 10); - test(S("abcdefghijklmnopqrst"), s, 0, 19); - test(S("abcdefghijklmnopqrst"), s, 0, 20); - test(S("abcdefghijklmnopqrst"), s, 0, 21); - test(S("abcdefghijklmnopqrst"), s, 1, 0); - test(S("abcdefghijklmnopqrst"), s, 1, 1); - test(S("abcdefghijklmnopqrst"), s, 1, 2); - test(S("abcdefghijklmnopqrst"), s, 1, 9); - test(S("abcdefghijklmnopqrst"), s, 1, 18); - test(S("abcdefghijklmnopqrst"), s, 1, 19); - test(S("abcdefghijklmnopqrst"), s, 1, 20); - test(S("abcdefghijklmnopqrst"), s, 2, 0); - test(S("abcdefghijklmnopqrst"), s, 2, 1); - test(S("abcdefghijklmnopqrst"), s, 2, 2); - test(S("abcdefghijklmnopqrst"), s, 2, 9); - test(S("abcdefghijklmnopqrst"), s, 2, 17); - test(S("abcdefghijklmnopqrst"), s, 2, 18); - test(S("abcdefghijklmnopqrst"), s, 2, 19); - test(S("abcdefghijklmnopqrst"), s, 10, 0); - test(S("abcdefghijklmnopqrst"), s, 10, 1); - test(S("abcdefghijklmnopqrst"), s, 10, 2); - test(S("abcdefghijklmnopqrst"), s, 10, 5); - test(S("abcdefghijklmnopqrst"), s, 10, 9); - test(S("abcdefghijklmnopqrst"), s, 10, 10); - test(S("abcdefghijklmnopqrst"), s, 10, 11); - test(S("abcdefghijklmnopqrst"), s, 19, 0); - test(S("abcdefghijklmnopqrst"), s, 19, 1); - test(S("abcdefghijklmnopqrst"), s, 19, 2); - test(S("abcdefghijklmnopqrst"), s, 20, 0); - test(S("abcdefghijklmnopqrst"), s, 20, 1); - test(S("abcdefghijklmnopqrst"), s, 21, 0); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - char s[50]; - test(S(""), s, 0, 0); - test(S(""), s, 0, 1); - test(S(""), s, 1, 0); - test(S("abcde"), s, 0, 0); - test(S("abcde"), s, 0, 1); - test(S("abcde"), s, 0, 2); - test(S("abcde"), s, 0, 4); - test(S("abcde"), s, 0, 5); - test(S("abcde"), s, 0, 6); - test(S("abcde"), s, 1, 0); - test(S("abcde"), s, 1, 1); - test(S("abcde"), s, 1, 2); - test(S("abcde"), s, 1, 4); - test(S("abcde"), s, 1, 5); - test(S("abcde"), s, 2, 0); - test(S("abcde"), s, 2, 1); - test(S("abcde"), s, 2, 2); - test(S("abcde"), s, 2, 4); - test(S("abcde"), s, 4, 0); - test(S("abcde"), s, 4, 1); - test(S("abcde"), s, 4, 2); - test(S("abcde"), s, 5, 0); - test(S("abcde"), s, 5, 1); - test(S("abcde"), s, 6, 0); - test(S("abcdefghijklmnopqrst"), s, 0, 0); - test(S("abcdefghijklmnopqrst"), s, 0, 1); - test(S("abcdefghijklmnopqrst"), s, 0, 2); - test(S("abcdefghijklmnopqrst"), s, 0, 10); - test(S("abcdefghijklmnopqrst"), s, 0, 19); - test(S("abcdefghijklmnopqrst"), s, 0, 20); - test(S("abcdefghijklmnopqrst"), s, 0, 21); - test(S("abcdefghijklmnopqrst"), s, 1, 0); - test(S("abcdefghijklmnopqrst"), s, 1, 1); - test(S("abcdefghijklmnopqrst"), s, 1, 2); - test(S("abcdefghijklmnopqrst"), s, 1, 9); - test(S("abcdefghijklmnopqrst"), s, 1, 18); - test(S("abcdefghijklmnopqrst"), s, 1, 19); - test(S("abcdefghijklmnopqrst"), s, 1, 20); - test(S("abcdefghijklmnopqrst"), s, 2, 0); - test(S("abcdefghijklmnopqrst"), s, 2, 1); - test(S("abcdefghijklmnopqrst"), s, 2, 2); - test(S("abcdefghijklmnopqrst"), s, 2, 9); - test(S("abcdefghijklmnopqrst"), s, 2, 17); - test(S("abcdefghijklmnopqrst"), s, 2, 18); - test(S("abcdefghijklmnopqrst"), s, 2, 19); - test(S("abcdefghijklmnopqrst"), s, 10, 0); - test(S("abcdefghijklmnopqrst"), s, 10, 1); - test(S("abcdefghijklmnopqrst"), s, 10, 2); - test(S("abcdefghijklmnopqrst"), s, 10, 5); - test(S("abcdefghijklmnopqrst"), s, 10, 9); - test(S("abcdefghijklmnopqrst"), s, 10, 10); - test(S("abcdefghijklmnopqrst"), s, 10, 11); - test(S("abcdefghijklmnopqrst"), s, 19, 0); - test(S("abcdefghijklmnopqrst"), s, 19, 1); - test(S("abcdefghijklmnopqrst"), s, 19, 2); - test(S("abcdefghijklmnopqrst"), s, 20, 0); - test(S("abcdefghijklmnopqrst"), s, 20, 1); - test(S("abcdefghijklmnopqrst"), s, 21, 0); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp @@ -28,38 +28,26 @@ assert(i - s.begin() == pos); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S("abcde"), 0, S("bcde")); + test(S("abcde"), 1, S("acde")); + test(S("abcde"), 2, S("abde")); + test(S("abcde"), 4, S("abcd")); + test(S("abcdefghij"), 0, S("bcdefghij")); + test(S("abcdefghij"), 1, S("acdefghij")); + test(S("abcdefghij"), 5, S("abcdeghij")); + test(S("abcdefghij"), 9, S("abcdefghi")); + test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S("abcde"), 0, S("bcde")); - test(S("abcde"), 1, S("acde")); - test(S("abcde"), 2, S("abde")); - test(S("abcde"), 4, S("abcd")); - test(S("abcdefghij"), 0, S("bcdefghij")); - test(S("abcdefghij"), 1, S("acdefghij")); - test(S("abcdefghij"), 5, S("abcdeghij")); - test(S("abcdefghij"), 9, S("abcdefghi")); - test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S("abcde"), 0, S("bcde")); - test(S("abcde"), 1, S("acde")); - test(S("abcde"), 2, S("abde")); - test(S("abcde"), 4, S("abcd")); - test(S("abcdefghij"), 0, S("bcdefghij")); - test(S("abcdefghij"), 1, S("acdefghij")); - test(S("abcdefghij"), 5, S("abcdeghij")); - test(S("abcdefghij"), 9, S("abcdefghi")); - test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp @@ -29,122 +29,68 @@ assert(i - s.begin() == pos); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(""), 0, 0, S("")); + test(S("abcde"), 0, 0, S("abcde")); + test(S("abcde"), 0, 1, S("bcde")); + test(S("abcde"), 0, 2, S("cde")); + test(S("abcde"), 0, 4, S("e")); + test(S("abcde"), 0, 5, S("")); + test(S("abcde"), 1, 0, S("abcde")); + test(S("abcde"), 1, 1, S("acde")); + test(S("abcde"), 1, 2, S("ade")); + test(S("abcde"), 1, 3, S("ae")); + test(S("abcde"), 1, 4, S("a")); + test(S("abcde"), 2, 0, S("abcde")); + test(S("abcde"), 2, 1, S("abde")); + test(S("abcde"), 2, 2, S("abe")); + test(S("abcde"), 2, 3, S("ab")); + test(S("abcde"), 4, 0, S("abcde")); + test(S("abcde"), 4, 1, S("abcd")); + test(S("abcde"), 5, 0, S("abcde")); + test(S("abcdefghij"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 1, S("bcdefghij")); + test(S("abcdefghij"), 0, 5, S("fghij")); + test(S("abcdefghij"), 0, 9, S("j")); + test(S("abcdefghij"), 0, 10, S("")); + test(S("abcdefghij"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 1, S("acdefghij")); + test(S("abcdefghij"), 1, 4, S("afghij")); + test(S("abcdefghij"), 1, 8, S("aj")); + test(S("abcdefghij"), 1, 9, S("a")); + test(S("abcdefghij"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 1, S("abcdeghij")); + test(S("abcdefghij"), 5, 2, S("abcdehij")); + test(S("abcdefghij"), 5, 4, S("abcdej")); + test(S("abcdefghij"), 5, 5, S("abcde")); + test(S("abcdefghij"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 1, S("abcdefghi")); + test(S("abcdefghij"), 10, 0, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("a")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(""), 0, 0, S("")); - test(S("abcde"), 0, 0, S("abcde")); - test(S("abcde"), 0, 1, S("bcde")); - test(S("abcde"), 0, 2, S("cde")); - test(S("abcde"), 0, 4, S("e")); - test(S("abcde"), 0, 5, S("")); - test(S("abcde"), 1, 0, S("abcde")); - test(S("abcde"), 1, 1, S("acde")); - test(S("abcde"), 1, 2, S("ade")); - test(S("abcde"), 1, 3, S("ae")); - test(S("abcde"), 1, 4, S("a")); - test(S("abcde"), 2, 0, S("abcde")); - test(S("abcde"), 2, 1, S("abde")); - test(S("abcde"), 2, 2, S("abe")); - test(S("abcde"), 2, 3, S("ab")); - test(S("abcde"), 4, 0, S("abcde")); - test(S("abcde"), 4, 1, S("abcd")); - test(S("abcde"), 5, 0, S("abcde")); - test(S("abcdefghij"), 0, 0, S("abcdefghij")); - test(S("abcdefghij"), 0, 1, S("bcdefghij")); - test(S("abcdefghij"), 0, 5, S("fghij")); - test(S("abcdefghij"), 0, 9, S("j")); - test(S("abcdefghij"), 0, 10, S("")); - test(S("abcdefghij"), 1, 0, S("abcdefghij")); - test(S("abcdefghij"), 1, 1, S("acdefghij")); - test(S("abcdefghij"), 1, 4, S("afghij")); - test(S("abcdefghij"), 1, 8, S("aj")); - test(S("abcdefghij"), 1, 9, S("a")); - test(S("abcdefghij"), 5, 0, S("abcdefghij")); - test(S("abcdefghij"), 5, 1, S("abcdeghij")); - test(S("abcdefghij"), 5, 2, S("abcdehij")); - test(S("abcdefghij"), 5, 4, S("abcdej")); - test(S("abcdefghij"), 5, 5, S("abcde")); - test(S("abcdefghij"), 9, 0, S("abcdefghij")); - test(S("abcdefghij"), 9, 1, S("abcdefghi")); - test(S("abcdefghij"), 10, 0, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 19, S("t")); - test(S("abcdefghijklmnopqrst"), 0, 20, S("")); - test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 18, S("at")); - test(S("abcdefghijklmnopqrst"), 1, 19, S("a")); - test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst")); - test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt")); - test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(""), 0, 0, S("")); - test(S("abcde"), 0, 0, S("abcde")); - test(S("abcde"), 0, 1, S("bcde")); - test(S("abcde"), 0, 2, S("cde")); - test(S("abcde"), 0, 4, S("e")); - test(S("abcde"), 0, 5, S("")); - test(S("abcde"), 1, 0, S("abcde")); - test(S("abcde"), 1, 1, S("acde")); - test(S("abcde"), 1, 2, S("ade")); - test(S("abcde"), 1, 3, S("ae")); - test(S("abcde"), 1, 4, S("a")); - test(S("abcde"), 2, 0, S("abcde")); - test(S("abcde"), 2, 1, S("abde")); - test(S("abcde"), 2, 2, S("abe")); - test(S("abcde"), 2, 3, S("ab")); - test(S("abcde"), 4, 0, S("abcde")); - test(S("abcde"), 4, 1, S("abcd")); - test(S("abcde"), 5, 0, S("abcde")); - test(S("abcdefghij"), 0, 0, S("abcdefghij")); - test(S("abcdefghij"), 0, 1, S("bcdefghij")); - test(S("abcdefghij"), 0, 5, S("fghij")); - test(S("abcdefghij"), 0, 9, S("j")); - test(S("abcdefghij"), 0, 10, S("")); - test(S("abcdefghij"), 1, 0, S("abcdefghij")); - test(S("abcdefghij"), 1, 1, S("acdefghij")); - test(S("abcdefghij"), 1, 4, S("afghij")); - test(S("abcdefghij"), 1, 8, S("aj")); - test(S("abcdefghij"), 1, 9, S("a")); - test(S("abcdefghij"), 5, 0, S("abcdefghij")); - test(S("abcdefghij"), 5, 1, S("abcdeghij")); - test(S("abcdefghij"), 5, 2, S("abcdehij")); - test(S("abcdefghij"), 5, 4, S("abcdej")); - test(S("abcdefghij"), 5, 5, S("abcde")); - test(S("abcdefghij"), 9, 0, S("abcdefghij")); - test(S("abcdefghij"), 9, 1, S("abcdefghi")); - test(S("abcdefghij"), 10, 0, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 19, S("t")); - test(S("abcdefghijklmnopqrst"), 0, 20, S("")); - test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 18, S("at")); - test(S("abcdefghijklmnopqrst"), 1, 19, S("a")); - test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst")); - test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt")); - test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp @@ -26,20 +26,17 @@ assert(s == expected); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S("abcde"), S("abcd")); + test(S("abcdefghij"), S("abcdefghi")); + test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S("abcde"), S("abcd")); - test(S("abcdefghij"), S("abcdefghi")); - test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S("abcde"), S("abcd")); - test(S("abcdefghij"), S("abcdefghi")); - test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp @@ -88,214 +88,114 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(""), 0, 0, S("")); - test(S(""), 0, 1, S("")); - test(S(""), 1, 0, S("can't happen")); - test(S("abcde"), 0, 0, S("abcde")); - test(S("abcde"), 0, 1, S("bcde")); - test(S("abcde"), 0, 2, S("cde")); - test(S("abcde"), 0, 4, S("e")); - test(S("abcde"), 0, 5, S("")); - test(S("abcde"), 0, 6, S("")); - test(S("abcde"), 1, 0, S("abcde")); - test(S("abcde"), 1, 1, S("acde")); - test(S("abcde"), 1, 2, S("ade")); - test(S("abcde"), 1, 3, S("ae")); - test(S("abcde"), 1, 4, S("a")); - test(S("abcde"), 1, 5, S("a")); - test(S("abcde"), 2, 0, S("abcde")); - test(S("abcde"), 2, 1, S("abde")); - test(S("abcde"), 2, 2, S("abe")); - test(S("abcde"), 2, 3, S("ab")); - test(S("abcde"), 2, 4, S("ab")); - test(S("abcde"), 4, 0, S("abcde")); - test(S("abcde"), 4, 1, S("abcd")); - test(S("abcde"), 4, 2, S("abcd")); - test(S("abcde"), 5, 0, S("abcde")); - test(S("abcde"), 5, 1, S("abcde")); - test(S("abcde"), 6, 0, S("can't happen")); - test(S("abcdefghij"), 0, 0, S("abcdefghij")); - test(S("abcdefghij"), 0, 1, S("bcdefghij")); - test(S("abcdefghij"), 0, 5, S("fghij")); - test(S("abcdefghij"), 0, 9, S("j")); - test(S("abcdefghij"), 0, 10, S("")); - test(S("abcdefghij"), 0, 11, S("")); - test(S("abcdefghij"), 1, 0, S("abcdefghij")); - test(S("abcdefghij"), 1, 1, S("acdefghij")); - test(S("abcdefghij"), 1, 4, S("afghij")); - test(S("abcdefghij"), 1, 8, S("aj")); - test(S("abcdefghij"), 1, 9, S("a")); - test(S("abcdefghij"), 1, 10, S("a")); - test(S("abcdefghij"), 5, 0, S("abcdefghij")); - test(S("abcdefghij"), 5, 1, S("abcdeghij")); - test(S("abcdefghij"), 5, 2, S("abcdehij")); - test(S("abcdefghij"), 5, 4, S("abcdej")); - test(S("abcdefghij"), 5, 5, S("abcde")); - test(S("abcdefghij"), 5, 6, S("abcde")); - test(S("abcdefghij"), 9, 0, S("abcdefghij")); - test(S("abcdefghij"), 9, 1, S("abcdefghi")); - test(S("abcdefghij"), 9, 2, S("abcdefghi")); - test(S("abcdefghij"), 10, 0, S("abcdefghij")); - test(S("abcdefghij"), 10, 1, S("abcdefghij")); - test(S("abcdefghij"), 11, 0, S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 19, S("t")); - test(S("abcdefghijklmnopqrst"), 0, 20, S("")); - test(S("abcdefghijklmnopqrst"), 0, 21, S("")); - test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 18, S("at")); - test(S("abcdefghijklmnopqrst"), 1, 19, S("a")); - test(S("abcdefghijklmnopqrst"), 1, 20, S("a")); - test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst")); - test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt")); - test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen")); - - test(S(""), 0, S("")); - test(S(""), 1, S("can't happen")); - test(S("abcde"), 0, S("")); - test(S("abcde"), 1, S("a")); - test(S("abcde"), 2, S("ab")); - test(S("abcde"), 4, S("abcd")); - test(S("abcde"), 5, S("abcde")); - test(S("abcde"), 6, S("can't happen")); - test(S("abcdefghij"), 0, S("")); - test(S("abcdefghij"), 1, S("a")); - test(S("abcdefghij"), 5, S("abcde")); - test(S("abcdefghij"), 9, S("abcdefghi")); - test(S("abcdefghij"), 10, S("abcdefghij")); - test(S("abcdefghij"), 11, S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, S("")); - test(S("abcdefghijklmnopqrst"), 1, S("a")); - test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 21, S("can't happen")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(""), 0, 0, S("")); + test(S(""), 0, 1, S("")); + test(S(""), 1, 0, S("can't happen")); + test(S("abcde"), 0, 0, S("abcde")); + test(S("abcde"), 0, 1, S("bcde")); + test(S("abcde"), 0, 2, S("cde")); + test(S("abcde"), 0, 4, S("e")); + test(S("abcde"), 0, 5, S("")); + test(S("abcde"), 0, 6, S("")); + test(S("abcde"), 1, 0, S("abcde")); + test(S("abcde"), 1, 1, S("acde")); + test(S("abcde"), 1, 2, S("ade")); + test(S("abcde"), 1, 3, S("ae")); + test(S("abcde"), 1, 4, S("a")); + test(S("abcde"), 1, 5, S("a")); + test(S("abcde"), 2, 0, S("abcde")); + test(S("abcde"), 2, 1, S("abde")); + test(S("abcde"), 2, 2, S("abe")); + test(S("abcde"), 2, 3, S("ab")); + test(S("abcde"), 2, 4, S("ab")); + test(S("abcde"), 4, 0, S("abcde")); + test(S("abcde"), 4, 1, S("abcd")); + test(S("abcde"), 4, 2, S("abcd")); + test(S("abcde"), 5, 0, S("abcde")); + test(S("abcde"), 5, 1, S("abcde")); + test(S("abcde"), 6, 0, S("can't happen")); + test(S("abcdefghij"), 0, 0, S("abcdefghij")); + test(S("abcdefghij"), 0, 1, S("bcdefghij")); + test(S("abcdefghij"), 0, 5, S("fghij")); + test(S("abcdefghij"), 0, 9, S("j")); + test(S("abcdefghij"), 0, 10, S("")); + test(S("abcdefghij"), 0, 11, S("")); + test(S("abcdefghij"), 1, 0, S("abcdefghij")); + test(S("abcdefghij"), 1, 1, S("acdefghij")); + test(S("abcdefghij"), 1, 4, S("afghij")); + test(S("abcdefghij"), 1, 8, S("aj")); + test(S("abcdefghij"), 1, 9, S("a")); + test(S("abcdefghij"), 1, 10, S("a")); + test(S("abcdefghij"), 5, 0, S("abcdefghij")); + test(S("abcdefghij"), 5, 1, S("abcdeghij")); + test(S("abcdefghij"), 5, 2, S("abcdehij")); + test(S("abcdefghij"), 5, 4, S("abcdej")); + test(S("abcdefghij"), 5, 5, S("abcde")); + test(S("abcdefghij"), 5, 6, S("abcde")); + test(S("abcdefghij"), 9, 0, S("abcdefghij")); + test(S("abcdefghij"), 9, 1, S("abcdefghi")); + test(S("abcdefghij"), 9, 2, S("abcdefghi")); + test(S("abcdefghij"), 10, 0, S("abcdefghij")); + test(S("abcdefghij"), 10, 1, S("abcdefghij")); + test(S("abcdefghij"), 11, 0, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 19, S("t")); + test(S("abcdefghijklmnopqrst"), 0, 20, S("")); + test(S("abcdefghijklmnopqrst"), 0, 21, S("")); + test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 18, S("at")); + test(S("abcdefghijklmnopqrst"), 1, 19, S("a")); + test(S("abcdefghijklmnopqrst"), 1, 20, S("a")); + test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst")); + test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt")); + test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen")); - test(S(""), S("")); - test(S("abcde"), S("")); - test(S("abcdefghij"), S("")); - test(S("abcdefghijklmnopqrst"), S("")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(""), 0, 0, S("")); - test(S(""), 0, 1, S("")); - test(S(""), 1, 0, S("can't happen")); - test(S("abcde"), 0, 0, S("abcde")); - test(S("abcde"), 0, 1, S("bcde")); - test(S("abcde"), 0, 2, S("cde")); - test(S("abcde"), 0, 4, S("e")); - test(S("abcde"), 0, 5, S("")); - test(S("abcde"), 0, 6, S("")); - test(S("abcde"), 1, 0, S("abcde")); - test(S("abcde"), 1, 1, S("acde")); - test(S("abcde"), 1, 2, S("ade")); - test(S("abcde"), 1, 3, S("ae")); - test(S("abcde"), 1, 4, S("a")); - test(S("abcde"), 1, 5, S("a")); - test(S("abcde"), 2, 0, S("abcde")); - test(S("abcde"), 2, 1, S("abde")); - test(S("abcde"), 2, 2, S("abe")); - test(S("abcde"), 2, 3, S("ab")); - test(S("abcde"), 2, 4, S("ab")); - test(S("abcde"), 4, 0, S("abcde")); - test(S("abcde"), 4, 1, S("abcd")); - test(S("abcde"), 4, 2, S("abcd")); - test(S("abcde"), 5, 0, S("abcde")); - test(S("abcde"), 5, 1, S("abcde")); - test(S("abcde"), 6, 0, S("can't happen")); - test(S("abcdefghij"), 0, 0, S("abcdefghij")); - test(S("abcdefghij"), 0, 1, S("bcdefghij")); - test(S("abcdefghij"), 0, 5, S("fghij")); - test(S("abcdefghij"), 0, 9, S("j")); - test(S("abcdefghij"), 0, 10, S("")); - test(S("abcdefghij"), 0, 11, S("")); - test(S("abcdefghij"), 1, 0, S("abcdefghij")); - test(S("abcdefghij"), 1, 1, S("acdefghij")); - test(S("abcdefghij"), 1, 4, S("afghij")); - test(S("abcdefghij"), 1, 8, S("aj")); - test(S("abcdefghij"), 1, 9, S("a")); - test(S("abcdefghij"), 1, 10, S("a")); - test(S("abcdefghij"), 5, 0, S("abcdefghij")); - test(S("abcdefghij"), 5, 1, S("abcdeghij")); - test(S("abcdefghij"), 5, 2, S("abcdehij")); - test(S("abcdefghij"), 5, 4, S("abcdej")); - test(S("abcdefghij"), 5, 5, S("abcde")); - test(S("abcdefghij"), 5, 6, S("abcde")); - test(S("abcdefghij"), 9, 0, S("abcdefghij")); - test(S("abcdefghij"), 9, 1, S("abcdefghi")); - test(S("abcdefghij"), 9, 2, S("abcdefghi")); - test(S("abcdefghij"), 10, 0, S("abcdefghij")); - test(S("abcdefghij"), 10, 1, S("abcdefghij")); - test(S("abcdefghij"), 11, 0, S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 19, S("t")); - test(S("abcdefghijklmnopqrst"), 0, 20, S("")); - test(S("abcdefghijklmnopqrst"), 0, 21, S("")); - test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 18, S("at")); - test(S("abcdefghijklmnopqrst"), 1, 19, S("a")); - test(S("abcdefghijklmnopqrst"), 1, 20, S("a")); - test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst")); - test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt")); - test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen")); + test(S(""), 0, S("")); + test(S(""), 1, S("can't happen")); + test(S("abcde"), 0, S("")); + test(S("abcde"), 1, S("a")); + test(S("abcde"), 2, S("ab")); + test(S("abcde"), 4, S("abcd")); + test(S("abcde"), 5, S("abcde")); + test(S("abcde"), 6, S("can't happen")); + test(S("abcdefghij"), 0, S("")); + test(S("abcdefghij"), 1, S("a")); + test(S("abcdefghij"), 5, S("abcde")); + test(S("abcdefghij"), 9, S("abcdefghi")); + test(S("abcdefghij"), 10, S("abcdefghij")); + test(S("abcdefghij"), 11, S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S("")); + test(S("abcdefghijklmnopqrst"), 1, S("a")); + test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij")); + test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs")); + test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 21, S("can't happen")); - test(S(""), 0, S("")); - test(S(""), 1, S("can't happen")); - test(S("abcde"), 0, S("")); - test(S("abcde"), 1, S("a")); - test(S("abcde"), 2, S("ab")); - test(S("abcde"), 4, S("abcd")); - test(S("abcde"), 5, S("abcde")); - test(S("abcde"), 6, S("can't happen")); - test(S("abcdefghij"), 0, S("")); - test(S("abcdefghij"), 1, S("a")); - test(S("abcdefghij"), 5, S("abcde")); - test(S("abcdefghij"), 9, S("abcdefghi")); - test(S("abcdefghij"), 10, S("abcdefghij")); - test(S("abcdefghij"), 11, S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, S("")); - test(S("abcdefghijklmnopqrst"), 1, S("a")); - test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij")); - test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs")); - test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 21, S("can't happen")); + test(S(""), S("")); + test(S("abcde"), S("")); + test(S("abcdefghij"), S("")); + test(S("abcdefghijklmnopqrst"), S("")); +} - test(S(""), S("")); - test(S("abcde"), S("")); - test(S("abcdefghij"), S("")); - test(S("abcdefghijklmnopqrst"), S("")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp @@ -32,44 +32,29 @@ assert(i == p); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + S s; + test(s, s.begin(), '1', S("1")); + test(s, s.begin(), 'a', S("a1")); + test(s, s.end(), 'b', S("a1b")); + test(s, s.end()-1, 'c', S("a1cb")); + test(s, s.end()-2, 'd', S("a1dcb")); + test(s, s.end()-3, '2', S("a12dcb")); + test(s, s.end()-4, '3', S("a132dcb")); + test(s, s.end()-5, '4', S("a1432dcb")); + test(s, s.begin()+1, '5', S("a51432dcb")); + test(s, s.begin()+2, '6', S("a561432dcb")); + test(s, s.begin()+3, '7', S("a5671432dcb")); + test(s, s.begin()+4, 'A', S("a567A1432dcb")); + test(s, s.begin()+5, 'B', S("a567AB1432dcb")); + test(s, s.begin()+6, 'C', S("a567ABC1432dcb")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - S s; - test(s, s.begin(), '1', S("1")); - test(s, s.begin(), 'a', S("a1")); - test(s, s.end(), 'b', S("a1b")); - test(s, s.end()-1, 'c', S("a1cb")); - test(s, s.end()-2, 'd', S("a1dcb")); - test(s, s.end()-3, '2', S("a12dcb")); - test(s, s.end()-4, '3', S("a132dcb")); - test(s, s.end()-5, '4', S("a1432dcb")); - test(s, s.begin()+1, '5', S("a51432dcb")); - test(s, s.begin()+2, '6', S("a561432dcb")); - test(s, s.begin()+3, '7', S("a5671432dcb")); - test(s, s.begin()+4, 'A', S("a567A1432dcb")); - test(s, s.begin()+5, 'B', S("a567AB1432dcb")); - test(s, s.begin()+6, 'C', S("a567ABC1432dcb")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - S s; - test(s, s.begin(), '1', S("1")); - test(s, s.begin(), 'a', S("a1")); - test(s, s.end(), 'b', S("a1b")); - test(s, s.end()-1, 'c', S("a1cb")); - test(s, s.end()-2, 'd', S("a1dcb")); - test(s, s.end()-3, '2', S("a12dcb")); - test(s, s.end()-4, '3', S("a132dcb")); - test(s, s.end()-5, '4', S("a1432dcb")); - test(s, s.begin()+1, '5', S("a51432dcb")); - test(s, s.begin()+2, '6', S("a561432dcb")); - test(s, s.begin()+3, '7', S("a5671432dcb")); - test(s, s.begin()+4, 'A', S("a567A1432dcb")); - test(s, s.begin()+5, 'B', S("a567AB1432dcb")); - test(s, s.begin()+6, 'C', S("a567ABC1432dcb")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp @@ -56,99 +56,58 @@ } #endif +template +TEST_CONSTEXPR_CXX20 void test_string() { + const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + test(S(), 0, s, s, S()); + test(S(), 0, s, s+1, S("A")); + test(S(), 0, s, s+10, S("ABCDEFGHIJ")); + test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), 0, s, s, S("12345")); + test(S("12345"), 1, s, s+1, S("1A2345")); + test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5")); + test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), 0, s, s, S("1234567890")); + test(S("1234567890"), 1, s, s+1, S("1A234567890")); + test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); + + test(S("12345678901234567890"), 3, s, s, S("12345678901234567890")); + test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890")); + test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890")); + test(S("12345678901234567890"), 20, s, s+52, + S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S()); + test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); + test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("ABCDEFGHIJ")); + test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("12345"), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S("12345")); + test(S("12345"), 1, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("1A2345")); + test(S("12345"), 4, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("1234ABCDEFGHIJ5")); + test(S("12345"), 5, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); + + test(S("1234567890"), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S("1234567890")); + test(S("1234567890"), 1, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("1A234567890")); + test(S("1234567890"), 10, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("1234567890ABCDEFGHIJ")); + test(S("1234567890"), 8, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); + + test(S("12345678901234567890"), 3, cpp17_input_iterator(s), cpp17_input_iterator(s), S("12345678901234567890")); + test(S("12345678901234567890"), 3, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("123A45678901234567890")); + test(S("12345678901234567890"), 15, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("123456789012345ABCDEFGHIJ67890")); + test(S("12345678901234567890"), 20, cpp17_input_iterator(s), cpp17_input_iterator(s+52), + S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), 0, s, s, S()); - test(S(), 0, s, s+1, S("A")); - test(S(), 0, s, s+10, S("ABCDEFGHIJ")); - test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), 0, s, s, S("12345")); - test(S("12345"), 1, s, s+1, S("1A2345")); - test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5")); - test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), 0, s, s, S("1234567890")); - test(S("1234567890"), 1, s, s+1, S("1A234567890")); - test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); - - test(S("12345678901234567890"), 3, s, s, S("12345678901234567890")); - test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890")); - test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890")); - test(S("12345678901234567890"), 20, s, s+52, - S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S()); - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("ABCDEFGHIJ")); - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S("12345")); - test(S("12345"), 1, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("1A2345")); - test(S("12345"), 4, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("1234ABCDEFGHIJ5")); - test(S("12345"), 5, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S("1234567890")); - test(S("1234567890"), 1, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("1A234567890")); - test(S("1234567890"), 10, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), 8, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); - - test(S("12345678901234567890"), 3, cpp17_input_iterator(s), cpp17_input_iterator(s), S("12345678901234567890")); - test(S("12345678901234567890"), 3, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("123A45678901234567890")); - test(S("12345678901234567890"), 15, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("123456789012345ABCDEFGHIJ67890")); - test(S("12345678901234567890"), 20, cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), 0, s, s, S()); - test(S(), 0, s, s+1, S("A")); - test(S(), 0, s, s+10, S("ABCDEFGHIJ")); - test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), 0, s, s, S("12345")); - test(S("12345"), 1, s, s+1, S("1A2345")); - test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5")); - test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), 0, s, s, S("1234567890")); - test(S("1234567890"), 1, s, s+1, S("1A234567890")); - test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); - - test(S("12345678901234567890"), 3, s, s, S("12345678901234567890")); - test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890")); - test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890")); - test(S("12345678901234567890"), 20, s, s+52, - S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S()); - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("A")); - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("ABCDEFGHIJ")); - test(S(), 0, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S("12345")); - test(S("12345"), 1, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("1A2345")); - test(S("12345"), 4, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("1234ABCDEFGHIJ5")); - test(S("12345"), 5, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), 0, cpp17_input_iterator(s), cpp17_input_iterator(s), S("1234567890")); - test(S("1234567890"), 1, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("1A234567890")); - test(S("1234567890"), 10, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), 8, cpp17_input_iterator(s), cpp17_input_iterator(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90")); - - test(S("12345678901234567890"), 3, cpp17_input_iterator(s), cpp17_input_iterator(s), S("12345678901234567890")); - test(S("12345678901234567890"), 3, cpp17_input_iterator(s), cpp17_input_iterator(s+1), S("123A45678901234567890")); - test(S("12345678901234567890"), 15, cpp17_input_iterator(s), cpp17_input_iterator(s+10), S("123456789012345ABCDEFGHIJ67890")); - test(S("12345678901234567890"), 20, cpp17_input_iterator(s), cpp17_input_iterator(s+52), - S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } + test_string, min_allocator>>(); #endif + #ifndef TEST_HAS_NO_EXCEPTIONS if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw typedef std::string S; @@ -230,7 +189,6 @@ s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1))); assert(s == "ABCD"); } - return true; } diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp @@ -28,142 +28,78 @@ assert(s == expected); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(""), 0, 0, '1', S("")); + test(S(""), 0, 5, '1', S("11111")); + test(S(""), 0, 10, '1', S("1111111111")); + test(S(""), 0, 20, '1', S("11111111111111111111")); + test(S("abcde"), 0, 0, '1', S("abcde")); + test(S("abcde"), 0, 5, '1', S("11111abcde")); + test(S("abcde"), 0, 10, '1', S("1111111111abcde")); + test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde")); + test(S("abcde"), 1, 0, '1', S("abcde")); + test(S("abcde"), 1, 5, '1', S("a11111bcde")); + test(S("abcde"), 1, 10, '1', S("a1111111111bcde")); + test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde")); + test(S("abcde"), 2, 0, '1', S("abcde")); + test(S("abcde"), 2, 5, '1', S("ab11111cde")); + test(S("abcde"), 2, 10, '1', S("ab1111111111cde")); + test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde")); + test(S("abcde"), 4, 0, '1', S("abcde")); + test(S("abcde"), 4, 5, '1', S("abcd11111e")); + test(S("abcde"), 4, 10, '1', S("abcd1111111111e")); + test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e")); + test(S("abcde"), 5, 0, '1', S("abcde")); + test(S("abcde"), 5, 5, '1', S("abcde11111")); + test(S("abcde"), 5, 10, '1', S("abcde1111111111")); + test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111")); + test(S("abcdefghij"), 0, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij")); + test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij")); + test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij")); + test(S("abcdefghij"), 1, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij")); + test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij")); + test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij")); + test(S("abcdefghij"), 5, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij")); + test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij")); + test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij")); + test(S("abcdefghij"), 9, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j")); + test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j")); + test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j")); + test(S("abcdefghij"), 10, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111")); + test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111")); + test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111")); + test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t")); + test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t")); + test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t")); + test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111")); + test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111")); + test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(""), 0, 0, '1', S("")); - test(S(""), 0, 5, '1', S("11111")); - test(S(""), 0, 10, '1', S("1111111111")); - test(S(""), 0, 20, '1', S("11111111111111111111")); - test(S("abcde"), 0, 0, '1', S("abcde")); - test(S("abcde"), 0, 5, '1', S("11111abcde")); - test(S("abcde"), 0, 10, '1', S("1111111111abcde")); - test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde")); - test(S("abcde"), 1, 0, '1', S("abcde")); - test(S("abcde"), 1, 5, '1', S("a11111bcde")); - test(S("abcde"), 1, 10, '1', S("a1111111111bcde")); - test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde")); - test(S("abcde"), 2, 0, '1', S("abcde")); - test(S("abcde"), 2, 5, '1', S("ab11111cde")); - test(S("abcde"), 2, 10, '1', S("ab1111111111cde")); - test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde")); - test(S("abcde"), 4, 0, '1', S("abcde")); - test(S("abcde"), 4, 5, '1', S("abcd11111e")); - test(S("abcde"), 4, 10, '1', S("abcd1111111111e")); - test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e")); - test(S("abcde"), 5, 0, '1', S("abcde")); - test(S("abcde"), 5, 5, '1', S("abcde11111")); - test(S("abcde"), 5, 10, '1', S("abcde1111111111")); - test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111")); - test(S("abcdefghij"), 0, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij")); - test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij")); - test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij")); - test(S("abcdefghij"), 1, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij")); - test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij")); - test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij")); - test(S("abcdefghij"), 5, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij")); - test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij")); - test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij")); - test(S("abcdefghij"), 9, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j")); - test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j")); - test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j")); - test(S("abcdefghij"), 10, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111")); - test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111")); - test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111")); - test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t")); - test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t")); - test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t")); - test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111")); - test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111")); - test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(""), 0, 0, '1', S("")); - test(S(""), 0, 5, '1', S("11111")); - test(S(""), 0, 10, '1', S("1111111111")); - test(S(""), 0, 20, '1', S("11111111111111111111")); - test(S("abcde"), 0, 0, '1', S("abcde")); - test(S("abcde"), 0, 5, '1', S("11111abcde")); - test(S("abcde"), 0, 10, '1', S("1111111111abcde")); - test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde")); - test(S("abcde"), 1, 0, '1', S("abcde")); - test(S("abcde"), 1, 5, '1', S("a11111bcde")); - test(S("abcde"), 1, 10, '1', S("a1111111111bcde")); - test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde")); - test(S("abcde"), 2, 0, '1', S("abcde")); - test(S("abcde"), 2, 5, '1', S("ab11111cde")); - test(S("abcde"), 2, 10, '1', S("ab1111111111cde")); - test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde")); - test(S("abcde"), 4, 0, '1', S("abcde")); - test(S("abcde"), 4, 5, '1', S("abcd11111e")); - test(S("abcde"), 4, 10, '1', S("abcd1111111111e")); - test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e")); - test(S("abcde"), 5, 0, '1', S("abcde")); - test(S("abcde"), 5, 5, '1', S("abcde11111")); - test(S("abcde"), 5, 10, '1', S("abcde1111111111")); - test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111")); - test(S("abcdefghij"), 0, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij")); - test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij")); - test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij")); - test(S("abcdefghij"), 1, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij")); - test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij")); - test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij")); - test(S("abcdefghij"), 5, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij")); - test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij")); - test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij")); - test(S("abcdefghij"), 9, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j")); - test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j")); - test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j")); - test(S("abcdefghij"), 10, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111")); - test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111")); - test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111")); - test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t")); - test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t")); - test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t")); - test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111")); - test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111")); - test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp @@ -47,174 +47,94 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(""), 0, "", S("")); + test(S(""), 0, "12345", S("12345")); + test(S(""), 0, "1234567890", S("1234567890")); + test(S(""), 0, "12345678901234567890", S("12345678901234567890")); + test(S(""), 1, "", S("can't happen")); + test(S(""), 1, "12345", S("can't happen")); + test(S(""), 1, "1234567890", S("can't happen")); + test(S(""), 1, "12345678901234567890", S("can't happen")); + test(S("abcde"), 0, "", S("abcde")); + test(S("abcde"), 0, "12345", S("12345abcde")); + test(S("abcde"), 0, "1234567890", S("1234567890abcde")); + test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde")); + test(S("abcde"), 1, "", S("abcde")); + test(S("abcde"), 1, "12345", S("a12345bcde")); + test(S("abcde"), 1, "1234567890", S("a1234567890bcde")); + test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde")); + test(S("abcde"), 2, "", S("abcde")); + test(S("abcde"), 2, "12345", S("ab12345cde")); + test(S("abcde"), 2, "1234567890", S("ab1234567890cde")); + test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde")); + test(S("abcde"), 4, "", S("abcde")); + test(S("abcde"), 4, "12345", S("abcd12345e")); + test(S("abcde"), 4, "1234567890", S("abcd1234567890e")); + test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e")); + test(S("abcde"), 5, "", S("abcde")); + test(S("abcde"), 5, "12345", S("abcde12345")); + test(S("abcde"), 5, "1234567890", S("abcde1234567890")); + test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890")); + test(S("abcde"), 6, "", S("can't happen")); + test(S("abcde"), 6, "12345", S("can't happen")); + test(S("abcde"), 6, "1234567890", S("can't happen")); + test(S("abcde"), 6, "12345678901234567890", S("can't happen")); + test(S("abcdefghij"), 0, "", S("abcdefghij")); + test(S("abcdefghij"), 0, "12345", S("12345abcdefghij")); + test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 1, "", S("abcdefghij")); + test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij")); + test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 5, "", S("abcdefghij")); + test(S("abcdefghij"), 5, "12345", S("abcde12345fghij")); + test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 9, "", S("abcdefghij")); + test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j")); + test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 10, "", S("abcdefghij")); + test(S("abcdefghij"), 10, "12345", S("abcdefghij12345")); + test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, "", S("can't happen")); + test(S("abcdefghij"), 11, "12345", S("can't happen")); + test(S("abcdefghij"), 11, "1234567890", S("can't happen")); + test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(""), 0, "", S("")); - test(S(""), 0, "12345", S("12345")); - test(S(""), 0, "1234567890", S("1234567890")); - test(S(""), 0, "12345678901234567890", S("12345678901234567890")); - test(S(""), 1, "", S("can't happen")); - test(S(""), 1, "12345", S("can't happen")); - test(S(""), 1, "1234567890", S("can't happen")); - test(S(""), 1, "12345678901234567890", S("can't happen")); - test(S("abcde"), 0, "", S("abcde")); - test(S("abcde"), 0, "12345", S("12345abcde")); - test(S("abcde"), 0, "1234567890", S("1234567890abcde")); - test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde")); - test(S("abcde"), 1, "", S("abcde")); - test(S("abcde"), 1, "12345", S("a12345bcde")); - test(S("abcde"), 1, "1234567890", S("a1234567890bcde")); - test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde")); - test(S("abcde"), 2, "", S("abcde")); - test(S("abcde"), 2, "12345", S("ab12345cde")); - test(S("abcde"), 2, "1234567890", S("ab1234567890cde")); - test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde")); - test(S("abcde"), 4, "", S("abcde")); - test(S("abcde"), 4, "12345", S("abcd12345e")); - test(S("abcde"), 4, "1234567890", S("abcd1234567890e")); - test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e")); - test(S("abcde"), 5, "", S("abcde")); - test(S("abcde"), 5, "12345", S("abcde12345")); - test(S("abcde"), 5, "1234567890", S("abcde1234567890")); - test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890")); - test(S("abcde"), 6, "", S("can't happen")); - test(S("abcde"), 6, "12345", S("can't happen")); - test(S("abcde"), 6, "1234567890", S("can't happen")); - test(S("abcde"), 6, "12345678901234567890", S("can't happen")); - test(S("abcdefghij"), 0, "", S("abcdefghij")); - test(S("abcdefghij"), 0, "12345", S("12345abcdefghij")); - test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij")); - test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij")); - test(S("abcdefghij"), 1, "", S("abcdefghij")); - test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij")); - test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij")); - test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij")); - test(S("abcdefghij"), 5, "", S("abcdefghij")); - test(S("abcdefghij"), 5, "12345", S("abcde12345fghij")); - test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij")); - test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij")); - test(S("abcdefghij"), 9, "", S("abcdefghij")); - test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j")); - test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j")); - test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j")); - test(S("abcdefghij"), 10, "", S("abcdefghij")); - test(S("abcdefghij"), 10, "12345", S("abcdefghij12345")); - test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890")); - test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890")); - test(S("abcdefghij"), 11, "", S("can't happen")); - test(S("abcdefghij"), 11, "12345", S("can't happen")); - test(S("abcdefghij"), 11, "1234567890", S("can't happen")); - test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t")); - test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t")); - test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t")); - test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345")); - test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890")); - test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); - test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(""), 0, "", S("")); - test(S(""), 0, "12345", S("12345")); - test(S(""), 0, "1234567890", S("1234567890")); - test(S(""), 0, "12345678901234567890", S("12345678901234567890")); - test(S(""), 1, "", S("can't happen")); - test(S(""), 1, "12345", S("can't happen")); - test(S(""), 1, "1234567890", S("can't happen")); - test(S(""), 1, "12345678901234567890", S("can't happen")); - test(S("abcde"), 0, "", S("abcde")); - test(S("abcde"), 0, "12345", S("12345abcde")); - test(S("abcde"), 0, "1234567890", S("1234567890abcde")); - test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde")); - test(S("abcde"), 1, "", S("abcde")); - test(S("abcde"), 1, "12345", S("a12345bcde")); - test(S("abcde"), 1, "1234567890", S("a1234567890bcde")); - test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde")); - test(S("abcde"), 2, "", S("abcde")); - test(S("abcde"), 2, "12345", S("ab12345cde")); - test(S("abcde"), 2, "1234567890", S("ab1234567890cde")); - test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde")); - test(S("abcde"), 4, "", S("abcde")); - test(S("abcde"), 4, "12345", S("abcd12345e")); - test(S("abcde"), 4, "1234567890", S("abcd1234567890e")); - test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e")); - test(S("abcde"), 5, "", S("abcde")); - test(S("abcde"), 5, "12345", S("abcde12345")); - test(S("abcde"), 5, "1234567890", S("abcde1234567890")); - test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890")); - test(S("abcde"), 6, "", S("can't happen")); - test(S("abcde"), 6, "12345", S("can't happen")); - test(S("abcde"), 6, "1234567890", S("can't happen")); - test(S("abcde"), 6, "12345678901234567890", S("can't happen")); - test(S("abcdefghij"), 0, "", S("abcdefghij")); - test(S("abcdefghij"), 0, "12345", S("12345abcdefghij")); - test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij")); - test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij")); - test(S("abcdefghij"), 1, "", S("abcdefghij")); - test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij")); - test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij")); - test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij")); - test(S("abcdefghij"), 5, "", S("abcdefghij")); - test(S("abcdefghij"), 5, "12345", S("abcde12345fghij")); - test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij")); - test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij")); - test(S("abcdefghij"), 9, "", S("abcdefghij")); - test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j")); - test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j")); - test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j")); - test(S("abcdefghij"), 10, "", S("abcdefghij")); - test(S("abcdefghij"), 10, "12345", S("abcdefghij12345")); - test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890")); - test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890")); - test(S("abcdefghij"), 11, "", S("can't happen")); - test(S("abcdefghij"), 11, "12345", S("can't happen")); - test(S("abcdefghij"), 11, "1234567890", S("can't happen")); - test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t")); - test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t")); - test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t")); - test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345")); - test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890")); - test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890")); - test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen")); - } + test_string, min_allocator>>(); #endif { // test inserting into self diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp @@ -48,174 +48,94 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(""), 0, 0, '1', S("")); + test(S(""), 0, 5, '1', S("11111")); + test(S(""), 0, 10, '1', S("1111111111")); + test(S(""), 0, 20, '1', S("11111111111111111111")); + test(S(""), 1, 0, '1', S("can't happen")); + test(S(""), 1, 5, '1', S("can't happen")); + test(S(""), 1, 10, '1', S("can't happen")); + test(S(""), 1, 20, '1', S("can't happen")); + test(S("abcde"), 0, 0, '1', S("abcde")); + test(S("abcde"), 0, 5, '1', S("11111abcde")); + test(S("abcde"), 0, 10, '1', S("1111111111abcde")); + test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde")); + test(S("abcde"), 1, 0, '1', S("abcde")); + test(S("abcde"), 1, 5, '1', S("a11111bcde")); + test(S("abcde"), 1, 10, '1', S("a1111111111bcde")); + test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde")); + test(S("abcde"), 2, 0, '1', S("abcde")); + test(S("abcde"), 2, 5, '1', S("ab11111cde")); + test(S("abcde"), 2, 10, '1', S("ab1111111111cde")); + test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde")); + test(S("abcde"), 4, 0, '1', S("abcde")); + test(S("abcde"), 4, 5, '1', S("abcd11111e")); + test(S("abcde"), 4, 10, '1', S("abcd1111111111e")); + test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e")); + test(S("abcde"), 5, 0, '1', S("abcde")); + test(S("abcde"), 5, 5, '1', S("abcde11111")); + test(S("abcde"), 5, 10, '1', S("abcde1111111111")); + test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111")); + test(S("abcde"), 6, 0, '1', S("can't happen")); + test(S("abcde"), 6, 5, '1', S("can't happen")); + test(S("abcde"), 6, 10, '1', S("can't happen")); + test(S("abcde"), 6, 20, '1', S("can't happen")); + test(S("abcdefghij"), 0, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij")); + test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij")); + test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij")); + test(S("abcdefghij"), 1, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij")); + test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij")); + test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij")); + test(S("abcdefghij"), 5, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij")); + test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij")); + test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij")); + test(S("abcdefghij"), 9, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j")); + test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j")); + test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j")); + test(S("abcdefghij"), 10, 0, '1', S("abcdefghij")); + test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111")); + test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111")); + test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111")); + test(S("abcdefghij"), 11, 0, '1', S("can't happen")); + test(S("abcdefghij"), 11, 5, '1', S("can't happen")); + test(S("abcdefghij"), 11, 10, '1', S("can't happen")); + test(S("abcdefghij"), 11, 20, '1', S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t")); + test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t")); + test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t")); + test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111")); + test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111")); + test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); + test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(""), 0, 0, '1', S("")); - test(S(""), 0, 5, '1', S("11111")); - test(S(""), 0, 10, '1', S("1111111111")); - test(S(""), 0, 20, '1', S("11111111111111111111")); - test(S(""), 1, 0, '1', S("can't happen")); - test(S(""), 1, 5, '1', S("can't happen")); - test(S(""), 1, 10, '1', S("can't happen")); - test(S(""), 1, 20, '1', S("can't happen")); - test(S("abcde"), 0, 0, '1', S("abcde")); - test(S("abcde"), 0, 5, '1', S("11111abcde")); - test(S("abcde"), 0, 10, '1', S("1111111111abcde")); - test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde")); - test(S("abcde"), 1, 0, '1', S("abcde")); - test(S("abcde"), 1, 5, '1', S("a11111bcde")); - test(S("abcde"), 1, 10, '1', S("a1111111111bcde")); - test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde")); - test(S("abcde"), 2, 0, '1', S("abcde")); - test(S("abcde"), 2, 5, '1', S("ab11111cde")); - test(S("abcde"), 2, 10, '1', S("ab1111111111cde")); - test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde")); - test(S("abcde"), 4, 0, '1', S("abcde")); - test(S("abcde"), 4, 5, '1', S("abcd11111e")); - test(S("abcde"), 4, 10, '1', S("abcd1111111111e")); - test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e")); - test(S("abcde"), 5, 0, '1', S("abcde")); - test(S("abcde"), 5, 5, '1', S("abcde11111")); - test(S("abcde"), 5, 10, '1', S("abcde1111111111")); - test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111")); - test(S("abcde"), 6, 0, '1', S("can't happen")); - test(S("abcde"), 6, 5, '1', S("can't happen")); - test(S("abcde"), 6, 10, '1', S("can't happen")); - test(S("abcde"), 6, 20, '1', S("can't happen")); - test(S("abcdefghij"), 0, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij")); - test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij")); - test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij")); - test(S("abcdefghij"), 1, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij")); - test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij")); - test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij")); - test(S("abcdefghij"), 5, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij")); - test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij")); - test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij")); - test(S("abcdefghij"), 9, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j")); - test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j")); - test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j")); - test(S("abcdefghij"), 10, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111")); - test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111")); - test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111")); - test(S("abcdefghij"), 11, 0, '1', S("can't happen")); - test(S("abcdefghij"), 11, 5, '1', S("can't happen")); - test(S("abcdefghij"), 11, 10, '1', S("can't happen")); - test(S("abcdefghij"), 11, 20, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t")); - test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t")); - test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t")); - test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111")); - test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111")); - test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); - test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(""), 0, 0, '1', S("")); - test(S(""), 0, 5, '1', S("11111")); - test(S(""), 0, 10, '1', S("1111111111")); - test(S(""), 0, 20, '1', S("11111111111111111111")); - test(S(""), 1, 0, '1', S("can't happen")); - test(S(""), 1, 5, '1', S("can't happen")); - test(S(""), 1, 10, '1', S("can't happen")); - test(S(""), 1, 20, '1', S("can't happen")); - test(S("abcde"), 0, 0, '1', S("abcde")); - test(S("abcde"), 0, 5, '1', S("11111abcde")); - test(S("abcde"), 0, 10, '1', S("1111111111abcde")); - test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde")); - test(S("abcde"), 1, 0, '1', S("abcde")); - test(S("abcde"), 1, 5, '1', S("a11111bcde")); - test(S("abcde"), 1, 10, '1', S("a1111111111bcde")); - test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde")); - test(S("abcde"), 2, 0, '1', S("abcde")); - test(S("abcde"), 2, 5, '1', S("ab11111cde")); - test(S("abcde"), 2, 10, '1', S("ab1111111111cde")); - test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde")); - test(S("abcde"), 4, 0, '1', S("abcde")); - test(S("abcde"), 4, 5, '1', S("abcd11111e")); - test(S("abcde"), 4, 10, '1', S("abcd1111111111e")); - test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e")); - test(S("abcde"), 5, 0, '1', S("abcde")); - test(S("abcde"), 5, 5, '1', S("abcde11111")); - test(S("abcde"), 5, 10, '1', S("abcde1111111111")); - test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111")); - test(S("abcde"), 6, 0, '1', S("can't happen")); - test(S("abcde"), 6, 5, '1', S("can't happen")); - test(S("abcde"), 6, 10, '1', S("can't happen")); - test(S("abcde"), 6, 20, '1', S("can't happen")); - test(S("abcdefghij"), 0, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij")); - test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij")); - test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij")); - test(S("abcdefghij"), 1, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij")); - test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij")); - test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij")); - test(S("abcdefghij"), 5, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij")); - test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij")); - test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij")); - test(S("abcdefghij"), 9, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j")); - test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j")); - test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j")); - test(S("abcdefghij"), 10, 0, '1', S("abcdefghij")); - test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111")); - test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111")); - test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111")); - test(S("abcdefghij"), 11, 0, '1', S("can't happen")); - test(S("abcdefghij"), 11, 5, '1', S("can't happen")); - test(S("abcdefghij"), 11, 10, '1', S("can't happen")); - test(S("abcdefghij"), 11, 20, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t")); - test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t")); - test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t")); - test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111")); - test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111")); - test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); - test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen")); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp @@ -47,177 +47,97 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(""), 0, S(""), S("")); + test(S(""), 0, S("12345"), S("12345")); + test(S(""), 0, S("1234567890"), S("1234567890")); + test(S(""), 0, S("12345678901234567890"), S("12345678901234567890")); + test(S(""), 1, S(""), S("can't happen")); + test(S(""), 1, S("12345"), S("can't happen")); + test(S(""), 1, S("1234567890"), S("can't happen")); + test(S(""), 1, S("12345678901234567890"), S("can't happen")); + test(S("abcde"), 0, S(""), S("abcde")); + test(S("abcde"), 0, S("12345"), S("12345abcde")); + test(S("abcde"), 0, S("1234567890"), S("1234567890abcde")); + test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde")); + test(S("abcde"), 1, S(""), S("abcde")); + test(S("abcde"), 1, S("12345"), S("a12345bcde")); + test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde")); + test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde")); + test(S("abcde"), 2, S(""), S("abcde")); + test(S("abcde"), 2, S("12345"), S("ab12345cde")); + test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde")); + test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde")); + test(S("abcde"), 4, S(""), S("abcde")); + test(S("abcde"), 4, S("12345"), S("abcd12345e")); + test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e")); + test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e")); + test(S("abcde"), 5, S(""), S("abcde")); + test(S("abcde"), 5, S("12345"), S("abcde12345")); + test(S("abcde"), 5, S("1234567890"), S("abcde1234567890")); + test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcde"), 6, S(""), S("can't happen")); + test(S("abcde"), 6, S("12345"), S("can't happen")); + test(S("abcde"), 6, S("1234567890"), S("can't happen")); + test(S("abcde"), 6, S("12345678901234567890"), S("can't happen")); + test(S("abcdefghij"), 0, S(""), S("abcdefghij")); + test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij")); + test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 1, S(""), S("abcdefghij")); + test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij")); + test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 5, S(""), S("abcdefghij")); + test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij")); + test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 9, S(""), S("abcdefghij")); + test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j")); + test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 10, S(""), S("abcdefghij")); + test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345")); + test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, S(""), S("can't happen")); + test(S("abcdefghij"), 11, S("12345"), S("can't happen")); + test(S("abcdefghij"), 11, S("1234567890"), S("can't happen")); + test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(""), 0, S(""), S("")); - test(S(""), 0, S("12345"), S("12345")); - test(S(""), 0, S("1234567890"), S("1234567890")); - test(S(""), 0, S("12345678901234567890"), S("12345678901234567890")); - test(S(""), 1, S(""), S("can't happen")); - test(S(""), 1, S("12345"), S("can't happen")); - test(S(""), 1, S("1234567890"), S("can't happen")); - test(S(""), 1, S("12345678901234567890"), S("can't happen")); - test(S("abcde"), 0, S(""), S("abcde")); - test(S("abcde"), 0, S("12345"), S("12345abcde")); - test(S("abcde"), 0, S("1234567890"), S("1234567890abcde")); - test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde")); - test(S("abcde"), 1, S(""), S("abcde")); - test(S("abcde"), 1, S("12345"), S("a12345bcde")); - test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde")); - test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde")); - test(S("abcde"), 2, S(""), S("abcde")); - test(S("abcde"), 2, S("12345"), S("ab12345cde")); - test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde")); - test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde")); - test(S("abcde"), 4, S(""), S("abcde")); - test(S("abcde"), 4, S("12345"), S("abcd12345e")); - test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e")); - test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e")); - test(S("abcde"), 5, S(""), S("abcde")); - test(S("abcde"), 5, S("12345"), S("abcde12345")); - test(S("abcde"), 5, S("1234567890"), S("abcde1234567890")); - test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890")); - test(S("abcde"), 6, S(""), S("can't happen")); - test(S("abcde"), 6, S("12345"), S("can't happen")); - test(S("abcde"), 6, S("1234567890"), S("can't happen")); - test(S("abcde"), 6, S("12345678901234567890"), S("can't happen")); - test(S("abcdefghij"), 0, S(""), S("abcdefghij")); - test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij")); - test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij")); - test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); - test(S("abcdefghij"), 1, S(""), S("abcdefghij")); - test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij")); - test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij")); - test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); - test(S("abcdefghij"), 5, S(""), S("abcdefghij")); - test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij")); - test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij")); - test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij")); - test(S("abcdefghij"), 9, S(""), S("abcdefghij")); - test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j")); - test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j")); - test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); - test(S("abcdefghij"), 10, S(""), S("abcdefghij")); - test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345")); - test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890")); - test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); - test(S("abcdefghij"), 11, S(""), S("can't happen")); - test(S("abcdefghij"), 11, S("12345"), S("can't happen")); - test(S("abcdefghij"), 11, S("1234567890"), S("can't happen")); - test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t")); - test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); - test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); - test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345")); - test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); - test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); - test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(""), 0, S(""), S("")); - test(S(""), 0, S("12345"), S("12345")); - test(S(""), 0, S("1234567890"), S("1234567890")); - test(S(""), 0, S("12345678901234567890"), S("12345678901234567890")); - test(S(""), 1, S(""), S("can't happen")); - test(S(""), 1, S("12345"), S("can't happen")); - test(S(""), 1, S("1234567890"), S("can't happen")); - test(S(""), 1, S("12345678901234567890"), S("can't happen")); - test(S("abcde"), 0, S(""), S("abcde")); - test(S("abcde"), 0, S("12345"), S("12345abcde")); - test(S("abcde"), 0, S("1234567890"), S("1234567890abcde")); - test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde")); - test(S("abcde"), 1, S(""), S("abcde")); - test(S("abcde"), 1, S("12345"), S("a12345bcde")); - test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde")); - test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde")); - test(S("abcde"), 2, S(""), S("abcde")); - test(S("abcde"), 2, S("12345"), S("ab12345cde")); - test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde")); - test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde")); - test(S("abcde"), 4, S(""), S("abcde")); - test(S("abcde"), 4, S("12345"), S("abcd12345e")); - test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e")); - test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e")); - test(S("abcde"), 5, S(""), S("abcde")); - test(S("abcde"), 5, S("12345"), S("abcde12345")); - test(S("abcde"), 5, S("1234567890"), S("abcde1234567890")); - test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890")); - test(S("abcde"), 6, S(""), S("can't happen")); - test(S("abcde"), 6, S("12345"), S("can't happen")); - test(S("abcde"), 6, S("1234567890"), S("can't happen")); - test(S("abcde"), 6, S("12345678901234567890"), S("can't happen")); - test(S("abcdefghij"), 0, S(""), S("abcdefghij")); - test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij")); - test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij")); - test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij")); - test(S("abcdefghij"), 1, S(""), S("abcdefghij")); - test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij")); - test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij")); - test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij")); - test(S("abcdefghij"), 5, S(""), S("abcdefghij")); - test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij")); - test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij")); - test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij")); - test(S("abcdefghij"), 9, S(""), S("abcdefghij")); - test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j")); - test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j")); - test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j")); - test(S("abcdefghij"), 10, S(""), S("abcdefghij")); - test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345")); - test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890")); - test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890")); - test(S("abcdefghij"), 11, S(""), S("can't happen")); - test(S("abcdefghij"), 11, S("12345"), S("can't happen")); - test(S("abcdefghij"), 11, S("1234567890"), S("can't happen")); - test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t")); - test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t")); - test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); - test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345")); - test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890")); - test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); - test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen")); - } + test_string, min_allocator>>(); #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s; s.insert(0, {"abc", 1}); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/string_view.pass.cpp @@ -47,176 +47,95 @@ #endif } +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(S(""), 0, SV(""), S("")); + test(S(""), 0, SV("12345"), S("12345")); + test(S(""), 0, SV("1234567890"), S("1234567890")); + test(S(""), 0, SV("12345678901234567890"), S("12345678901234567890")); + test(S(""), 1, SV(""), S("can't happen")); + test(S(""), 1, SV("12345"), S("can't happen")); + test(S(""), 1, SV("1234567890"), S("can't happen")); + test(S(""), 1, SV("12345678901234567890"), S("can't happen")); + test(S("abcde"), 0, SV(""), S("abcde")); + test(S("abcde"), 0, SV("12345"), S("12345abcde")); + test(S("abcde"), 0, SV("1234567890"), S("1234567890abcde")); + test(S("abcde"), 0, SV("12345678901234567890"), S("12345678901234567890abcde")); + test(S("abcde"), 1, SV(""), S("abcde")); + test(S("abcde"), 1, SV("12345"), S("a12345bcde")); + test(S("abcde"), 1, SV("1234567890"), S("a1234567890bcde")); + test(S("abcde"), 1, SV("12345678901234567890"), S("a12345678901234567890bcde")); + test(S("abcde"), 2, SV(""), S("abcde")); + test(S("abcde"), 2, SV("12345"), S("ab12345cde")); + test(S("abcde"), 2, SV("1234567890"), S("ab1234567890cde")); + test(S("abcde"), 2, SV("12345678901234567890"), S("ab12345678901234567890cde")); + test(S("abcde"), 4, SV(""), S("abcde")); + test(S("abcde"), 4, SV("12345"), S("abcd12345e")); + test(S("abcde"), 4, SV("1234567890"), S("abcd1234567890e")); + test(S("abcde"), 4, SV("12345678901234567890"), S("abcd12345678901234567890e")); + test(S("abcde"), 5, SV(""), S("abcde")); + test(S("abcde"), 5, SV("12345"), S("abcde12345")); + test(S("abcde"), 5, SV("1234567890"), S("abcde1234567890")); + test(S("abcde"), 5, SV("12345678901234567890"), S("abcde12345678901234567890")); + test(S("abcde"), 6, SV(""), S("can't happen")); + test(S("abcde"), 6, SV("12345"), S("can't happen")); + test(S("abcde"), 6, SV("1234567890"), S("can't happen")); + test(S("abcde"), 6, SV("12345678901234567890"), S("can't happen")); + test(S("abcdefghij"), 0, SV(""), S("abcdefghij")); + test(S("abcdefghij"), 0, SV("12345"), S("12345abcdefghij")); + test(S("abcdefghij"), 0, SV("1234567890"), S("1234567890abcdefghij")); + test(S("abcdefghij"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghij")); + test(S("abcdefghij"), 1, SV(""), S("abcdefghij")); + test(S("abcdefghij"), 1, SV("12345"), S("a12345bcdefghij")); + test(S("abcdefghij"), 1, SV("1234567890"), S("a1234567890bcdefghij")); + test(S("abcdefghij"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghij")); + test(S("abcdefghij"), 5, SV(""), S("abcdefghij")); + test(S("abcdefghij"), 5, SV("12345"), S("abcde12345fghij")); + test(S("abcdefghij"), 5, SV("1234567890"), S("abcde1234567890fghij")); + test(S("abcdefghij"), 5, SV("12345678901234567890"), S("abcde12345678901234567890fghij")); + test(S("abcdefghij"), 9, SV(""), S("abcdefghij")); + test(S("abcdefghij"), 9, SV("12345"), S("abcdefghi12345j")); + test(S("abcdefghij"), 9, SV("1234567890"), S("abcdefghi1234567890j")); + test(S("abcdefghij"), 9, SV("12345678901234567890"), S("abcdefghi12345678901234567890j")); + test(S("abcdefghij"), 10, SV(""), S("abcdefghij")); + test(S("abcdefghij"), 10, SV("12345"), S("abcdefghij12345")); + test(S("abcdefghij"), 10, SV("1234567890"), S("abcdefghij1234567890")); + test(S("abcdefghij"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890")); + test(S("abcdefghij"), 11, SV(""), S("can't happen")); + test(S("abcdefghij"), 11, SV("12345"), S("can't happen")); + test(S("abcdefghij"), 11, SV("1234567890"), S("can't happen")); + test(S("abcdefghij"), 11, SV("12345678901234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 0, SV(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, SV("12345"), S("12345abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, SV("1234567890"), S("1234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, SV(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, SV("12345"), S("a12345bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, SV("1234567890"), S("a1234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, SV(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, SV("12345"), S("abcdefghij12345klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, SV("1234567890"), S("abcdefghij1234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, SV(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 19, SV("12345"), S("abcdefghijklmnopqrs12345t")); + test(S("abcdefghijklmnopqrst"), 19, SV("1234567890"), S("abcdefghijklmnopqrs1234567890t")); + test(S("abcdefghijklmnopqrst"), 19, SV("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); + test(S("abcdefghijklmnopqrst"), 20, SV(""), S("abcdefghijklmnopqrst")); + test(S("abcdefghijklmnopqrst"), 20, SV("12345"), S("abcdefghijklmnopqrst12345")); + test(S("abcdefghijklmnopqrst"), 20, SV("1234567890"), S("abcdefghijklmnopqrst1234567890")); + test(S("abcdefghijklmnopqrst"), 20, SV("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); + test(S("abcdefghijklmnopqrst"), 21, SV(""), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, SV("12345"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, SV("1234567890"), S("can't happen")); + test(S("abcdefghijklmnopqrst"), 21, SV("12345678901234567890"), S("can't happen")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string_view SV; - test(S(""), 0, SV(""), S("")); - test(S(""), 0, SV("12345"), S("12345")); - test(S(""), 0, SV("1234567890"), S("1234567890")); - test(S(""), 0, SV("12345678901234567890"), S("12345678901234567890")); - test(S(""), 1, SV(""), S("can't happen")); - test(S(""), 1, SV("12345"), S("can't happen")); - test(S(""), 1, SV("1234567890"), S("can't happen")); - test(S(""), 1, SV("12345678901234567890"), S("can't happen")); - test(S("abcde"), 0, SV(""), S("abcde")); - test(S("abcde"), 0, SV("12345"), S("12345abcde")); - test(S("abcde"), 0, SV("1234567890"), S("1234567890abcde")); - test(S("abcde"), 0, SV("12345678901234567890"), S("12345678901234567890abcde")); - test(S("abcde"), 1, SV(""), S("abcde")); - test(S("abcde"), 1, SV("12345"), S("a12345bcde")); - test(S("abcde"), 1, SV("1234567890"), S("a1234567890bcde")); - test(S("abcde"), 1, SV("12345678901234567890"), S("a12345678901234567890bcde")); - test(S("abcde"), 2, SV(""), S("abcde")); - test(S("abcde"), 2, SV("12345"), S("ab12345cde")); - test(S("abcde"), 2, SV("1234567890"), S("ab1234567890cde")); - test(S("abcde"), 2, SV("12345678901234567890"), S("ab12345678901234567890cde")); - test(S("abcde"), 4, SV(""), S("abcde")); - test(S("abcde"), 4, SV("12345"), S("abcd12345e")); - test(S("abcde"), 4, SV("1234567890"), S("abcd1234567890e")); - test(S("abcde"), 4, SV("12345678901234567890"), S("abcd12345678901234567890e")); - test(S("abcde"), 5, SV(""), S("abcde")); - test(S("abcde"), 5, SV("12345"), S("abcde12345")); - test(S("abcde"), 5, SV("1234567890"), S("abcde1234567890")); - test(S("abcde"), 5, SV("12345678901234567890"), S("abcde12345678901234567890")); - test(S("abcde"), 6, SV(""), S("can't happen")); - test(S("abcde"), 6, SV("12345"), S("can't happen")); - test(S("abcde"), 6, SV("1234567890"), S("can't happen")); - test(S("abcde"), 6, SV("12345678901234567890"), S("can't happen")); - test(S("abcdefghij"), 0, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 0, SV("12345"), S("12345abcdefghij")); - test(S("abcdefghij"), 0, SV("1234567890"), S("1234567890abcdefghij")); - test(S("abcdefghij"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghij")); - test(S("abcdefghij"), 1, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 1, SV("12345"), S("a12345bcdefghij")); - test(S("abcdefghij"), 1, SV("1234567890"), S("a1234567890bcdefghij")); - test(S("abcdefghij"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghij")); - test(S("abcdefghij"), 5, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 5, SV("12345"), S("abcde12345fghij")); - test(S("abcdefghij"), 5, SV("1234567890"), S("abcde1234567890fghij")); - test(S("abcdefghij"), 5, SV("12345678901234567890"), S("abcde12345678901234567890fghij")); - test(S("abcdefghij"), 9, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 9, SV("12345"), S("abcdefghi12345j")); - test(S("abcdefghij"), 9, SV("1234567890"), S("abcdefghi1234567890j")); - test(S("abcdefghij"), 9, SV("12345678901234567890"), S("abcdefghi12345678901234567890j")); - test(S("abcdefghij"), 10, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 10, SV("12345"), S("abcdefghij12345")); - test(S("abcdefghij"), 10, SV("1234567890"), S("abcdefghij1234567890")); - test(S("abcdefghij"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890")); - test(S("abcdefghij"), 11, SV(""), S("can't happen")); - test(S("abcdefghij"), 11, SV("12345"), S("can't happen")); - test(S("abcdefghij"), 11, SV("1234567890"), S("can't happen")); - test(S("abcdefghij"), 11, SV("12345678901234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, SV("12345"), S("12345abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, SV("1234567890"), S("1234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV("12345"), S("a12345bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV("1234567890"), S("a1234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV("12345"), S("abcdefghij12345klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV("1234567890"), S("abcdefghij1234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, SV("12345"), S("abcdefghijklmnopqrs12345t")); - test(S("abcdefghijklmnopqrst"), 19, SV("1234567890"), S("abcdefghijklmnopqrs1234567890t")); - test(S("abcdefghijklmnopqrst"), 19, SV("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); - test(S("abcdefghijklmnopqrst"), 20, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, SV("12345"), S("abcdefghijklmnopqrst12345")); - test(S("abcdefghijklmnopqrst"), 20, SV("1234567890"), S("abcdefghijklmnopqrst1234567890")); - test(S("abcdefghijklmnopqrst"), 20, SV("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); - test(S("abcdefghijklmnopqrst"), 21, SV(""), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, SV("12345"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, SV("1234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, SV("12345678901234567890"), S("can't happen")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - typedef std::string_view SV; - test(S(""), 0, SV(""), S("")); - test(S(""), 0, SV("12345"), S("12345")); - test(S(""), 0, SV("1234567890"), S("1234567890")); - test(S(""), 0, SV("12345678901234567890"), S("12345678901234567890")); - test(S(""), 1, SV(""), S("can't happen")); - test(S(""), 1, SV("12345"), S("can't happen")); - test(S(""), 1, SV("1234567890"), S("can't happen")); - test(S(""), 1, SV("12345678901234567890"), S("can't happen")); - test(S("abcde"), 0, SV(""), S("abcde")); - test(S("abcde"), 0, SV("12345"), S("12345abcde")); - test(S("abcde"), 0, SV("1234567890"), S("1234567890abcde")); - test(S("abcde"), 0, SV("12345678901234567890"), S("12345678901234567890abcde")); - test(S("abcde"), 1, SV(""), S("abcde")); - test(S("abcde"), 1, SV("12345"), S("a12345bcde")); - test(S("abcde"), 1, SV("1234567890"), S("a1234567890bcde")); - test(S("abcde"), 1, SV("12345678901234567890"), S("a12345678901234567890bcde")); - test(S("abcde"), 2, SV(""), S("abcde")); - test(S("abcde"), 2, SV("12345"), S("ab12345cde")); - test(S("abcde"), 2, SV("1234567890"), S("ab1234567890cde")); - test(S("abcde"), 2, SV("12345678901234567890"), S("ab12345678901234567890cde")); - test(S("abcde"), 4, SV(""), S("abcde")); - test(S("abcde"), 4, SV("12345"), S("abcd12345e")); - test(S("abcde"), 4, SV("1234567890"), S("abcd1234567890e")); - test(S("abcde"), 4, SV("12345678901234567890"), S("abcd12345678901234567890e")); - test(S("abcde"), 5, SV(""), S("abcde")); - test(S("abcde"), 5, SV("12345"), S("abcde12345")); - test(S("abcde"), 5, SV("1234567890"), S("abcde1234567890")); - test(S("abcde"), 5, SV("12345678901234567890"), S("abcde12345678901234567890")); - test(S("abcde"), 6, SV(""), S("can't happen")); - test(S("abcde"), 6, SV("12345"), S("can't happen")); - test(S("abcde"), 6, SV("1234567890"), S("can't happen")); - test(S("abcde"), 6, SV("12345678901234567890"), S("can't happen")); - test(S("abcdefghij"), 0, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 0, SV("12345"), S("12345abcdefghij")); - test(S("abcdefghij"), 0, SV("1234567890"), S("1234567890abcdefghij")); - test(S("abcdefghij"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghij")); - test(S("abcdefghij"), 1, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 1, SV("12345"), S("a12345bcdefghij")); - test(S("abcdefghij"), 1, SV("1234567890"), S("a1234567890bcdefghij")); - test(S("abcdefghij"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghij")); - test(S("abcdefghij"), 5, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 5, SV("12345"), S("abcde12345fghij")); - test(S("abcdefghij"), 5, SV("1234567890"), S("abcde1234567890fghij")); - test(S("abcdefghij"), 5, SV("12345678901234567890"), S("abcde12345678901234567890fghij")); - test(S("abcdefghij"), 9, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 9, SV("12345"), S("abcdefghi12345j")); - test(S("abcdefghij"), 9, SV("1234567890"), S("abcdefghi1234567890j")); - test(S("abcdefghij"), 9, SV("12345678901234567890"), S("abcdefghi12345678901234567890j")); - test(S("abcdefghij"), 10, SV(""), S("abcdefghij")); - test(S("abcdefghij"), 10, SV("12345"), S("abcdefghij12345")); - test(S("abcdefghij"), 10, SV("1234567890"), S("abcdefghij1234567890")); - test(S("abcdefghij"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890")); - test(S("abcdefghij"), 11, SV(""), S("can't happen")); - test(S("abcdefghij"), 11, SV("12345"), S("can't happen")); - test(S("abcdefghij"), 11, SV("1234567890"), S("can't happen")); - test(S("abcdefghij"), 11, SV("12345678901234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 0, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, SV("12345"), S("12345abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, SV("1234567890"), S("1234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV("12345"), S("a12345bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV("1234567890"), S("a1234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV("12345"), S("abcdefghij12345klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV("1234567890"), S("abcdefghij1234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 19, SV("12345"), S("abcdefghijklmnopqrs12345t")); - test(S("abcdefghijklmnopqrst"), 19, SV("1234567890"), S("abcdefghijklmnopqrs1234567890t")); - test(S("abcdefghijklmnopqrst"), 19, SV("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t")); - test(S("abcdefghijklmnopqrst"), 20, SV(""), S("abcdefghijklmnopqrst")); - test(S("abcdefghijklmnopqrst"), 20, SV("12345"), S("abcdefghijklmnopqrst12345")); - test(S("abcdefghijklmnopqrst"), 20, SV("1234567890"), S("abcdefghijklmnopqrst1234567890")); - test(S("abcdefghijklmnopqrst"), 20, SV("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890")); - test(S("abcdefghijklmnopqrst"), 21, SV(""), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, SV("12345"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, SV("1234567890"), S("can't happen")); - test(S("abcdefghijklmnopqrst"), 21, SV("12345678901234567890"), S("can't happen")); - } + test_string, min_allocator>>(); #endif { // test inserting into self diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp @@ -25,54 +25,34 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "1234567890", S("1234567890")); - test(S(), "12345678901234567890", S("12345678901234567890")); - - test(S("12345"), "", S("12345")); - test(S("12345"), "12345", S("1234512345")); - test(S("12345"), "1234567890", S("123451234567890")); - test(S("12345"), "12345678901234567890", S("1234512345678901234567890")); - - test(S("1234567890"), "", S("1234567890")); - test(S("1234567890"), "12345", S("123456789012345")); - test(S("1234567890"), "1234567890", S("12345678901234567890")); - test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), "", S()); + test(S(), "12345", S("12345")); + test(S(), "1234567890", S("1234567890")); + test(S(), "12345678901234567890", S("12345678901234567890")); - test(S("12345678901234567890"), "", S("12345678901234567890")); - test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); - test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890")); - test(S("12345678901234567890"), "12345678901234567890", - S("1234567890123456789012345678901234567890")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "1234567890", S("1234567890")); - test(S(), "12345678901234567890", S("12345678901234567890")); + test(S("12345"), "", S("12345")); + test(S("12345"), "12345", S("1234512345")); + test(S("12345"), "1234567890", S("123451234567890")); + test(S("12345"), "12345678901234567890", S("1234512345678901234567890")); - test(S("12345"), "", S("12345")); - test(S("12345"), "12345", S("1234512345")); - test(S("12345"), "1234567890", S("123451234567890")); - test(S("12345"), "12345678901234567890", S("1234512345678901234567890")); + test(S("1234567890"), "", S("1234567890")); + test(S("1234567890"), "12345", S("123456789012345")); + test(S("1234567890"), "1234567890", S("12345678901234567890")); + test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890")); - test(S("1234567890"), "", S("1234567890")); - test(S("1234567890"), "12345", S("123456789012345")); - test(S("1234567890"), "1234567890", S("12345678901234567890")); - test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890")); + test(S("12345678901234567890"), "", S("12345678901234567890")); + test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); + test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890")); + test(S("12345678901234567890"), "12345678901234567890", + S("1234567890123456789012345678901234567890")); +} - test(S("12345678901234567890"), "", S("12345678901234567890")); - test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); - test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890")); - test(S("12345678901234567890"), "12345678901234567890", - S("1234567890123456789012345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); +#if TEST_STD_VER >= 11 + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp @@ -26,57 +26,37 @@ assert(s == expected); } -TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S("12345")); - test(S("12345"), S("12345"), S("1234512345")); - test(S("12345"), S("1234567890"), S("123451234567890")); - test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), S(), S("1234567890")); - test(S("1234567890"), S("12345"), S("123456789012345")); - test(S("1234567890"), S("1234567890"), S("12345678901234567890")); - test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); +template +TEST_CONSTEXPR_CXX20 void test_string() { + test(S(), S(), S()); + test(S(), S("12345"), S("12345")); + test(S(), S("1234567890"), S("1234567890")); + test(S(), S("12345678901234567890"), S("12345678901234567890")); + + test(S("12345"), S(), S("12345")); + test(S("12345"), S("12345"), S("1234512345")); + test(S("12345"), S("1234567890"), S("123451234567890")); + test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); + + test(S("1234567890"), S(), S("1234567890")); + test(S("1234567890"), S("12345"), S("123456789012345")); + test(S("1234567890"), S("1234567890"), S("12345678901234567890")); + test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); + + test(S("12345678901234567890"), S(), S("12345678901234567890")); + test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); + test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); + test(S("12345678901234567890"), S("12345678901234567890"), + S("1234567890123456789012345678901234567890")); +} - test(S("12345678901234567890"), S(), S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } +TEST_CONSTEXPR_CXX20 bool test() { + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S("12345")); - test(S("12345"), S("12345"), S("1234512345")); - test(S("12345"), S("1234567890"), S("123451234567890")); - test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), S(), S("1234567890")); - test(S("1234567890"), S("12345"), S("123456789012345")); - test(S("1234567890"), S("1234567890"), S("12345678901234567890")); - test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); - - test(S("12345678901234567890"), S(), S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } + test_string, min_allocator>>(); #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s; s += {"abc", 1}; diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp @@ -283,7 +283,7 @@ #endif } -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " "; s.replace(s.cbegin(), s.cend(), {"abc", 1}); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp @@ -381,7 +381,7 @@ #endif } -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " "; s.replace(0, 1, {"abc", 1}); diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp @@ -31,46 +31,30 @@ assert(s2 == s1_); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + 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")); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - 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")); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> 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")); - } + test_string, min_allocator>>(); #endif return true; 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 --- 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 @@ -24,46 +24,30 @@ assert((lhs != rhs) == x); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + 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); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - 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); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> 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); - } + test_string, min_allocator>>(); #endif return true; 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 --- 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 @@ -24,46 +24,30 @@ assert((lhs != rhs) == x); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + 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); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - 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); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> 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); - } + test_string, min_allocator>>(); #endif return true; 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 --- 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 @@ -25,46 +25,30 @@ assert((lhs != rhs) == x); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + 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); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - 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); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> 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); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string_view.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string_view.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_string_view.pass.cpp @@ -23,48 +23,31 @@ assert((lhs != rhs) == x); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(S(""), SV(""), false); + test(S(""), SV("abcde"), true); + test(S(""), SV("abcdefghij"), true); + test(S(""), SV("abcdefghijklmnopqrst"), true); + test(S("abcde"), SV(""), true); + test(S("abcde"), SV("abcde"), false); + test(S("abcde"), SV("abcdefghij"), true); + test(S("abcde"), SV("abcdefghijklmnopqrst"), true); + test(S("abcdefghij"), SV(""), true); + test(S("abcdefghij"), SV("abcde"), true); + test(S("abcdefghij"), SV("abcdefghij"), false); + test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true); + test(S("abcdefghijklmnopqrst"), SV(""), true); + test(S("abcdefghijklmnopqrst"), SV("abcde"), true); + test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true); + test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string SV; - test(S(""), SV(""), false); - test(S(""), SV("abcde"), true); - test(S(""), SV("abcdefghij"), true); - test(S(""), SV("abcdefghijklmnopqrst"), true); - test(S("abcde"), SV(""), true); - test(S("abcde"), SV("abcde"), false); - test(S("abcde"), SV("abcdefghij"), true); - test(S("abcde"), SV("abcdefghijklmnopqrst"), true); - test(S("abcdefghij"), SV(""), true); - test(S("abcdefghij"), SV("abcde"), true); - test(S("abcdefghij"), SV("abcdefghij"), false); - test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true); - test(S("abcdefghijklmnopqrst"), SV(""), true); - test(S("abcdefghijklmnopqrst"), SV("abcde"), true); - test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true); - test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - typedef std::basic_string_view> SV; - test(S(""), SV(""), false); - test(S(""), SV("abcde"), true); - test(S(""), SV("abcdefghij"), true); - test(S(""), SV("abcdefghijklmnopqrst"), true); - test(S("abcde"), SV(""), true); - test(S("abcde"), SV("abcde"), false); - test(S("abcde"), SV("abcdefghij"), true); - test(S("abcde"), SV("abcdefghijklmnopqrst"), true); - test(S("abcdefghij"), SV(""), true); - test(S("abcdefghij"), SV("abcde"), true); - test(S("abcdefghij"), SV("abcdefghij"), false); - test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true); - test(S("abcdefghijklmnopqrst"), SV(""), true); - test(S("abcdefghijklmnopqrst"), SV("abcde"), true); - test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true); - test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_view_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_view_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_view_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op!=/string_view_string.pass.cpp @@ -23,48 +23,31 @@ assert((lhs != rhs) == x); } +template +TEST_CONSTEXPR_CXX20 void test_string() { + typedef std::string_view SV; + test(SV(""), S(""), false); + test(SV(""), S("abcde"), true); + test(SV(""), S("abcdefghij"), true); + test(SV(""), S("abcdefghijklmnopqrst"), true); + test(SV("abcde"), S(""), true); + test(SV("abcde"), S("abcde"), false); + test(SV("abcde"), S("abcdefghij"), true); + test(SV("abcde"), S("abcdefghijklmnopqrst"), true); + test(SV("abcdefghij"), S(""), true); + test(SV("abcdefghij"), S("abcde"), true); + test(SV("abcdefghij"), S("abcdefghij"), false); + test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true); + test(SV("abcdefghijklmnopqrst"), S(""), true); + test(SV("abcdefghijklmnopqrst"), S("abcde"), true); + test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true); + test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); +} + TEST_CONSTEXPR_CXX20 bool test() { - { - typedef std::string S; - typedef std::string_view SV; - test(SV(""), S(""), false); - test(SV(""), S("abcde"), true); - test(SV(""), S("abcdefghij"), true); - test(SV(""), S("abcdefghijklmnopqrst"), true); - test(SV("abcde"), S(""), true); - test(SV("abcde"), S("abcde"), false); - test(SV("abcde"), S("abcdefghij"), true); - test(SV("abcde"), S("abcdefghijklmnopqrst"), true); - test(SV("abcdefghij"), S(""), true); - test(SV("abcdefghij"), S("abcde"), true); - test(SV("abcdefghij"), S("abcdefghij"), false); - test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true); - test(SV("abcdefghijklmnopqrst"), S(""), true); - test(SV("abcdefghijklmnopqrst"), S("abcde"), true); - test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true); - test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); - } + test_string(); #if TEST_STD_VER >= 11 - { - typedef std::basic_string, min_allocator> S; - typedef std::basic_string_view> SV; - test(SV(""), S(""), false); - test(SV(""), S("abcde"), true); - test(SV(""), S("abcdefghij"), true); - test(SV(""), S("abcdefghijklmnopqrst"), true); - test(SV("abcde"), S(""), true); - test(SV("abcde"), S("abcde"), false); - test(SV("abcde"), S("abcdefghij"), true); - test(SV("abcde"), S("abcdefghijklmnopqrst"), true); - test(SV("abcdefghij"), S(""), true); - test(SV("abcdefghij"), S("abcde"), true); - test(SV("abcdefghij"), S("abcdefghij"), false); - test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true); - test(SV("abcdefghijklmnopqrst"), S(""), true); - test(SV("abcdefghijklmnopqrst"), S("abcde"), true); - test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true); - test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); - } + test_string, min_allocator>>(); #endif return true; diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp @@ -376,7 +376,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.compare(0, 1, {"abc", 1}) < 0); diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp @@ -75,7 +75,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.compare({"abc", 1}) < 0); diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp @@ -156,7 +156,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.find_first_not_of({"abc", 1}) == 0); diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp @@ -156,7 +156,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.find_first_of({"abc", 1}) == std::string::npos); diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp @@ -156,7 +156,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.find_last_not_of({"abc", 1}) == s.size() - 1); diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp @@ -156,7 +156,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.find_last_of({"abc", 1}) == std::string::npos); diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp @@ -156,7 +156,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.find({"abc", 1}) == std::string::npos); diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp @@ -156,7 +156,7 @@ } #endif -#if TEST_STD_VER > 3 +#if TEST_STD_VER >= 11 { // LWG 2946 std::string s = " !"; assert(s.rfind({"abc", 1}) == std::string::npos);