[libcxx-commits] [libcxx] 6e1dcc9 - [libc++] Refactor string unit tests to ease addition of new allocators
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 27 06:02:22 PDT 2023
Author: Louis Dionne
Date: 2023-09-27T09:01:58-04:00
New Revision: 6e1dcc9335116f650d68cdbed12bbb34a99b2d9b
URL: https://github.com/llvm/llvm-project/commit/6e1dcc9335116f650d68cdbed12bbb34a99b2d9b
DIFF: https://github.com/llvm/llvm-project/commit/6e1dcc9335116f650d68cdbed12bbb34a99b2d9b.diff
LOG: [libc++] Refactor string unit tests to ease addition of new allocators
While doing this, I also found a few tests that were either clearly
incorrect (e.g. testing the wrong function) or that lacked basic test
coverage like testing std::string itself (e.g. the test was only checking
std::basic_string with a custom allocator). In these cases, I did a few
conservative drive-by changes.
Differential Revision: https://reviews.llvm.org/D140550
Co-authored-by: Brendan Emery <brendan.emery at esrlabs.com>
Added:
Modified:
libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
libcxx/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp
libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
libcxx/test/std/strings/basic.string/string.capacity/max_size.pass.cpp
libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/copy.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/move.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp
libcxx/test/std/strings/basic.string/string.contains/contains.char.pass.cpp
libcxx/test/std/strings/basic.string/string.contains/contains.ptr.pass.cpp
libcxx/test/std/strings/basic.string/string.contains/contains.string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.ends_with/ends_with.char.pass.cpp
libcxx/test/std/strings/basic.string/string.ends_with/ends_with.ptr.pass.cpp
libcxx/test/std/strings/basic.string/string.ends_with/ends_with.string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/robust_against_adl.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_view_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_view_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_view_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_view_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_view_string.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_compare/string.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find/string_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
libcxx/test/std/strings/basic.string/string.require/contiguous.pass.cpp
libcxx/test/std/strings/basic.string/string.starts_with/starts_with.char.pass.cpp
libcxx/test/std/strings/basic.string/string.starts_with/starts_with.ptr.pass.cpp
libcxx/test/std/strings/basic.string/string.starts_with/starts_with.string_view.pass.cpp
libcxx/utils/data/ignore_format.txt
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
index 635c907c16e5c96..9c6d49af7883e72 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.back.pass.cpp
@@ -20,17 +20,15 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ S s;
+ TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
+}
+
int main(int, char**) {
- {
- std::string s;
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
index 002099d95660cf0..7a89d06d2474135 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cback.pass.cpp
@@ -20,17 +20,15 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ const S s;
+ TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
+}
+
int main(int, char**) {
- {
- std::string const s;
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- const S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.back(), "string::back(): string is empty");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
index 1be0c1404f4e853..30dc29a951c7bf6 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cfront.pass.cpp
@@ -20,18 +20,15 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ const S s;
+ TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
+}
+
int main(int, char**) {
- {
- typedef std::string S;
- const S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- const S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
index 02b88f2125e6e8d..2b4072826fd604d 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.cindex.pass.cpp
@@ -21,20 +21,16 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ const S s;
+ assert(s[0] == 0);
+ TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
+}
+
int main(int, char**) {
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- const S s;
- assert(s[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
- }
-
- {
- typedef std::string S;
- const S s;
- assert(s[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
index 70df94bad9e12d9..e75908ee07c1366 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.front.pass.cpp
@@ -21,18 +21,15 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ S s;
+ TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
+}
+
int main(int, char**) {
- {
- typedef std::string S;
- S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S s;
- TEST_LIBCPP_ASSERT_FAILURE(s.front(), "string::front(): string is empty");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
index e82178863f7466e..95701314faf8e2d 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.access/assert.index.pass.cpp
@@ -21,20 +21,16 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ S s;
+ assert(s[0] == 0);
+ TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
+}
+
int main(int, char**) {
- {
- typedef std::string S;
- S s;
- assert(s[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S s;
- assert(s[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(s[1], "string index out of bounds");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
index 9922306399a8fea..8459284637dc506 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.add.pass.cpp
@@ -19,26 +19,19 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class C>
+void test() {
+ C c(1, '\0');
+ typename C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ TEST_LIBCPP_ASSERT_FAILURE(i += 2, "Attempted to add/subtract an iterator outside its valid range");
+}
+
int main(int, char**) {
- {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.begin();
- i += 1;
- assert(i == c.end());
- i = c.begin();
- TEST_LIBCPP_ASSERT_FAILURE(i += 2, "Attempted to add/subtract an iterator outside its valid range");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.begin();
- i += 1;
- assert(i == c.end());
- i = c.begin();
- TEST_LIBCPP_ASSERT_FAILURE(i += 2, "Attempted to add/subtract an iterator outside its valid range");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
index b2149de6900aebb..c55410edf4ebac6 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.compare.pass.cpp
@@ -18,20 +18,16 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ S s1;
+ S s2;
+ TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators");
+}
+
int main(int, char**) {
- {
- typedef std::string S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() < s2.begin(), "Attempted to compare incomparable iterators");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
index 3379008f5966898..f1fa08d006a1e0d 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.decrement.pass.cpp
@@ -19,24 +19,18 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class C>
+void test() {
+ C c(1, '\0');
+ typename C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
+}
+
int main(int, char**) {
- {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.end();
- --i;
- assert(i == c.begin());
- TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.end();
- --i;
- assert(i == c.begin());
- TEST_LIBCPP_ASSERT_FAILURE(--i, "Attempted to decrement a non-decrementable iterator");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
index cc916bc7b77a1d2..0bf295c6c4f4fb8 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.dereference.pass.cpp
@@ -18,20 +18,16 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class C>
+void test() {
+ C c(1, '\0');
+ typename C::iterator i = c.end();
+ TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
+}
+
int main(int, char**) {
- {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.end();
- TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.end();
- TEST_LIBCPP_ASSERT_FAILURE(*i, "Attempted to dereference a non-dereferenceable iterator");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
index e276020f480a5e2..9cc9ab40bcdd659 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.increment.pass.cpp
@@ -19,24 +19,18 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class C>
+void test() {
+ C c(1, '\0');
+ typename C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
+}
+
int main(int, char**) {
- {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.begin();
- ++i;
- assert(i == c.end());
- TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.begin();
- ++i;
- assert(i == c.end());
- TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
index 9ab22bdf3b135bd..34060065d204669 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.index.pass.cpp
@@ -19,23 +19,18 @@
#include "check_assertion.h"
#include "min_allocator.h"
-int main(int, char**) {
+template <class C>
+void test() {
using T = decltype(std::uint8_t() - std::uint8_t());
- {
- typedef std::string C;
- C c(1, '\0');
- C::iterator i = c.begin();
- assert(i[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(i[1], "Attempted to subscript an iterator outside its valid range");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > C;
- C c(1, '\0');
- C::iterator i = c.begin();
- assert(i[0] == 0);
- TEST_LIBCPP_ASSERT_FAILURE(i[1], "Attempted to subscript an iterator outside its valid range");
- }
+ C c(1, '\0');
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ TEST_LIBCPP_ASSERT_FAILURE(i[1], "Attempted to subscript an iterator outside its valid range");
+}
+
+int main(int, char**) {
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
index e0a01f8eb3517a2..d3274cbd90cc500 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.iterators/debug.iterator.subtract.pass.cpp
@@ -18,20 +18,16 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ S s1;
+ S s2;
+ TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators");
+}
+
int main(int, char**) {
- {
- typedef std::string S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S s1;
- S s2;
- TEST_LIBCPP_ASSERT_FAILURE(s1.begin() - s2.begin(), "Attempted to subtract incompatible iterators");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
index 4800b245884db08..8c6d704a684b530 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.erase_iter.null.pass.cpp
@@ -20,19 +20,16 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ S l1("123");
+ typename S::const_iterator i = l1.end();
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with a non-dereferenceable iterator");
+}
+
int main(int, char**) {
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S::const_iterator i = l1.end();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with a non-dereferenceable iterator");
- }
-
- {
- std::string l1("123");
- std::string::const_iterator i = l1.end();
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(i), "string::erase(iterator) called with a non-dereferenceable iterator");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
index 637f5c2abe3d6ad..1bdf3af36743028 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/assert.pop_back.pass.cpp
@@ -19,9 +19,14 @@
#include "check_assertion.h"
-int main(int, char**) {
- std::string s;
+template <class S>
+void test() {
+ S s;
TEST_LIBCPP_ASSERT_FAILURE(s.pop_back(), "string::pop_back(): string is already empty");
+}
+
+int main(int, char**) {
+ test<std::string>();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
index 5b690a576fad3e8..93fd6caf0ba2365 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter.pass.cpp
@@ -18,23 +18,18 @@
#include "check_assertion.h"
#include "min_allocator.h"
+template <class S>
+void test() {
+ S l1("123");
+ S l2("123");
+ typename S::const_iterator i = l2.begin();
+ TEST_LIBCPP_ASSERT_FAILURE(
+ l1.erase(i), "string::erase(iterator) called with an iterator not referring to this string");
+}
+
int main(int, char**) {
- {
- std::string l1("123");
- std::string l2("123");
- std::string::const_iterator i = l2.begin();
- TEST_LIBCPP_ASSERT_FAILURE(
- l1.erase(i), "string::erase(iterator) called with an iterator not referring to this string");
- }
-
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- S::const_iterator i = l2.begin();
- TEST_LIBCPP_ASSERT_FAILURE(
- l1.erase(i), "string::erase(iterator) called with an iterator not referring to this string");
- }
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
index 7ee9d7ac20c6032..ed97e21d9411e62 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.erase.iter_iter.pass.cpp
@@ -18,64 +18,44 @@
#include "check_assertion.h"
#include "min_allocator.h"
-int main(int, char**) {
+template <class S>
+void test() {
// With first iterator from another container
- {{std::string l1("123");
- std::string l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), l1.cbegin() + 1),
- "string::erase(iterator, iterator) called with an iterator not referring to this string");
-}
-{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), l1.cbegin() + 1),
- "string::erase(iterator, iterator) called with an iterator not referring to this string");
-}
-}
-
-// With second iterator from another container
-{{std::string l1("123");
-std::string l2("123");
-TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), l2.cbegin() + 1), "Attempted to compare incomparable iterators");
-}
-{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), l2.cbegin() + 1), "Attempted to compare incomparable iterators");
-}
-}
+ {
+ S l1("123");
+ S l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(
+ l1.erase(l2.cbegin(), l1.cbegin() + 1),
+ "string::erase(iterator, iterator) called with an iterator not referring to this string");
+ }
-// With both iterators from another container
-{{std::string l1("123");
-std::string l2("123");
-TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), l2.cbegin() + 1),
- "string::erase(iterator, iterator) called with an iterator not referring to this string");
-}
-{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- S l1("123");
- S l2("123");
- TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l2.cbegin(), l2.cbegin() + 1),
- "string::erase(iterator, iterator) called with an iterator not referring to this string");
-}
-}
+ // With second iterator from another container
+ {
+ S l1("123");
+ S l2("123");
+ TEST_LIBCPP_ASSERT_FAILURE(l1.erase(l1.cbegin(), l2.cbegin() + 1), "Attempted to compare incomparable iterators");
+ }
-// With an invalid range
-{
+ // With both iterators from another container
{
- std::string l1("123");
+ S l1("123");
+ S l2("123");
TEST_LIBCPP_ASSERT_FAILURE(
- l1.erase(l1.cbegin() + 1, l1.cbegin()), "string::erase(first, last) called with invalid range");
+ l1.erase(l2.cbegin(), l2.cbegin() + 1),
+ "string::erase(iterator, iterator) called with an iterator not referring to this string");
}
+
+ // With an invalid range
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S l1("123");
TEST_LIBCPP_ASSERT_FAILURE(
l1.erase(l1.cbegin() + 1, l1.cbegin()), "string::erase(first, last) called with invalid range");
}
}
-return 0;
+int main(int, char**) {
+ test<std::string>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+
+ return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
index 7cdf64375718320..561f79e0e18fb81 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_char.pass.cpp
@@ -23,13 +23,17 @@
#include "check_assertion.h"
-int main(int, char**) {
- typedef std::string S;
+template <class S>
+void test() {
S s;
S s2;
TEST_LIBCPP_ASSERT_FAILURE(
s.insert(s2.begin(), '1'),
"string::insert(iterator, character) called with an iterator not referring to this string");
+}
+
+int main(int, char**) {
+ test<std::string>();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
index 3dadcfdad2631be..eef525349972b92 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_iter_iter.pass.cpp
@@ -18,13 +18,18 @@
#include "check_assertion.h"
-int main(int, char**) {
- std::string v;
- std::string v2;
+template <class S>
+void test() {
+ S v;
+ S v2;
char a[] = "123";
const int N = sizeof(a) / sizeof(a[0]);
TEST_LIBCPP_ASSERT_FAILURE(
v.insert(v2.cbegin() + 10, a, a + N), "Attempted to add/subtract an iterator outside its valid range");
+}
+
+int main(int, char**) {
+ test<std::string>();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
index ca4454400daa585..4b7532678f2e579 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/debug.insert.iter_size_char.pass.cpp
@@ -17,11 +17,16 @@
#include "check_assertion.h"
-int main(int, char**) {
- std::string s;
- std::string s2;
+template <class S>
+void test() {
+ S s;
+ S s2;
TEST_LIBCPP_ASSERT_FAILURE(s.insert(s2.begin(), 1, 'a'),
"string::insert(iterator, n, value) called with an iterator not referring to this string");
+}
+
+int main(int, char**) {
+ test<std::string>();
return 0;
}
diff --git a/libcxx/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp b/libcxx/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp
index 572a7672935a368..8e6e07d659c1a0a 100644
--- a/libcxx/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp
+++ b/libcxx/test/libcxx/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp
@@ -22,11 +22,12 @@ TEST_CONSTEXPR_CXX20 void write_c_str(char* buf, int size) {
buf[size] = '\0';
}
+template <class S>
TEST_CONSTEXPR_CXX20 void test_buffer_usage() {
{
unsigned buff_size = 125;
unsigned used_size = buff_size - 16;
- std::string s;
+ S s;
s.__resize_default_init(buff_size);
write_c_str(&s[0], used_size);
assert(s.size() == buff_size);
@@ -40,9 +41,10 @@ TEST_CONSTEXPR_CXX20 void test_buffer_usage() {
}
}
+template <class S>
TEST_CONSTEXPR_CXX20 void test_basic() {
{
- std::string s;
+ S s;
s.__resize_default_init(3);
assert(s.size() == 3);
assert(s.data()[3] == '\0');
@@ -55,17 +57,18 @@ TEST_CONSTEXPR_CXX20 void test_basic() {
}
}
+template <class S>
TEST_CONSTEXPR_CXX20 bool test() {
- test_basic();
- test_buffer_usage();
+ test_basic<S>();
+ test_buffer_usage<S>();
return true;
}
int main(int, char**) {
- test();
+ test<std::string>();
#if TEST_STD_VER > 17
- static_assert(test());
+ static_assert(test<std::string>());
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
index 871154ae3c97e23..e1d20662e41de89 100644
--- a/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
@@ -19,7 +19,7 @@
#include "test_macros.h"
template <class S>
-TEST_CONSTEXPR_CXX20 void test(S s, test_allocator_statistics& alloc_stats) {
+TEST_CONSTEXPR_CXX20 void test_invariant(S s, test_allocator_statistics& alloc_stats) {
alloc_stats.throw_after = 0;
#ifndef TEST_HAS_NO_EXCEPTIONS
try
@@ -37,33 +37,52 @@ TEST_CONSTEXPR_CXX20 void test(S s, test_allocator_statistics& alloc_stats) {
alloc_stats.throw_after = INT_MAX;
}
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc>;
+ {
+ S const s((Alloc(a)));
+ assert(s.capacity() >= 0);
+ }
+ {
+ S const s(3, 'x', Alloc(a));
+ assert(s.capacity() >= 3);
+ }
+#if TEST_STD_VER >= 11
+ // Check that we perform SSO
+ {
+ S const s;
+ assert(s.capacity() > 0);
+ ASSERT_NOEXCEPT(s.capacity());
+ }
+#endif
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(3));
+ test_string(min_allocator<char>());
+
{
test_allocator_statistics alloc_stats;
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S;
S s((test_allocator<char>(&alloc_stats)));
- test(s, alloc_stats);
+ test_invariant(s, alloc_stats);
s.assign(10, 'a');
s.erase(5);
- test(s, alloc_stats);
+ test_invariant(s, alloc_stats);
s.assign(100, 'a');
s.erase(50);
- test(s, alloc_stats);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s;
- assert(s.capacity() > 0);
+ test_invariant(s, alloc_stats);
}
-#endif
return true;
}
int main(int, char**) {
test();
-#if TEST_STD_VER > 17
+#if TEST_STD_VER >= 20
static_assert(test());
#endif
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
index ac17dac6e3efcd5..52dbde45dbb265d 100644
--- 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
@@ -26,7 +26,7 @@
#include "min_allocator.h"
template <class S>
-TEST_CONSTEXPR_CXX20 void test1(const S& s) {
+TEST_CONSTEXPR_CXX20 void test_resize_max_size_minus_1(const S& s) {
S s2(s);
const std::size_t sz = s2.max_size() - 1;
try {
@@ -38,7 +38,7 @@ TEST_CONSTEXPR_CXX20 void test1(const S& s) {
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test2(const S& s) {
+TEST_CONSTEXPR_CXX20 void test_resize_max_size(const S& s) {
S s2(s);
const std::size_t sz = s2.max_size();
try {
@@ -49,45 +49,50 @@ TEST_CONSTEXPR_CXX20 void test2(const S& s) {
assert(s.size() == sz);
}
-template <class S>
-TEST_CONSTEXPR_CXX20 void test(const S& s) {
- assert(s.max_size() >= s.size());
- test1(s);
- test2(s);
-}
-
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
- test(S());
- test(S("123"));
- test(S("12345678901234567890123456789012345678901234567890"));
+ {
+ S s;
+ assert(s.max_size() >= s.size());
+ assert(s.max_size() > 0);
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ test_resize_max_size_minus_1(s);
+ test_resize_max_size(s);
+ }
+ }
+ {
+ S s("123");
+ assert(s.max_size() >= s.size());
+ assert(s.max_size() > 0);
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ test_resize_max_size_minus_1(s);
+ test_resize_max_size(s);
+ }
+ }
+ {
+ S s("12345678901234567890123456789012345678901234567890");
+ assert(s.max_size() >= s.size());
+ assert(s.max_size() > 0);
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ test_resize_max_size_minus_1(s);
+ test_resize_max_size(s);
+ }
+ }
}
TEST_CONSTEXPR_CXX20 bool test() {
test_string<std::string>();
#if TEST_STD_VER >= 11
- test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
}
-#if TEST_STD_VER > 17
-constexpr bool test_constexpr() {
- std::string str;
-
- std::size_t size = str.max_size();
- assert(size > 0);
-
- return true;
-}
-#endif
-
int main(int, char**) {
test();
-#if TEST_STD_VER > 17
- test_constexpr();
- static_assert(test_constexpr());
+#if TEST_STD_VER >= 20
+ static_assert(test());
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
index a0d7f782de1f5b3..bbe6551a0ff1181 100644
--- a/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.capacity/resize_and_overwrite.pass.cpp
@@ -57,19 +57,18 @@ constexpr void test_truncating(std::size_t o, size_t N) {
assert(s.c_str()[N] == '\0');
}
-template <class CharT>
+template <class String>
constexpr bool test() {
- using S = std::basic_string<CharT>;
- test_appending<S>(10, 15, 15);
- test_appending<S>(10, 15, 20);
- test_appending<S>(10, 40, 40);
- test_appending<S>(10, 40, 50);
- test_appending<S>(30, 35, 35);
- test_appending<S>(30, 35, 45);
- test_appending<S>(10, 15, 30);
- test_truncating<S>(15, 10);
- test_truncating<S>(40, 35);
- test_truncating<S>(40, 10);
+ test_appending<String>(10, 15, 15);
+ test_appending<String>(10, 15, 20);
+ test_appending<String>(10, 40, 40);
+ test_appending<String>(10, 40, 50);
+ test_appending<String>(30, 35, 35);
+ test_appending<String>(30, 35, 45);
+ test_appending<String>(10, 15, 30);
+ test_truncating<String>(15, 10);
+ test_truncating<String>(40, 35);
+ test_truncating<String>(40, 10);
return true;
}
@@ -85,19 +84,19 @@ void test_value_categories() {
}
int main(int, char**) {
- test<char>();
- test<char8_t>();
- test<char16_t>();
- test<char32_t>();
+ test<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>();
+ test<std::basic_string<char8_t, std::char_traits<char8_t>, std::allocator<char8_t>>>();
+ test<std::basic_string<char16_t, std::char_traits<char16_t>, std::allocator<char16_t>>>();
+ test<std::basic_string<char32_t, std::char_traits<char32_t>, std::allocator<char32_t>>>();
- static_assert(test<char>());
- static_assert(test<char8_t>());
- static_assert(test<char16_t>());
- static_assert(test<char32_t>());
+ static_assert(test<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>());
+ static_assert(test<std::basic_string<char8_t, std::char_traits<char8_t>, std::allocator<char8_t>>>());
+ static_assert(test<std::basic_string<char16_t, std::char_traits<char16_t>, std::allocator<char16_t>>>());
+ static_assert(test<std::basic_string<char32_t, std::char_traits<char32_t>, std::allocator<char32_t>>>());
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- test<wchar_t>();
- static_assert(test<wchar_t>());
+ test<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>>();
+ static_assert(test<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>>());
#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
index edbc41f060cc560..a6b625b7b0e8113 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/T_size_size.pass.cpp
@@ -77,68 +77,44 @@ TEST_CONSTEXPR_CXX20 void test(SV sv, std::size_t pos, std::size_t n, const type
#endif
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- typedef std::basic_string_view<char, std::char_traits<char> > SV;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
-
- test<S, SV>(SV(), 0, 0);
- test<S, SV>(SV(), 0, 1);
- test<S, SV>(SV(), 1, 0);
- test<S, SV>(SV(), 1, 1);
- test<S, SV>(SV(), 1, 2);
- test<S, SV>(SV("1"), 0, 0);
- test<S, SV>(SV("1"), 0, 1);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
-
- test<S, SV>(SV(), 0, 0, A(4));
- test<S, SV>(SV(), 0, 1, A(4));
- test<S, SV>(SV(), 1, 0, A(4));
- test<S, SV>(SV(), 1, 1, A(4));
- test<S, SV>(SV(), 1, 2, A(4));
- test<S, SV>(SV("1"), 0, 0, A(6));
- test<S, SV>(SV("1"), 0, 1, A(6));
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, A(8));
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, A(8));
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, A(8));
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, A(8));
- }
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ typedef std::basic_string_view<char, std::char_traits<char> > SV;
+ typedef std::basic_string<char, std::char_traits<char>, Alloc> S;
+
+ test<S, SV>(SV(), 0, 0);
+ test<S, SV>(SV(), 0, 1);
+ test<S, SV>(SV(), 1, 0);
+ test<S, SV>(SV(), 1, 1);
+ test<S, SV>(SV(), 1, 2);
+ test<S, SV>(SV("1"), 0, 0);
+ test<S, SV>(SV("1"), 0, 1);
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
+
+ test<S, SV>(SV(), 0, 0, Alloc(a));
+ test<S, SV>(SV(), 0, 1, Alloc(a));
+ test<S, SV>(SV(), 1, 0, Alloc(a));
+ test<S, SV>(SV(), 1, 1, Alloc(a));
+ test<S, SV>(SV(), 1, 2, Alloc(a));
+ test<S, SV>(SV("1"), 0, 0, Alloc(a));
+ test<S, SV>(SV("1"), 0, 1, Alloc(a));
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, Alloc(a));
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, Alloc(a));
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, Alloc(a));
+ test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, Alloc(a));
+}
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(8));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
- typedef std::basic_string_view<char, std::char_traits<char> > SV;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
-
- test<S, SV>(SV(), 0, 0);
- test<S, SV>(SV(), 0, 1);
- test<S, SV>(SV(), 1, 0);
- test<S, SV>(SV(), 1, 1);
- test<S, SV>(SV(), 1, 2);
- test<S, SV>(SV("1"), 0, 0);
- test<S, SV>(SV("1"), 0, 1);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
-
- test<S, SV>(SV(), 0, 0, A());
- test<S, SV>(SV(), 0, 1, A());
- test<S, SV>(SV(), 1, 0, A());
- test<S, SV>(SV(), 1, 1, A());
- test<S, SV>(SV(), 1, 2, A());
- test<S, SV>(SV("1"), 0, 0, A());
- test<S, SV>(SV("1"), 0, 1, A());
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, A());
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, A());
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, A());
- test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, A());
- }
+ test_string(min_allocator<char>());
#endif
+
{
typedef std::string S;
typedef std::string_view SV;
diff --git a/libcxx/test/std/strings/basic.string/string.cons/copy.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/copy.pass.cpp
index 6b10388f5258bea..3afe76e88316f99 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/copy.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/copy.pass.cpp
@@ -26,22 +26,20 @@ TEST_CONSTEXPR_CXX20 void test(S s1) {
assert(s2.get_allocator() == s1.get_allocator());
}
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ typedef std::basic_string<char, std::char_traits<char>, Alloc> S;
+ test(S(Alloc(a)));
+ test(S("1", Alloc(a)));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a)));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(A(3)));
- test(S("1", A(5)));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
- }
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(3));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(A{}));
- test(S("1", A()));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
- }
+ test_string(min_allocator<char>());
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
index 2d45f38d6afc24e..6b0040376a424ec 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
@@ -85,23 +85,23 @@ TEST_CONSTEXPR_CXX20 void test(S s1, const typename S::allocator_type& a) {
assert(s2.get_allocator() == a);
}
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ typedef std::basic_string<char, std::char_traits<char>, Alloc> S;
+ test(S(), Alloc(a));
+ test(S("1"), Alloc(a));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), Alloc(a));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(), A(3));
- test(S("1"), A(5));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
- }
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(3));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(), A());
- test(S("1"), A());
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
- }
+ test_string(min_allocator<char>());
+#endif
+#if TEST_STD_VER >= 11
# ifndef TEST_HAS_NO_EXCEPTIONS
if (!TEST_IS_CONSTANT_EVALUATED) {
typedef poca_alloc<char> A;
diff --git a/libcxx/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp
index 78518aed7e59181..5b7e8bde2e6e877 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/initializer_list.pass.cpp
@@ -19,31 +19,25 @@
#include "test_allocator.h"
#include "min_allocator.h"
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- std::string s = {'a', 'b', 'c'};
- assert(s == "abc");
- }
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- {
- std::wstring s;
- s = {L'a', L'b', L'c'};
- assert(s == L"abc");
- }
-#endif
+// clang-format off
+template <template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s = {'a', 'b', 'c'};
+ std::basic_string<char, std::char_traits<char>, Alloc<char> > s = {'a', 'b', 'c'};
assert(s == "abc");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
- S s;
- s = {L'a', L'b', L'c'};
+ std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> > s = {L'a', L'b', L'c'};
assert(s == L"abc");
}
#endif
+}
+// clang-format on
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::allocator>();
+ test_string<min_allocator>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
index edc31eac0b07efc..88597daba121ac4 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
@@ -18,18 +18,31 @@
#include "test_macros.h"
#include "min_allocator.h"
-TEST_CONSTEXPR_CXX20 bool test() {
+// clang-format off
+template <template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
{
- std::string s;
- s = {'a', 'b', 'c'};
+ typedef std::basic_string<char, std::char_traits<char>, Alloc<char>> S;
+ S s;
+ S& result = (s = {'a', 'b', 'c'});
assert(s == "abc");
+ assert(&result == &s);
}
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+ typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t>> S;
S s;
- s = {'a', 'b', 'c'};
- assert(s == "abc");
+ S& result = (s = {L'a', L'b', L'c'});
+ assert(s == L"abc");
+ assert(&result == &s);
}
+#endif
+}
+// clang-format on
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::allocator>();
+ test_string<min_allocator>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
index 7cf2b194c6d1e68..2ef73e5ec8c1ade 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/iter_alloc.pass.cpp
@@ -22,11 +22,10 @@
#include "test_iterators.h"
#include "min_allocator.h"
-template <class It>
+template <class Alloc, class It>
TEST_CONSTEXPR_CXX20 void test(It first, It last) {
typedef typename std::iterator_traits<It>::value_type charT;
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
- typedef typename S::allocator_type A;
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
S s2(first, last);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
@@ -36,14 +35,14 @@ TEST_CONSTEXPR_CXX20 void test(It first, It last) {
++it;
++i;
}
- assert(s2.get_allocator() == A());
+ assert(s2.get_allocator() == Alloc());
assert(s2.capacity() >= s2.size());
}
-template <class It, class A>
-TEST_CONSTEXPR_CXX20 void test(It first, It last, const A& a) {
+template <class Alloc, class It>
+TEST_CONSTEXPR_CXX20 void test(It first, It last, const Alloc& a) {
typedef typename std::iterator_traits<It>::value_type charT;
- typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
S s2(first, last, a);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
@@ -57,64 +56,40 @@ TEST_CONSTEXPR_CXX20 void test(It first, It last, const A& a) {
assert(s2.capacity() >= s2.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- const char* s = "12345678901234567890123456789012345678901234567890";
-
- test(s, s);
- test(s, s, A(2));
-
- test(s, s + 1);
- test(s, s + 1, A(2));
-
- test(s, s + 10);
- test(s, s + 10, A(2));
-
- test(s, s + 50);
- test(s, s + 50, A(2));
-
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), A(2));
-
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), A(2));
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ const char* s = "12345678901234567890123456789012345678901234567890";
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), A(2));
+ test<Alloc>(s, s);
+ test<Alloc>(s, s, Alloc(a));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50), A(2));
- }
-#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
- const char* s = "12345678901234567890123456789012345678901234567890";
-
- test(s, s);
- test(s, s, A());
+ test<Alloc>(s, s + 1);
+ test<Alloc>(s, s + 1, Alloc(a));
- test(s, s + 1);
- test(s, s + 1, A());
+ test<Alloc>(s, s + 10);
+ test<Alloc>(s, s + 10, Alloc(a));
- test(s, s + 10);
- test(s, s + 10, A());
+ test<Alloc>(s, s + 50);
+ test<Alloc>(s, s + 50, Alloc(a));
- test(s, s + 50);
- test(s, s + 50, A());
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s));
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), Alloc(a));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), A());
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1));
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), Alloc(a));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), A());
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10));
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), Alloc(a));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), A());
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50));
+ test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50), Alloc(a));
+}
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50));
- test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50), A());
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(2));
+#if TEST_STD_VER >= 11
+ test_string(min_allocator<char>());
#endif
{
static_assert((!std::is_constructible<std::string, std::string, std::string>::value), "");
diff --git a/libcxx/test/std/strings/basic.string/string.cons/move.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/move.pass.cpp
index 29579b26df71d82..f5ffebd35d50e92 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/move.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/move.pass.cpp
@@ -30,21 +30,19 @@ TEST_CONSTEXPR_CXX20 void test(S s0) {
assert(s2.get_allocator() == s1.get_allocator());
}
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(Alloc const& a) {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc>;
+ test(S(Alloc(a)));
+ test(S("1", Alloc(a)));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a)));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(A(3)));
- test(S("1", A(5)));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
- }
- {
- typedef min_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(A{}));
- test(S("1", A()));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
- }
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(3));
+ test_string(min_allocator<char>());
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
index c7e31f5e64e0466..84a29df5b57bf16 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
@@ -20,23 +20,22 @@
#include "test_allocator.h"
#include "min_allocator.h"
-template <class charT>
+template <class Alloc, class charT>
TEST_CONSTEXPR_CXX20 void test(const charT* s) {
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
std::size_t n = T::length(s);
S s2(s);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == n);
assert(T::compare(s2.data(), s, n) == 0);
- assert(s2.get_allocator() == A());
+ assert(s2.get_allocator() == Alloc());
assert(s2.capacity() >= s2.size());
}
-template <class charT, class A>
-TEST_CONSTEXPR_CXX20 void test(const charT* s, const A& a) {
- typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+template <class Alloc, class charT>
+TEST_CONSTEXPR_CXX20 void test(const charT* s, const Alloc& a) {
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
typedef typename S::traits_type T;
std::size_t n = T::length(s);
S s2(s, a);
@@ -47,38 +46,27 @@ TEST_CONSTEXPR_CXX20 void test(const charT* s, const A& a) {
assert(s2.capacity() >= s2.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test(const Alloc& a) {
+ test<Alloc>("");
+ test<Alloc>("", Alloc(a));
- test("");
- test("", A(2));
+ test<Alloc>("1");
+ test<Alloc>("1", Alloc(a));
- test("1");
- test("1", A(2));
+ test<Alloc>("1234567980");
+ test<Alloc>("1234567980", Alloc(a));
- test("1234567980");
- test("1234567980", A(2));
+ test<Alloc>("123456798012345679801234567980123456798012345679801234567980");
+ test<Alloc>("123456798012345679801234567980123456798012345679801234567980", Alloc(a));
+}
- test("123456798012345679801234567980123456798012345679801234567980");
- test("123456798012345679801234567980123456798012345679801234567980", A(2));
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test(std::allocator<char>());
+ test(test_allocator<char>());
+ test(test_allocator<char>(2));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
-
- test("");
- test("", A());
-
- test("1");
- test("1", A());
-
- test("1234567980");
- test("1234567980", A());
-
- test("123456798012345679801234567980123456798012345679801234567980");
- test("123456798012345679801234567980123456798012345679801234567980", A());
- }
+ test(min_allocator<char>());
#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
index a85ef27adb8de90..e0dab72b5c6327e 100644
--- 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
@@ -19,22 +19,21 @@
#include "test_allocator.h"
#include "min_allocator.h"
-template <class charT>
-TEST_CONSTEXPR_CXX20 void test(const charT* s, unsigned n) {
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+template <class Alloc, class CharT>
+TEST_CONSTEXPR_CXX20 void test(const CharT* s, unsigned n) {
+ typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
S s2(s, n);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == n);
assert(T::compare(s2.data(), s, n) == 0);
- assert(s2.get_allocator() == A());
+ assert(s2.get_allocator() == Alloc());
assert(s2.capacity() >= s2.size());
}
-template <class charT, class A>
-TEST_CONSTEXPR_CXX20 void test(const charT* s, unsigned n, const A& a) {
- typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+template <class Alloc, class CharT>
+TEST_CONSTEXPR_CXX20 void test(const CharT* s, unsigned n, const Alloc& a) {
+ typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
typedef typename S::traits_type T;
S s2(s, n, a);
LIBCPP_ASSERT(s2.__invariants());
@@ -44,38 +43,27 @@ TEST_CONSTEXPR_CXX20 void test(const charT* s, unsigned n, const A& a) {
assert(s2.capacity() >= s2.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test(const Alloc& a) {
+ test<Alloc>("", 0);
+ test<Alloc>("", 0, Alloc(a));
- test("", 0);
- test("", 0, A(2));
+ test<Alloc>("1", 1);
+ test<Alloc>("1", 1, Alloc(a));
- test("1", 1);
- test("1", 1, A(2));
+ test<Alloc>("1234567980", 10);
+ test<Alloc>("1234567980", 10, Alloc(a));
- test("1234567980", 10);
- test("1234567980", 10, A(2));
+ test<Alloc>("123456798012345679801234567980123456798012345679801234567980", 60);
+ test<Alloc>("123456798012345679801234567980123456798012345679801234567980", 60, Alloc(a));
+}
- test("123456798012345679801234567980123456798012345679801234567980", 60);
- test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test(std::allocator<char>());
+ test(test_allocator<char>());
+ test(test_allocator<char>(2));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
-
- test("", 0);
- test("", 0, A());
-
- test("1", 1);
- test("1", 1, A());
-
- test("1234567980", 10);
- test("1234567980", 10, A());
-
- test("123456798012345679801234567980123456798012345679801234567980", 60);
- test("123456798012345679801234567980123456798012345679801234567980", 60, A());
- }
+ test(min_allocator<char>());
#endif
#if TEST_STD_VER >= 11
diff --git a/libcxx/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
index 8d56cfa628f72a2..3afbcdffa6bdfe3 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
@@ -20,22 +20,21 @@
#include "test_allocator.h"
#include "min_allocator.h"
-template <class charT>
+template <class Alloc, class charT>
TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c) {
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
- typedef typename S::allocator_type A;
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
S s2(n, c);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == n);
for (unsigned i = 0; i < n; ++i)
assert(s2[i] == c);
- assert(s2.get_allocator() == A());
+ assert(s2.get_allocator() == Alloc());
assert(s2.capacity() >= s2.size());
}
-template <class charT, class A>
-TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c, const A& a) {
- typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+template <class Alloc, class charT>
+TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c, const Alloc& a) {
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
S s2(n, c, a);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == n);
@@ -45,24 +44,23 @@ TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c, const A& a) {
assert(s2.capacity() >= s2.size());
}
-template <class Tp>
+template <class Alloc, class Tp>
TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c) {
typedef char charT;
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
- typedef typename S::allocator_type A;
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
S s2(n, c);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == static_cast<std::size_t>(n));
for (int i = 0; i < n; ++i)
assert(s2[i] == c);
- assert(s2.get_allocator() == A());
+ assert(s2.get_allocator() == Alloc());
assert(s2.capacity() >= s2.size());
}
-template <class Tp, class A>
-TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c, const A& a) {
+template <class Alloc, class Tp>
+TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c, const Alloc& a) {
typedef char charT;
- typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+ typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
S s2(n, c, a);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == static_cast<std::size_t>(n));
@@ -72,44 +70,30 @@ TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c, const A& a) {
assert(s2.capacity() >= s2.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ test<Alloc>(0, 'a');
+ test<Alloc>(0, 'a', Alloc(a));
- test(0, 'a');
- test(0, 'a', A(2));
+ test<Alloc>(1, 'a');
+ test<Alloc>(1, 'a', Alloc(a));
- test(1, 'a');
- test(1, 'a', A(2));
+ test<Alloc>(10, 'a');
+ test<Alloc>(10, 'a', Alloc(a));
- test(10, 'a');
- test(10, 'a', A(2));
+ test<Alloc>(100, 'a');
+ test<Alloc>(100, 'a', Alloc(a));
- test(100, 'a');
- test(100, 'a', A(2));
+ test<Alloc>(static_cast<char>(100), static_cast<char>(65));
+ test<Alloc>(static_cast<char>(100), static_cast<char>(65), a);
+}
- test(static_cast<char>(100), static_cast<char>(65));
- test(static_cast<char>(100), static_cast<char>(65), A(3));
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(2));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
-
- test(0, 'a');
- test(0, 'a', A());
-
- test(1, 'a');
- test(1, 'a', A());
-
- test(10, 'a');
- test(10, 'a', A());
-
- test(100, 'a');
- test(100, 'a', A());
-
- test(static_cast<char>(100), static_cast<char>(65));
- test(static_cast<char>(100), static_cast<char>(65), A());
- }
+ test_string(min_allocator<char>());
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp
index d3804479612fac0..74fa76a013a6926 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/string_view.pass.cpp
@@ -24,17 +24,16 @@
static_assert(!std::is_convertible<std::string_view, std::string const&>::value, "");
static_assert(!std::is_convertible<std::string_view, std::string>::value, "");
-template <class charT>
-TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv) {
- typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+template <class Alloc, class CharT>
+TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<CharT> sv) {
+ typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
typedef typename S::traits_type T;
- typedef typename S::allocator_type A;
{
S s2(sv);
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == sv.size());
assert(T::compare(s2.data(), sv.data(), sv.size()) == 0);
- assert(s2.get_allocator() == A());
+ assert(s2.get_allocator() == Alloc());
assert(s2.capacity() >= s2.size());
}
{
@@ -43,14 +42,14 @@ TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv) {
LIBCPP_ASSERT(s2.__invariants());
assert(s2.size() == sv.size());
assert(T::compare(s2.data(), sv.data(), sv.size()) == 0);
- assert(s2.get_allocator() == A());
+ assert(s2.get_allocator() == Alloc());
assert(s2.capacity() >= s2.size());
}
}
-template <class charT, class A>
-TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv, const A& a) {
- typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+template <class Alloc, class CharT>
+TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<CharT> sv, const Alloc& a) {
+ typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
typedef typename S::traits_type T;
{
S s2(sv, a);
@@ -71,40 +70,29 @@ TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv, const A& a) {
}
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- typedef std::basic_string_view<char, std::char_traits<char> > SV;
-
- test(SV(""));
- test(SV(""), A(2));
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ typedef std::basic_string_view<char, std::char_traits<char> > SV;
- test(SV("1"));
- test(SV("1"), A(2));
-
- test(SV("1234567980"));
- test(SV("1234567980"), A(2));
-
- test(SV("123456798012345679801234567980123456798012345679801234567980"));
- test(SV("123456798012345679801234567980123456798012345679801234567980"), A(2));
- }
-#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
- typedef std::basic_string_view<char, std::char_traits<char> > SV;
+ test<Alloc>(SV(""));
+ test<Alloc>(SV(""), Alloc(a));
- test(SV(""));
- test(SV(""), A());
+ test<Alloc>(SV("1"));
+ test<Alloc>(SV("1"), Alloc(a));
- test(SV("1"));
- test(SV("1"), A());
+ test<Alloc>(SV("1234567980"));
+ test<Alloc>(SV("1234567980"), Alloc(a));
- test(SV("1234567980"));
- test(SV("1234567980"), A());
+ test<Alloc>(SV("123456798012345679801234567980123456798012345679801234567980"));
+ test<Alloc>(SV("123456798012345679801234567980123456798012345679801234567980"), Alloc(a));
+}
- test(SV("123456798012345679801234567980123456798012345679801234567980"));
- test(SV("123456798012345679801234567980123456798012345679801234567980"), A());
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(2));
+#if TEST_STD_VER >= 11
+ test_string(min_allocator<char>());
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp
index e8a72708007c383..693edab76b17b0c 100644
--- a/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.cons/substr.pass.cpp
@@ -105,8 +105,8 @@ TEST_CONSTEXPR_CXX20 void test(S str, unsigned pos, unsigned n, const typename S
void test_lwg2583() {
#if TEST_STD_VER >= 11 && !defined(TEST_HAS_NO_EXCEPTIONS)
- typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> StringA;
- std::vector<StringA, std::scoped_allocator_adaptor<test_allocator<StringA>>> vs;
+ typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > StringA;
+ std::vector<StringA, std::scoped_allocator_adaptor<test_allocator<StringA> > > vs;
StringA s{"1234"};
vs.emplace_back(s, 2);
@@ -119,84 +119,51 @@ void test_lwg2583() {
#endif
}
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a1, const Alloc& a2) {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc>;
+
+ test(S(Alloc(a1)), 0);
+ test(S(Alloc(a1)), 1);
+ test(S("1", Alloc(a1)), 0);
+ test(S("1", Alloc(a1)), 1);
+ test(S("1", Alloc(a1)), 2);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 5);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 500);
+
+ test(S(Alloc(a1)), 0, 0);
+ test(S(Alloc(a1)), 0, 1);
+ test(S(Alloc(a1)), 1, 0);
+ test(S(Alloc(a1)), 1, 1);
+ test(S(Alloc(a1)), 1, 2);
+ test(S("1", Alloc(a1)), 0, 0);
+ test(S("1", Alloc(a1)), 0, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 0);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 1);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 10);
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 100);
+
+ test(S(Alloc(a1)), 0, 0, Alloc(a2));
+ test(S(Alloc(a1)), 0, 1, Alloc(a2));
+ test(S(Alloc(a1)), 1, 0, Alloc(a2));
+ test(S(Alloc(a1)), 1, 1, Alloc(a2));
+ test(S(Alloc(a1)), 1, 2, Alloc(a2));
+ test(S("1", Alloc(a1)), 0, 0, Alloc(a2));
+ test(S("1", Alloc(a1)), 0, 1, Alloc(a2));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 0, Alloc(a2));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 1, Alloc(a2));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 10, Alloc(a2));
+ test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 100, Alloc(a2));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
-
- test(S(A(3)), 0);
- test(S(A(3)), 1);
- test(S("1", A(5)), 0);
- test(S("1", A(5)), 1);
- test(S("1", A(5)), 2);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 0);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 5);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 500);
-
- test(S(A(3)), 0, 0);
- test(S(A(3)), 0, 1);
- test(S(A(3)), 1, 0);
- test(S(A(3)), 1, 1);
- test(S(A(3)), 1, 2);
- test(S("1", A(5)), 0, 0);
- test(S("1", A(5)), 0, 1);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100);
-
- test(S(A(3)), 0, 0, A(4));
- test(S(A(3)), 0, 1, A(4));
- test(S(A(3)), 1, 0, A(4));
- test(S(A(3)), 1, 1, A(4));
- test(S(A(3)), 1, 2, A(4));
- test(S("1", A(5)), 0, 0, A(6));
- test(S("1", A(5)), 0, 1, A(6));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0, A(8));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1, A(8));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));
- }
+ test_string(std::allocator<char>(), std::allocator<char>());
+ test_string(test_allocator<char>(), test_allocator<char>());
+ test_string(test_allocator<char>(3), test_allocator<char>(5));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
-
- test(S(A()), 0);
- test(S(A()), 1);
- test(S("1", A()), 0);
- test(S("1", A()), 1);
- test(S("1", A()), 2);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 0);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 5);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 500);
-
- test(S(A()), 0, 0);
- test(S(A()), 0, 1);
- test(S(A()), 1, 0);
- test(S(A()), 1, 1);
- test(S(A()), 1, 2);
- test(S("1", A()), 0, 0);
- test(S("1", A()), 0, 1);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10);
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100);
-
- test(S(A()), 0, 0, A());
- test(S(A()), 0, 1, A());
- test(S(A()), 1, 0, A());
- test(S(A()), 1, 1, A());
- test(S(A()), 1, 2, A());
- test(S("1", A()), 0, 0, A());
- test(S("1", A()), 0, 1, A());
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0, A());
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1, A());
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());
- test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
- }
+ test_string(min_allocator<char>(), min_allocator<char>());
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.contains/contains.char.pass.cpp b/libcxx/test/std/strings/basic.string/string.contains/contains.char.pass.cpp
index 6d632f4921e4c76..658af8e2cd64967 100644
--- a/libcxx/test/std/strings/basic.string/string.contains/contains.char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.contains/contains.char.pass.cpp
@@ -16,9 +16,8 @@
#include "test_macros.h"
-constexpr bool test() {
- using S = std::string;
-
+template <class S>
+constexpr void test_string() {
S s1{};
S s2{"abcde", 5};
@@ -30,6 +29,10 @@ constexpr bool test() {
assert(s2.contains('c'));
assert(s2.contains('e'));
assert(!s2.contains('x'));
+}
+
+constexpr bool test() {
+ test_string<std::string>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.contains/contains.ptr.pass.cpp b/libcxx/test/std/strings/basic.string/string.contains/contains.ptr.pass.cpp
index df5e4007acdf298..99f400fa0c37b38 100644
--- a/libcxx/test/std/strings/basic.string/string.contains/contains.ptr.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.contains/contains.ptr.pass.cpp
@@ -16,9 +16,8 @@
#include "test_macros.h"
-constexpr bool test() {
- using S = std::string;
-
+template <class S>
+constexpr void test_string() {
const char* s = "abcde";
S s0;
S s1{s + 4, 1};
@@ -60,6 +59,10 @@ constexpr bool test() {
assert(!sNot.contains("abcde"));
assert(sNot.contains("xyz"));
assert(!sNot.contains("zyx"));
+}
+
+constexpr bool test() {
+ test_string<std::string>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.contains/contains.string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.contains/contains.string_view.pass.cpp
index 74734d43fd22450..619a718794b14e1 100644
--- a/libcxx/test/std/strings/basic.string/string.contains/contains.string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.contains/contains.string_view.pass.cpp
@@ -16,9 +16,10 @@
#include "test_macros.h"
-constexpr bool test() {
- using S = std::string;
- using SV = std::string_view;
+template <class CharT, template <class> class Alloc>
+constexpr void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view< CharT, std::char_traits<CharT> >;
const char* s = "abcde";
S s0;
@@ -81,6 +82,10 @@ constexpr bool test() {
assert(sNot.contains(svNot));
assert(!sNot.contains(svNot2));
assert(!sNot.contains(svNot3));
+}
+
+constexpr bool test() {
+ test_string<char, std::allocator>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.char.pass.cpp b/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.char.pass.cpp
index 8e540606f38b9f6..a9547ec4f3af3fd 100644
--- a/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.char.pass.cpp
@@ -16,19 +16,21 @@
#include "test_macros.h"
+template <class S>
+constexpr void test_string() {
+ S s1{};
+ S s2{"abcde", 5};
+
+ ASSERT_NOEXCEPT(s1.ends_with('e'));
+
+ assert(!s1.ends_with('e'));
+ assert(!s1.ends_with('x'));
+ assert(s2.ends_with('e'));
+ assert(!s2.ends_with('x'));
+}
+
constexpr bool test() {
- {
- typedef std::string S;
- S s1{};
- S s2{"abcde", 5};
-
- ASSERT_NOEXCEPT(s1.ends_with('e'));
-
- assert(!s1.ends_with('e'));
- assert(!s1.ends_with('x'));
- assert(s2.ends_with('e'));
- assert(!s2.ends_with('x'));
- }
+ test_string<std::string>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.ptr.pass.cpp b/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.ptr.pass.cpp
index 75abb0743268191..23331967d1c730a 100644
--- a/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.ptr.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.ptr.pass.cpp
@@ -16,48 +16,50 @@
#include "test_macros.h"
-constexpr bool test() {
- {
- typedef std::string S;
- const char* s = "abcde";
+template <class S>
+constexpr void test_string() {
+ const char* s = "abcde";
+
+ S s0;
+ S s1{s + 4, 1};
+ S s2{s + 3, 2};
+ // S s3 { s + 2, 3 };
+ // S s4 { s + 1, 4 };
+ // S s5 { s, 5 };
+ S sNot{"def", 3};
- S s0;
- S s1{s + 4, 1};
- S s2{s + 3, 2};
- // S s3 { s + 2, 3 };
- // S s4 { s + 1, 4 };
- // S s5 { s, 5 };
- S sNot{"def", 3};
+ LIBCPP_ASSERT_NOEXCEPT(s0.ends_with(""));
- LIBCPP_ASSERT_NOEXCEPT(s0.ends_with(""));
+ assert(s0.ends_with(""));
+ assert(!s0.ends_with("e"));
- assert(s0.ends_with(""));
- assert(!s0.ends_with("e"));
+ assert(s1.ends_with(""));
+ assert(s1.ends_with("e"));
+ assert(!s1.ends_with("de"));
+ assert(!s1.ends_with("cde"));
+ assert(!s1.ends_with("bcde"));
+ assert(!s1.ends_with("abcde"));
+ assert(!s1.ends_with("def"));
- assert(s1.ends_with(""));
- assert(s1.ends_with("e"));
- assert(!s1.ends_with("de"));
- assert(!s1.ends_with("cde"));
- assert(!s1.ends_with("bcde"));
- assert(!s1.ends_with("abcde"));
- assert(!s1.ends_with("def"));
+ assert(s2.ends_with(""));
+ assert(s2.ends_with("e"));
+ assert(s2.ends_with("de"));
+ assert(!s2.ends_with("cde"));
+ assert(!s2.ends_with("bcde"));
+ assert(!s2.ends_with("abcde"));
+ assert(!s2.ends_with("def"));
- assert(s2.ends_with(""));
- assert(s2.ends_with("e"));
- assert(s2.ends_with("de"));
- assert(!s2.ends_with("cde"));
- assert(!s2.ends_with("bcde"));
- assert(!s2.ends_with("abcde"));
- assert(!s2.ends_with("def"));
+ assert(sNot.ends_with(""));
+ assert(!sNot.ends_with("e"));
+ assert(!sNot.ends_with("de"));
+ assert(!sNot.ends_with("cde"));
+ assert(!sNot.ends_with("bcde"));
+ assert(!sNot.ends_with("abcde"));
+ assert(sNot.ends_with("def"));
+}
- assert(sNot.ends_with(""));
- assert(!sNot.ends_with("e"));
- assert(!sNot.ends_with("de"));
- assert(!sNot.ends_with("cde"));
- assert(!sNot.ends_with("bcde"));
- assert(!sNot.ends_with("abcde"));
- assert(sNot.ends_with("def"));
- }
+constexpr bool test() {
+ test_string<std::string>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.string_view.pass.cpp
index ab0b4f10356d278..683a16a2fc536af 100644
--- a/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ends_with/ends_with.string_view.pass.cpp
@@ -16,57 +16,60 @@
#include "test_macros.h"
+template <class CharT, template <class> class Alloc>
+constexpr void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view< CharT, std::char_traits<CharT> >;
+ const char* s = "abcde";
+
+ S s0;
+ S s1{s + 4, 1};
+ S s2{s + 3, 2};
+ // S s3 { s + 2, 3 };
+ // S s4 { s + 1, 4 };
+ // S s5 { s, 5 };
+ S sNot{"def", 3};
+
+ SV sv0;
+ SV sv1{s + 4, 1};
+ SV sv2{s + 3, 2};
+ SV sv3{s + 2, 3};
+ SV sv4{s + 1, 4};
+ SV sv5{s, 5};
+ SV svNot{"def", 3};
+
+ ASSERT_NOEXCEPT(s0.ends_with(sv0));
+
+ assert(s0.ends_with(sv0));
+ assert(!s0.ends_with(sv1));
+
+ assert(s1.ends_with(sv0));
+ assert(s1.ends_with(sv1));
+ assert(!s1.ends_with(sv2));
+ assert(!s1.ends_with(sv3));
+ assert(!s1.ends_with(sv4));
+ assert(!s1.ends_with(sv5));
+ assert(!s1.ends_with(svNot));
+
+ assert(s2.ends_with(sv0));
+ assert(s2.ends_with(sv1));
+ assert(s2.ends_with(sv2));
+ assert(!s2.ends_with(sv3));
+ assert(!s2.ends_with(sv4));
+ assert(!s2.ends_with(sv5));
+ assert(!s2.ends_with(svNot));
+
+ assert(sNot.ends_with(sv0));
+ assert(!sNot.ends_with(sv1));
+ assert(!sNot.ends_with(sv2));
+ assert(!sNot.ends_with(sv3));
+ assert(!sNot.ends_with(sv4));
+ assert(!sNot.ends_with(sv5));
+ assert(sNot.ends_with(svNot));
+}
+
constexpr bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- const char* s = "abcde";
-
- S s0;
- S s1{s + 4, 1};
- S s2{s + 3, 2};
- // S s3 { s + 2, 3 };
- // S s4 { s + 1, 4 };
- // S s5 { s, 5 };
- S sNot{"def", 3};
-
- SV sv0;
- SV sv1{s + 4, 1};
- SV sv2{s + 3, 2};
- SV sv3{s + 2, 3};
- SV sv4{s + 1, 4};
- SV sv5{s, 5};
- SV svNot{"def", 3};
-
- ASSERT_NOEXCEPT(s0.ends_with(sv0));
-
- assert(s0.ends_with(sv0));
- assert(!s0.ends_with(sv1));
-
- assert(s1.ends_with(sv0));
- assert(s1.ends_with(sv1));
- assert(!s1.ends_with(sv2));
- assert(!s1.ends_with(sv3));
- assert(!s1.ends_with(sv4));
- assert(!s1.ends_with(sv5));
- assert(!s1.ends_with(svNot));
-
- assert(s2.ends_with(sv0));
- assert(s2.ends_with(sv1));
- assert(s2.ends_with(sv2));
- assert(!s2.ends_with(sv3));
- assert(!s2.ends_with(sv4));
- assert(!s2.ends_with(sv5));
- assert(!s2.ends_with(svNot));
-
- assert(sNot.ends_with(sv0));
- assert(!sNot.ends_with(sv1));
- assert(!sNot.ends_with(sv2));
- assert(!sNot.ends_with(sv3));
- assert(!sNot.ends_with(sv4));
- assert(!sNot.ends_with(sv5));
- assert(sNot.ends_with(svNot));
- }
+ test_string<char, std::allocator>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp
index 592ca787c1d6fc3..202a87dd777b3b3 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/begin.pass.cpp
@@ -28,18 +28,16 @@ TEST_CONSTEXPR_CXX20 void test(S s) {
assert(b == cb);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
index 5a0de9d5424ae65..df2c38476197ed1 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/cbegin.pass.cpp
@@ -25,18 +25,16 @@ TEST_CONSTEXPR_CXX20 void test(const S& s) {
assert(cb == s.begin());
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp
index 54b4e2bcedc295c..31d06725e5107db 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/cend.pass.cpp
@@ -22,18 +22,16 @@ TEST_CONSTEXPR_CXX20 void test(const S& s) {
assert(ce == s.end());
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
index a1acf691b73c725..85b33afeb403eb6 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/crbegin.pass.cpp
@@ -25,18 +25,16 @@ TEST_CONSTEXPR_CXX20 void test(const S& s) {
assert(cb == s.rbegin());
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp
index cc63b6bcc608dcc..5d1f90c409bc403 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/crend.pass.cpp
@@ -22,18 +22,16 @@ TEST_CONSTEXPR_CXX20 void test(const S& s) {
assert(ce == s.rend());
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp
index 64f91cae7d33f96..2c3e3b12872157e 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/end.pass.cpp
@@ -31,18 +31,16 @@ TEST_CONSTEXPR_CXX20 void test(S s) {
assert(static_cast<std::size_t>(ce - cs.begin()) == cs.size());
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
index 66bac353e1afe85..feaea2f65790c77 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/rbegin.pass.cpp
@@ -28,18 +28,16 @@ TEST_CONSTEXPR_CXX20 void test(S s) {
assert(b == cb);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp
index 01b2e0165fc7ac3..d34ee26fd9d04b7 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/rend.pass.cpp
@@ -31,18 +31,16 @@ TEST_CONSTEXPR_CXX20 void test(S s) {
assert(static_cast<std::size_t>(ce - cs.rbegin()) == cs.size());
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S());
+ test(S("123"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S());
- test(S("123"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S());
- test(S("123"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/robust_against_adl.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/robust_against_adl.pass.cpp
index fe231d84ddb6707..a02b455ce1fe62c 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/robust_against_adl.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/robust_against_adl.pass.cpp
@@ -26,14 +26,19 @@ struct Charlike {
TEST_CONSTEXPR operator char() const { return ch_; }
};
-TEST_CONSTEXPR_CXX20 bool test() {
- std::string s;
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ S s;
Charlike<Holder<Incomplete> > a[] = {'m', 'a', 'h', 'i'};
s.append(a, a + 4);
s.assign(a, a + 4);
s.insert(s.begin(), a, a + 4);
s.replace(s.begin(), s.begin() + 4, a, a + 4);
assert(s == "mahimahi");
+}
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
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
index 6502e630d92878e..2982cfe77042c0d 100644
--- 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
@@ -53,102 +53,96 @@ TEST_CONSTEXPR_CXX20 void test_exceptions(S s, It first, It last) {
template <class S>
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<const char*>(s), cpp17_input_iterator<const char*>(s), S());
- test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
- test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), S("ABCDEFGHIJ"));
- test(S(),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-
- test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345"));
- test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("12345A"));
- test(S("12345"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 10),
- S("12345ABCDEFGHIJ"));
- test(S("12345"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-
- test(S("1234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("1234567890"));
- test(S("1234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 1),
- S("1234567890A"));
- test(S("1234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 10),
- S("1234567890ABCDEFGHIJ"));
- test(S("1234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-
- test(S("12345678901234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s),
- S("12345678901234567890"));
- test(S("12345678901234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 1),
- S("12345678901234567890"
- "A"));
- test(S("12345678901234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 10),
- S("12345678901234567890"
- "ABCDEFGHIJ"));
- test(S("12345678901234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("12345678901234567890"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-}
-
-TEST_CONSTEXPR_CXX20 bool test() {
- test_string<std::string>();
-#if TEST_STD_VER >= 11
- test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
-#endif
+ {
+ 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<const char*>(s), cpp17_input_iterator<const char*>(s), S());
+ test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
+ test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), S("ABCDEFGHIJ"));
+ test(S(),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345"));
+ test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("12345A"));
+ test(S("12345"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 10),
+ S("12345ABCDEFGHIJ"));
+ test(S("12345"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("1234567890"));
+ test(S("1234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 1),
+ S("1234567890A"));
+ test(S("1234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 10),
+ S("1234567890ABCDEFGHIJ"));
+ test(S("1234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s),
+ S("12345678901234567890"));
+ test(S("12345678901234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 1),
+ S("12345678901234567890"
+ "A"));
+ test(S("12345678901234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 10),
+ S("12345678901234567890"
+ "ABCDEFGHIJ"));
+ test(S("12345678901234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("12345678901234567890"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
#ifndef TEST_HAS_NO_EXCEPTIONS
if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw
- typedef std::string S;
typedef ThrowingIterator<char> TIter;
typedef cpp17_input_iterator<TIter> IIter;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -166,7 +160,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
#endif
{ // test appending to self
- typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
@@ -182,7 +175,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
}
{ // test appending a
diff erent type
- typedef std::string S;
const std::uint8_t p[] = "ABCD";
S s;
@@ -191,23 +183,23 @@ TEST_CONSTEXPR_CXX20 bool test() {
}
{ // regression-test appending to self in sneaky ways
- std::string s_short = "hello";
- std::string s_long = "Lorem ipsum dolor sit amet, consectetur/";
- std::string s_othertype = "hello";
- std::string s_sneaky = "hello";
+ S s_short = "hello";
+ S s_long = "Lorem ipsum dolor sit amet, consectetur/";
+ S s_othertype = "hello";
+ S s_sneaky = "hello";
- test(s_short, s_short.data() + s_short.size(), s_short.data() + s_short.size() + 1, std::string("hello\0", 6));
+ test(s_short, s_short.data() + s_short.size(), s_short.data() + s_short.size() + 1, S("hello\0", 6));
test(s_long,
s_long.data() + s_long.size(),
s_long.data() + s_long.size() + 1,
- std::string("Lorem ipsum dolor sit amet, consectetur/\0", 41));
+ S("Lorem ipsum dolor sit amet, consectetur/\0", 41));
s_sneaky.reserve(12);
- test(s_sneaky, s_sneaky.data(), s_sneaky.data() + 6, std::string("hellohello\0", 11));
+ test(s_sneaky, s_sneaky.data(), s_sneaky.data() + 6, S("hellohello\0", 11));
if (!TEST_IS_CONSTANT_EVALUATED) {
const unsigned char* first = reinterpret_cast<const unsigned char*>(s_othertype.data());
- test(s_othertype, first + 2, first + 5, std::string("hellollo"));
+ test(s_othertype, first + 2, first + 5, S("hellollo"));
}
}
@@ -215,7 +207,7 @@ TEST_CONSTEXPR_CXX20 bool test() {
typedef forward_iterator<const char*> It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
- std::string s;
+ S s;
s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
@@ -223,10 +215,17 @@ TEST_CONSTEXPR_CXX20 bool test() {
typedef const char* It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
- std::string s;
+ S s;
s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
+}
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
index c985d89f88ffad7..0b8e5f65c15e94d 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
@@ -63,22 +63,18 @@ TEST_CONSTEXPR_CXX20 void test(S s, typename S::value_type c, S expected) {
assert(s == expected);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(), 'a', S(1, 'a'));
+ test(S("12345"), 'a', S("12345a"));
+ test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(), 'a', S(1, 'a'));
- test(S("12345"), 'a', S("12345a"));
- test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(), 'a', S(1, 'a'));
- test(S("12345"), 'a', S("12345a"));
- test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
-
{
// https://llvm.org/PR31454
std::basic_string<VeryLarge> s;
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
index baabe167ff17a0f..ba55f30785e94f4 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
@@ -18,18 +18,18 @@
#include "test_macros.h"
#include "min_allocator.h"
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ S s("123");
+ s.assign({'a', 'b', 'c'});
+ assert(s == "abc");
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- std::string s("123");
- s.assign({'a', 'b', 'c'});
- assert(s == "abc");
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s("123");
- s.assign({'a', 'b', 'c'});
- assert(s == "abc");
- }
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
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
index 81e28391dbd68d0..b2ca4fb5ddd9370 100644
--- 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
@@ -53,78 +53,72 @@ void test_exceptions(S s, It first, It last) {
template <class S>
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<const char*>(s), cpp17_input_iterator<const char*>(s), S());
- test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
- test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), S("ABCDEFGHIJ"));
- test(S(),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-
- test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
- test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
- test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), S("ABCDEFGHIJ"));
- test(S("12345"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-
- test(S("1234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
- test(S("1234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
- test(S("1234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 10),
- S("ABCDEFGHIJ"));
- test(S("1234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-
- test(S("12345678901234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
- test(S("12345678901234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 1),
- S("A"));
- test(S("12345678901234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 10),
- S("ABCDEFGHIJ"));
- test(S("12345678901234567890"),
- cpp17_input_iterator<const char*>(s),
- cpp17_input_iterator<const char*>(s + 52),
- S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
-}
-
-TEST_CONSTEXPR_CXX20 bool test() {
- test_string<std::string>();
-#if TEST_STD_VER >= 11
- test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
-#endif
+ {
+ 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<const char*>(s), cpp17_input_iterator<const char*>(s), S());
+ test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
+ test(S(), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), S("ABCDEFGHIJ"));
+ test(S(),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
+ test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
+ test(S("12345"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), S("ABCDEFGHIJ"));
+ test(S("12345"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("1234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
+ test(S("1234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), S("A"));
+ test(S("1234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 10),
+ S("ABCDEFGHIJ"));
+ test(S("1234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+ test(S("12345678901234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
+ test(S("12345678901234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 1),
+ S("A"));
+ test(S("12345678901234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 10),
+ S("ABCDEFGHIJ"));
+ test(S("12345678901234567890"),
+ cpp17_input_iterator<const char*>(s),
+ cpp17_input_iterator<const char*>(s + 52),
+ S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+ }
#ifndef TEST_HAS_NO_EXCEPTIONS
if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw
- typedef std::string S;
typedef ThrowingIterator<char> TIter;
typedef cpp17_input_iterator<TIter> IIter;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -142,7 +136,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
#endif
{ // test assigning to self
- typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
@@ -159,7 +152,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
}
{ // test assigning a
diff erent type
- typedef std::string S;
const std::uint8_t p[] = "ABCD";
S s;
@@ -168,11 +160,19 @@ TEST_CONSTEXPR_CXX20 bool test() {
}
{ // regression-test assigning to self in sneaky ways
- std::string sneaky = "hello";
+ S sneaky = "hello";
sneaky.resize(sneaky.capacity(), 'x');
- std::string expected = sneaky + std::string(1, '\0');
+ S expected = sneaky + S(1, '\0');
test(sneaky, sneaky.data(), sneaky.data() + sneaky.size() + 1, expected);
}
+}
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
+
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
index 6db086e78ed0f40..f39b7f66c4b187a 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
@@ -90,7 +90,9 @@ TEST_CONSTEXPR_CXX20 bool test() {
testAlloc(S(A(5)), S("1"), A());
testAlloc(S(A(5)), S("1", A(7)), A(7));
testAlloc(S(A(5)), S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), A(7));
- testAlloc(S("12345678901234567890", A(5)), S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), A(7));
+ testAlloc(S("12345678901234567890", A(5)),
+ S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)),
+ A(7));
}
#if TEST_STD_VER >= 11
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
index 7da74031f0d4afb..876cc9ecd14c6a8 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
@@ -18,20 +18,17 @@
#include "test_macros.h"
#include "min_allocator.h"
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ S s("123456");
+ typename S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
+ assert(i - s.begin() == 3);
+ assert(s == "123abc456");
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- std::string s("123456");
- std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
- assert(i - s.begin() == 3);
- assert(s == "123abc456");
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s("123456");
- S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
- assert(i - s.begin() == 3);
- assert(s == "123abc456");
- }
+ test_string<std::string>();
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
index 496c484ee20b306..1e03d8c1b614741 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
@@ -23,22 +23,18 @@ TEST_CONSTEXPR_CXX20 void test(S s, typename S::value_type str, S expected) {
assert(s == expected);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(), 'a', S("a"));
+ test(S("12345"), 'a', S("12345a"));
+ test(S("1234567890"), 'a', S("1234567890a"));
+ test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(), 'a', S("a"));
- test(S("12345"), 'a', S("12345a"));
- test(S("1234567890"), 'a', S("1234567890a"));
- test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(), 'a', S("a"));
- test(S("12345"), 'a', S("12345a"));
- test(S("1234567890"), 'a', S("1234567890a"));
- test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
index ce31ebc3bc8ed12..e7334b96276a5f8 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
@@ -18,19 +18,16 @@
#include "test_macros.h"
#include "min_allocator.h"
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- std::string s("123");
- s += {'a', 'b', 'c'};
- assert(s == "123abc");
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s("123");
- s += {'a', 'b', 'c'};
- assert(s == "123abc");
- }
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ S s("123");
+ s += {'a', 'b', 'c'};
+ assert(s == "123abc");
+}
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
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
index 870843192da86bb..e02ced737ae16a2 100644
--- 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
@@ -50,10 +50,7 @@ TEST_CONSTEXPR_CXX20 void test_string() {
TEST_CONSTEXPR_CXX20 bool test() {
test_string<std::string>();
#if TEST_STD_VER >= 11
- test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
-#endif
-
-#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // LWG 2946
std::string s;
s += {"abc", 1};
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
index dc6f191e106c6fc..efc21725ee24cde 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
@@ -18,18 +18,16 @@
#include "test_macros.h"
#include "min_allocator.h"
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ S s("123def456");
+ s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
+ assert(s == "123abc456");
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- std::string s("123def456");
- s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
- assert(s == "123abc456");
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- S s("123def456");
- s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
- assert(s == "123abc456");
- }
+ test_string<std::string>();
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
index 79c3bce081acf24..fa13ca8062b2a32 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
@@ -283,35 +283,23 @@ TEST_CONSTEXPR_CXX20 bool test2() {
return true;
}
+template <class S>
TEST_CONSTEXPR_CXX20 void test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
+ test0<S>();
+ test1<S>();
+ test2<S>();
#if TEST_STD_VER > 17
- static_assert(test0<S>());
- static_assert(test1<S>());
- static_assert(test2<S>());
-#endif
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
-# if TEST_STD_VER > 17
- static_assert(test0<S>());
- static_assert(test1<S>());
- static_assert(test2<S>());
-# endif
- }
+ static_assert(test0<S>());
+ static_assert(test1<S>());
+ static_assert(test2<S>());
#endif
}
int main(int, char**) {
- test();
+ test<std::string>();
+#if TEST_STD_VER >= 11
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
index 1bade1f7025bc39..dd87da1e2535463 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
@@ -38,7 +38,7 @@ test(S s,
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test0() {
+TEST_CONSTEXPR_CXX20 bool test0() {
test(S(""), 0, 0, 0, '3', S(""));
test(S(""), 0, 0, 5, '3', S("33333"));
test(S(""), 0, 0, 10, '3', S("3333333333"));
@@ -139,10 +139,11 @@ TEST_CONSTEXPR_CXX20 void test0() {
test(S("abcdefghij"), 1, 1, 5, '3', S("a33333cdefghij"));
test(S("abcdefghij"), 1, 1, 10, '3', S("a3333333333cdefghij"));
test(S("abcdefghij"), 1, 1, 20, '3', S("a33333333333333333333cdefghij"));
+ return true;
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test1() {
+TEST_CONSTEXPR_CXX20 bool test1() {
test(S("abcdefghij"), 1, 4, 0, '3', S("afghij"));
test(S("abcdefghij"), 1, 4, 5, '3', S("a33333fghij"));
test(S("abcdefghij"), 1, 4, 10, '3', S("a3333333333fghij"));
@@ -243,10 +244,11 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("abcdefghijklmnopqrst"), 10, 9, 5, '3', S("abcdefghij33333t"));
test(S("abcdefghijklmnopqrst"), 10, 9, 10, '3', S("abcdefghij3333333333t"));
test(S("abcdefghijklmnopqrst"), 10, 9, 20, '3', S("abcdefghij33333333333333333333t"));
+ return true;
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test2() {
+TEST_CONSTEXPR_CXX20 bool test2() {
test(S("abcdefghijklmnopqrst"), 10, 10, 0, '3', S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 10, 10, 5, '3', S("abcdefghij33333"));
test(S("abcdefghijklmnopqrst"), 10, 10, 10, '3', S("abcdefghij3333333333"));
@@ -263,31 +265,26 @@ TEST_CONSTEXPR_CXX20 void test2() {
test(S("abcdefghijklmnopqrst"), 20, 0, 5, '3', S("abcdefghijklmnopqrst33333"));
test(S("abcdefghijklmnopqrst"), 20, 0, 10, '3', S("abcdefghijklmnopqrst3333333333"));
test(S("abcdefghijklmnopqrst"), 20, 0, 20, '3', S("abcdefghijklmnopqrst33333333333333333333"));
+ return true;
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- }
-#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
- return true;
+#if TEST_STD_VER > 17
+ static_assert(test0<S>());
+ static_assert(test1<S>());
+ static_assert(test2<S>());
+#endif
}
int main(int, char**) {
- test();
-#if TEST_STD_VER > 17
- static_assert(test());
+ test<std::string>();
+#if TEST_STD_VER >= 11
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp
index bd97872707f3f2b..767ed41ae22477b 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string_view.pass.cpp
@@ -265,37 +265,25 @@ TEST_CONSTEXPR_CXX20 bool test2() {
return true;
}
+template <class CharT, template <class> class Alloc>
TEST_CONSTEXPR_CXX20 void test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- test2<S, SV>();
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test0<S, SV>();
+ test1<S, SV>();
+ test2<S, SV>();
#if TEST_STD_VER > 17
- static_assert(test0<S, SV>());
- static_assert(test1<S, SV>());
- static_assert(test2<S, SV>());
-#endif
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- test2<S, SV>();
-# if TEST_STD_VER > 17
- static_assert(test0<S, SV>());
- static_assert(test1<S, SV>());
- static_assert(test2<S, SV>());
-# endif
- }
+ static_assert(test0<S, SV>());
+ static_assert(test1<S, SV>());
+ static_assert(test2<S, SV>());
#endif
}
int main(int, char**) {
- test();
+ test<char, std::allocator>();
+#if TEST_STD_VER >= 11
+ test<char, min_allocator>();
+#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
index 6ecefa0187553bd..004a51926285394 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
@@ -6154,8 +6154,10 @@ TEST_CONSTEXPR_CXX20 bool test56() {
return true;
}
-template <class S, class SV>
-TEST_CONSTEXPR_CXX20 bool test() {
+template <class CharT, template <class> class Alloc>
+void test() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
test0<S, SV>();
test1<S, SV>();
test2<S, SV>();
@@ -6271,15 +6273,12 @@ TEST_CONSTEXPR_CXX20 bool test() {
static_assert(test54<S, SV>());
static_assert(test55<S, SV>());
#endif
-
- return true;
}
int main(int, char**) {
- test<std::string, std::string_view>();
+ test<char, std::allocator>();
#if TEST_STD_VER >= 11
- test<std::basic_string<char, std::char_traits<char>, min_allocator<char>>,
- std::basic_string_view<char, std::char_traits<char>>>();
+ test<char, min_allocator>();
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
index 00e8a901c332760..073de60289857ae 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
@@ -5977,7 +5977,7 @@ TEST_CONSTEXPR_CXX20 bool test55() {
}
template <class S>
-void test() {
+TEST_CONSTEXPR_CXX20 void test() {
test0<S>();
test1<S>();
test2<S>();
@@ -6098,7 +6098,7 @@ void test() {
int main(int, char**) {
test<std::string>();
#if TEST_STD_VER >= 11
- test<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp
index 1e9965511f14a3d..cec8cc0c52dd9f3 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_view.pass.cpp
@@ -358,25 +358,24 @@ TEST_CONSTEXPR_CXX20 bool test2() {
return true;
}
-template <class S>
+template <class CharT, template <class> class Alloc>
void test() {
- {
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- test2<S, SV>();
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test0<S, SV>();
+ test1<S, SV>();
+ test2<S, SV>();
#if TEST_STD_VER > 17
- static_assert(test0<S, SV>());
- static_assert(test1<S, SV>());
- static_assert(test2<S, SV>());
+ static_assert(test0<S, SV>());
+ static_assert(test1<S, SV>());
+ static_assert(test2<S, SV>());
#endif
- }
}
int main(int, char**) {
- test<std::string>();
+ test<char, std::allocator>();
#if TEST_STD_VER >= 11
- test<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
+ test<char, min_allocator>();
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
index 1a1981fe89f4644..7bcb34135440bfb 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
@@ -20,38 +20,13 @@
#include "min_allocator.h"
#include "test_macros.h"
-int main(int, char**) {
- {
- std::istringstream in(" abc\n def\n ghij");
- std::string s("initial text");
- std::getline(in, s);
- assert(in.good());
- assert(s == " abc");
- std::getline(in, s);
- assert(in.good());
- assert(s == " def");
- std::getline(in, s);
- assert(in.eof());
- assert(s == " ghij");
- }
+template <template <class> class Alloc>
+void test_string() {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc<char> >;
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- {
- std::wistringstream in(L" abc\n def\n ghij");
- std::wstring s(L"initial text");
- std::getline(in, s);
- assert(in.good());
- assert(s == L" abc");
- std::getline(in, s);
- assert(in.good());
- assert(s == L" def");
- std::getline(in, s);
- assert(in.eof());
- assert(s == L" ghij");
- }
+ using WS = std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> >;
#endif
-#if TEST_STD_VER >= 11
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in(" abc\n def\n ghij");
S s("initial text");
std::getline(in, s);
@@ -64,11 +39,10 @@ int main(int, char**) {
assert(in.eof());
assert(s == " ghij");
}
-# ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L" abc\n def\n ghij");
- S s(L"initial text");
+ WS s(L"initial text");
std::getline(in, s);
assert(in.good());
assert(s == L" abc");
@@ -79,15 +53,15 @@ int main(int, char**) {
assert(in.eof());
assert(s == L" ghij");
}
-# endif // TEST_HAS_NO_WIDE_CHARACTERS
-#endif // TEST_STD_VER >= 11
+#endif
+
#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::basic_stringbuf<char> sb("hello");
std::basic_istream<char> is(&sb);
is.exceptions(std::ios_base::eofbit);
- std::basic_string<char> s;
+ S s;
bool threw = false;
try {
std::getline(is, s);
@@ -107,7 +81,7 @@ int main(int, char**) {
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios_base::eofbit);
- std::basic_string<wchar_t> s;
+ WS s;
bool threw = false;
try {
std::getline(is, s);
@@ -128,7 +102,7 @@ int main(int, char**) {
std::basic_istream<char> is(&sb);
is.exceptions(std::ios_base::failbit);
- std::basic_string<char> s;
+ S s;
bool threw = false;
try {
std::getline(is, s);
@@ -148,7 +122,7 @@ int main(int, char**) {
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios_base::failbit);
- std::basic_string<wchar_t> s;
+ WS s;
bool threw = false;
try {
std::getline(is, s);
@@ -164,6 +138,13 @@ int main(int, char**) {
}
# endif
#endif // TEST_HAS_NO_EXCEPTIONS
+}
+
+int main(int, char**) {
+ test_string<std::allocator>();
+#if TEST_STD_VER >= 11
+ test_string<min_allocator>();
+#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
index 00abd249f15d302..97a55fa09d14df0 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
@@ -20,44 +20,14 @@
#include "min_allocator.h"
#include "test_macros.h"
-int main(int, char**) {
- {
- std::istringstream in(" abc* def** ghij");
- std::string s("initial text");
- std::getline(in, s, '*');
- assert(in.good());
- assert(s == " abc");
- std::getline(in, s, '*');
- assert(in.good());
- assert(s == " def");
- std::getline(in, s, '*');
- assert(in.good());
- assert(s == "");
- std::getline(in, s, '*');
- assert(in.eof());
- assert(s == " ghij");
- }
+template <template <class> class Alloc>
+void test_string() {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc<char> >;
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- {
- std::wistringstream in(L" abc* def** ghij");
- std::wstring s(L"initial text");
- std::getline(in, s, L'*');
- assert(in.good());
- assert(s == L" abc");
- std::getline(in, s, L'*');
- assert(in.good());
- assert(s == L" def");
- std::getline(in, s, L'*');
- assert(in.good());
- assert(s == L"");
- std::getline(in, s, L'*');
- assert(in.eof());
- assert(s == L" ghij");
- }
+ using WS = std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> >;
#endif
-#if TEST_STD_VER >= 11
+
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in(" abc* def** ghij");
S s("initial text");
std::getline(in, s, '*');
@@ -73,11 +43,10 @@ int main(int, char**) {
assert(in.eof());
assert(s == " ghij");
}
-# ifndef TEST_HAS_NO_WIDE_CHARACTERS
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L" abc* def** ghij");
- S s(L"initial text");
+ WS s(L"initial text");
std::getline(in, s, L'*');
assert(in.good());
assert(s == L" abc");
@@ -91,15 +60,15 @@ int main(int, char**) {
assert(in.eof());
assert(s == L" ghij");
}
-# endif // TEST_HAS_NO_WIDE_CHARACTERS
-#endif // TEST_STD_VER >= 11
+#endif
+
#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::basic_stringbuf<char> sb("hello");
std::basic_istream<char> is(&sb);
is.exceptions(std::ios::eofbit);
- std::basic_string<char> s;
+ S s;
bool threw = false;
try {
std::getline(is, s, '\n');
@@ -119,7 +88,7 @@ int main(int, char**) {
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios::eofbit);
- std::basic_string<wchar_t> s;
+ WS s;
bool threw = false;
try {
std::getline(is, s, L'\n');
@@ -139,7 +108,7 @@ int main(int, char**) {
std::basic_istream<char> is(&sb);
is.exceptions(std::ios::failbit);
- std::basic_string<char> s;
+ S s;
bool threw = false;
try {
std::getline(is, s, '\n');
@@ -159,7 +128,7 @@ int main(int, char**) {
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios::failbit);
- std::basic_string<wchar_t> s;
+ WS s;
bool threw = false;
try {
std::getline(is, s, L'\n');
@@ -175,6 +144,12 @@ int main(int, char**) {
}
# endif // TEST_HAS_NO_WIDE_CHARACTERS
#endif // TEST_HAS_NO_EXCEPTIONS
+}
+int main(int, char**) {
+ test_string<std::allocator>();
+#if TEST_STD_VER >= 11
+ test_string<min_allocator>();
+#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
index f195d0aebe5efb2..1cd50a4c8940c75 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
@@ -20,33 +20,29 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
- {
- std::string s("initial text");
- std::getline(std::istringstream(" abc* def* ghij"), s, '*');
- assert(s == " abc");
- }
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+template <template <class> class Alloc>
+void test() {
{
- std::wstring s(L"initial text");
- std::getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
- assert(s == L" abc");
- }
-#endif
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ using S = std::basic_string<char, std::char_traits<char>, Alloc<char> >;
S s("initial text");
std::getline(std::istringstream(" abc* def* ghij"), s, '*');
assert(s == " abc");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t> > S;
- S s(L"initial text");
+ using WS = std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> >;
+ WS s(L"initial text");
std::getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
assert(s == L" abc");
}
#endif
+}
+
+int main(int, char**) {
+ test<std::allocator>();
+#if TEST_STD_VER >= 11
+ test<min_allocator>();
+#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
index 57802a08f1001ea..ff100f9234bef0e 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
@@ -20,33 +20,27 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
- {
- std::string s("initial text");
- std::getline(std::istringstream(" abc\n def\n ghij"), s);
- assert(s == " abc");
- }
-#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- {
- std::wstring s(L"initial text");
- std::getline(std::wistringstream(L" abc\n def\n ghij"), s);
- assert(s == L" abc");
- }
-#endif
+template <template <class> class Alloc>
+void test() {
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
+ using S = std::basic_string<char, std::char_traits<char>, Alloc<char> >;
S s("initial text");
std::getline(std::istringstream(" abc\n def\n ghij"), s);
assert(s == " abc");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t> > S;
- S s(L"initial text");
+ using WS = std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> >;
+ WS s(L"initial text");
std::getline(std::wistringstream(L" abc\n def\n ghij"), s);
assert(s == L" abc");
}
#endif
+}
+
+int main(int, char**) {
+ test<std::allocator>();
+ test<min_allocator>();
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
index b5d0184c78f85df..fde4990c9cafb24 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
@@ -20,10 +20,12 @@
#include "min_allocator.h"
#include "test_macros.h"
-int main(int, char**) {
+template <template <class> class Alloc>
+void test_string() {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc<char> >;
{
std::istringstream in("a bc defghij");
- std::string s("initial text");
+ S s("initial text");
in >> s;
assert(in.good());
assert(s == "a");
@@ -45,8 +47,9 @@ int main(int, char**) {
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
+ using WS = std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> >;
std::wistringstream in(L"a bc defghij");
- std::wstring s(L"initial text");
+ WS s(L"initial text");
in >> s;
assert(in.good());
assert(s == L"a");
@@ -67,6 +70,7 @@ int main(int, char**) {
assert(in.fail());
}
#endif
+
#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::stringbuf sb;
@@ -75,7 +79,7 @@ int main(int, char**) {
bool threw = false;
try {
- std::string s;
+ S s;
is >> s;
} catch (std::ios::failure const&) {
threw = true;
@@ -93,7 +97,7 @@ int main(int, char**) {
bool threw = false;
try {
- std::string s;
+ S s;
is >> s;
} catch (std::ios::failure const&) {
threw = true;
@@ -105,56 +109,13 @@ int main(int, char**) {
assert(threw);
}
#endif // TEST_HAS_NO_EXCEPTIONS
+}
+
+int main(int, char**) {
+ test_string<std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- std::istringstream in("a bc defghij");
- S s("initial text");
- in >> s;
- assert(in.good());
- assert(s == "a");
- assert(in.peek() == ' ');
- in >> s;
- assert(in.good());
- assert(s == "bc");
- assert(in.peek() == ' ');
- in.width(3);
- in >> s;
- assert(in.good());
- assert(s == "def");
- assert(in.peek() == 'g');
- in >> s;
- assert(in.eof());
- assert(s == "ghij");
- in >> s;
- assert(in.fail());
- }
-# ifndef TEST_HAS_NO_WIDE_CHARACTERS
- {
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
- std::wistringstream in(L"a bc defghij");
- S s(L"initial text");
- in >> s;
- assert(in.good());
- assert(s == L"a");
- assert(in.peek() == L' ');
- in >> s;
- assert(in.good());
- assert(s == L"bc");
- assert(in.peek() == L' ');
- in.width(3);
- in >> s;
- assert(in.good());
- assert(s == L"def");
- assert(in.peek() == L'g');
- in >> s;
- assert(in.eof());
- assert(s == L"ghij");
- in >> s;
- assert(in.fail());
- }
-# endif // TEST_HAS_NO_WIDE_CHARACTERS
-#endif // TEST_STD_VER >= 11
+ test_string<min_allocator>();
+#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
index ae6cb3d2e92ab6c..c66f15213ff2f03 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
@@ -20,77 +20,52 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+template <template <class> class Alloc>
+void test() {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc<char> >;
+ using OS = std::basic_ostringstream<char, std::char_traits<char>, Alloc<char> >;
{
- std::ostringstream out;
- std::string s("some text");
+ OS out;
+ S s("some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
- std::ostringstream out;
- std::string s("some text");
+ OS out;
+ S s("some text");
out.width(12);
out << s;
assert(out.good());
assert(" " + s == out.str());
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+ using WS = std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> >;
+ using WOS = std::basic_ostringstream<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> >;
{
- std::wostringstream out;
- std::wstring s(L"some text");
+ WOS out;
+ WS s(L"some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
- std::wostringstream out;
- std::wstring s(L"some text");
+ WOS out;
+ WS s(L"some text");
out.width(12);
out << s;
assert(out.good());
assert(L" " + s == out.str());
}
#endif
+}
+
+int main(int, char**) {
+ test<std::allocator>();
+
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
- S s("some text");
- out << s;
- assert(out.good());
- assert(s == out.str());
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
- S s("some text");
- out.width(12);
- out << s;
- assert(out.good());
- assert(" " + s == out.str());
- }
-# ifndef TEST_HAS_NO_WIDE_CHARACTERS
- {
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
- std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
- S s(L"some text");
- out << s;
- assert(out.good());
- assert(s == out.str());
- }
- {
- typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
- std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
- S s(L"some text");
- out.width(12);
- out << s;
- assert(out.good());
- assert(L" " + s == out.str());
- }
-# endif // TEST_HAS_NO_WIDE_CHARACTERS
-#endif // TEST_STD_VER >= 11
+ test<min_allocator>();
+#endif
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
index 8dc8c70fb36cfc7..da6fc11c14329f4 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
@@ -31,46 +31,30 @@ TEST_CONSTEXPR_CXX20 void test(S s1, S s2) {
assert(s2 == s1_);
}
+template <class S>
+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<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), S(""));
- test(S(""), S("12345"));
- test(S(""), S("1234567890"));
- test(S(""), S("12345678901234567890"));
- test(S("abcde"), S(""));
- test(S("abcde"), S("12345"));
- test(S("abcde"), S("1234567890"));
- test(S("abcde"), S("12345678901234567890"));
- test(S("abcdefghij"), S(""));
- test(S("abcdefghij"), S("12345"));
- test(S("abcdefghij"), S("1234567890"));
- test(S("abcdefghij"), S("12345678901234567890"));
- test(S("abcdefghijklmnopqrst"), S(""));
- test(S("abcdefghijklmnopqrst"), S("12345"));
- test(S("abcdefghijklmnopqrst"), S("1234567890"));
- test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
index da06df99a13797a..82a591e0533628d 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
@@ -35,34 +35,24 @@ TEST_CONSTEXPR_CXX20 void test1(typename S::value_type lhs, S&& rhs, const S& x)
}
#endif
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0('a', S(""), S("a"));
- test0('a', S("12345"), S("a12345"));
- test0('a', S("1234567890"), S("a1234567890"));
- test0('a', S("12345678901234567890"), S("a12345678901234567890"));
- }
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0('a', S(""), S("a"));
+ test0('a', S("12345"), S("a12345"));
+ test0('a', S("1234567890"), S("a1234567890"));
+ test0('a', S("12345678901234567890"), S("a12345678901234567890"));
#if TEST_STD_VER >= 11
- {
- typedef std::string S;
- test1('a', S(""), S("a"));
- test1('a', S("12345"), S("a12345"));
- test1('a', S("1234567890"), S("a1234567890"));
- test1('a', S("12345678901234567890"), S("a12345678901234567890"));
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- test0('a', S(""), S("a"));
- test0('a', S("12345"), S("a12345"));
- test0('a', S("1234567890"), S("a1234567890"));
- test0('a', S("12345678901234567890"), S("a12345678901234567890"));
+ test1('a', S(""), S("a"));
+ test1('a', S("12345"), S("a12345"));
+ test1('a', S("1234567890"), S("a1234567890"));
+ test1('a', S("12345678901234567890"), S("a12345678901234567890"));
+#endif
+}
- test1('a', S(""), S("a"));
- test1('a', S("12345"), S("a12345"));
- test1('a', S("1234567890"), S("a1234567890"));
- test1('a', S("12345678901234567890"), S("a12345678901234567890"));
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#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
index 0dc5a06b1ac0836..fa14f657d8269c3 100644
--- 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
@@ -35,83 +35,49 @@ TEST_CONSTEXPR_CXX20 void test1(const typename S::value_type* lhs, S&& rhs, cons
}
#endif
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0("", S(""), S(""));
- test0("", S("12345"), S("12345"));
- test0("", S("1234567890"), S("1234567890"));
- test0("", S("12345678901234567890"), S("12345678901234567890"));
- test0("abcde", S(""), S("abcde"));
- test0("abcde", S("12345"), S("abcde12345"));
- test0("abcde", S("1234567890"), S("abcde1234567890"));
- test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
- test0("abcdefghij", S(""), S("abcdefghij"));
- test0("abcdefghij", S("12345"), S("abcdefghij12345"));
- test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
- test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
- test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
- test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
- }
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0("", S(""), S(""));
+ test0("", S("12345"), S("12345"));
+ test0("", S("1234567890"), S("1234567890"));
+ test0("", S("12345678901234567890"), S("12345678901234567890"));
+ test0("abcde", S(""), S("abcde"));
+ test0("abcde", S("12345"), S("abcde12345"));
+ test0("abcde", S("1234567890"), S("abcde1234567890"));
+ test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+ test0("abcdefghij", S(""), S("abcdefghij"));
+ test0("abcdefghij", S("12345"), S("abcdefghij12345"));
+ test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+ test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+ test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+ test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#if TEST_STD_VER >= 11
- {
- typedef std::string S;
- test1("", S(""), S(""));
- test1("", S("12345"), S("12345"));
- test1("", S("1234567890"), S("1234567890"));
- test1("", S("12345678901234567890"), S("12345678901234567890"));
- test1("abcde", S(""), S("abcde"));
- test1("abcde", S("12345"), S("abcde12345"));
- test1("abcde", S("1234567890"), S("abcde1234567890"));
- test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
- test1("abcdefghij", S(""), S("abcdefghij"));
- test1("abcdefghij", S("12345"), S("abcdefghij12345"));
- test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
- test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
- test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
- test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- test0("", S(""), S(""));
- test0("", S("12345"), S("12345"));
- test0("", S("1234567890"), S("1234567890"));
- test0("", S("12345678901234567890"), S("12345678901234567890"));
- test0("abcde", S(""), S("abcde"));
- test0("abcde", S("12345"), S("abcde12345"));
- test0("abcde", S("1234567890"), S("abcde1234567890"));
- test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
- test0("abcdefghij", S(""), S("abcdefghij"));
- test0("abcdefghij", S("12345"), S("abcdefghij12345"));
- test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
- test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
- test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
- test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+ test1("", S(""), S(""));
+ test1("", S("12345"), S("12345"));
+ test1("", S("1234567890"), S("1234567890"));
+ test1("", S("12345678901234567890"), S("12345678901234567890"));
+ test1("abcde", S(""), S("abcde"));
+ test1("abcde", S("12345"), S("abcde12345"));
+ test1("abcde", S("1234567890"), S("abcde1234567890"));
+ test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+ test1("abcdefghij", S(""), S("abcdefghij"));
+ test1("abcdefghij", S("12345"), S("abcdefghij12345"));
+ test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+ test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+ test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+ test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+#endif
+}
- test1("", S(""), S(""));
- test1("", S("12345"), S("12345"));
- test1("", S("1234567890"), S("1234567890"));
- test1("", S("12345678901234567890"), S("12345678901234567890"));
- test1("abcde", S(""), S("abcde"));
- test1("abcde", S("12345"), S("abcde12345"));
- test1("abcde", S("1234567890"), S("abcde1234567890"));
- test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
- test1("abcdefghij", S(""), S("abcdefghij"));
- test1("abcdefghij", S("12345"), S("abcdefghij12345"));
- test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
- test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
- test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
- test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
index bc6ac71ec95d926..66cbac28f9f2c3a 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
@@ -35,34 +35,26 @@ TEST_CONSTEXPR_CXX20 void test1(S&& lhs, typename S::value_type rhs, const S& x)
}
#endif
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0(S(""), '1', S("1"));
- test0(S("abcde"), '1', S("abcde1"));
- test0(S("abcdefghij"), '1', S("abcdefghij1"));
- test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
- }
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0(S(""), '1', S("1"));
+ test0(S(""), '1', S("1"));
+ test0(S("abcde"), '1', S("abcde1"));
+ test0(S("abcdefghij"), '1', S("abcdefghij1"));
+ test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
#if TEST_STD_VER >= 11
- {
- typedef std::string S;
- test1(S(""), '1', S("1"));
- test1(S("abcde"), '1', S("abcde1"));
- test1(S("abcdefghij"), '1', S("abcdefghij1"));
- test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- test0(S(""), '1', S("1"));
- test0(S("abcde"), '1', S("abcde1"));
- test0(S("abcdefghij"), '1', S("abcdefghij1"));
- test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+ test1(S(""), '1', S("1"));
+ test1(S("abcde"), '1', S("abcde1"));
+ test1(S("abcdefghij"), '1', S("abcdefghij1"));
+ test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+#endif
+}
- test1(S(""), '1', S("1"));
- test1(S("abcde"), '1', S("abcde1"));
- test1(S("abcdefghij"), '1', S("abcdefghij1"));
- test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#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
index d3f229343611912..2802189f843c59c 100644
--- 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
@@ -35,82 +35,48 @@ TEST_CONSTEXPR_CXX20 void test1(S&& lhs, const typename S::value_type* rhs, cons
}
#endif
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0(S(""), "", S(""));
- test0(S(""), "12345", S("12345"));
- test0(S(""), "1234567890", S("1234567890"));
- test0(S(""), "12345678901234567890", S("12345678901234567890"));
- test0(S("abcde"), "", S("abcde"));
- test0(S("abcde"), "12345", S("abcde12345"));
- test0(S("abcde"), "1234567890", S("abcde1234567890"));
- test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
- test0(S("abcdefghij"), "", S("abcdefghij"));
- test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
- test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
- test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
- test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
- test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
- test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
- test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
- }
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0(S(""), "", S(""));
+ test0(S(""), "12345", S("12345"));
+ test0(S(""), "1234567890", S("1234567890"));
+ test0(S(""), "12345678901234567890", S("12345678901234567890"));
+ test0(S("abcde"), "", S("abcde"));
+ test0(S("abcde"), "12345", S("abcde12345"));
+ test0(S("abcde"), "1234567890", S("abcde1234567890"));
+ test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+ test0(S("abcdefghij"), "", S("abcdefghij"));
+ test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
+ test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+ test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+ test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+ test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#if TEST_STD_VER >= 11
- {
- typedef std::string S;
- test1(S(""), "", S(""));
- test1(S(""), "12345", S("12345"));
- test1(S(""), "1234567890", S("1234567890"));
- test1(S(""), "12345678901234567890", S("12345678901234567890"));
- test1(S("abcde"), "", S("abcde"));
- test1(S("abcde"), "12345", S("abcde12345"));
- test1(S("abcde"), "1234567890", S("abcde1234567890"));
- test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
- test1(S("abcdefghij"), "", S("abcdefghij"));
- test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
- test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
- test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
- test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
- test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
- test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
- test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- test0(S(""), "", S(""));
- test0(S(""), "12345", S("12345"));
- test0(S(""), "1234567890", S("1234567890"));
- test0(S(""), "12345678901234567890", S("12345678901234567890"));
- test0(S("abcde"), "", S("abcde"));
- test0(S("abcde"), "12345", S("abcde12345"));
- test0(S("abcde"), "1234567890", S("abcde1234567890"));
- test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
- test0(S("abcdefghij"), "", S("abcdefghij"));
- test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
- test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
- test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
- test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
- test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
- test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
- test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+ test1(S(""), "", S(""));
+ test1(S(""), "12345", S("12345"));
+ test1(S(""), "1234567890", S("1234567890"));
+ test1(S(""), "12345678901234567890", S("12345678901234567890"));
+ test1(S("abcde"), "", S("abcde"));
+ test1(S("abcde"), "12345", S("abcde12345"));
+ test1(S("abcde"), "1234567890", S("abcde1234567890"));
+ test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+ test1(S("abcdefghij"), "", S("abcdefghij"));
+ test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
+ test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+ test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+ test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+ test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+ test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+ test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+#endif
+}
- test1(S(""), "", S(""));
- test1(S(""), "12345", S("12345"));
- test1(S(""), "1234567890", S("1234567890"));
- test1(S(""), "12345678901234567890", S("12345678901234567890"));
- test1(S("abcde"), "", S("abcde"));
- test1(S("abcde"), "12345", S("abcde12345"));
- test1(S("abcde"), "1234567890", S("abcde1234567890"));
- test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
- test1(S("abcdefghij"), "", S("abcdefghij"));
- test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
- test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
- test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
- test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
- test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
- test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
- test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#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
index fe03ba1e7c2725f..f8ebb98767a8375 100644
--- 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
@@ -57,151 +57,83 @@ TEST_CONSTEXPR_CXX20 void test3(S&& lhs, S&& rhs, const S& x) {
}
#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0(S(""), S(""), S(""));
+ test0(S(""), S("12345"), S("12345"));
+ test0(S(""), S("1234567890"), S("1234567890"));
+ test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test0(S("abcde"), S(""), S("abcde"));
+ test0(S("abcde"), S("12345"), S("abcde12345"));
+ test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test0(S("abcdefghij"), S(""), S("abcdefghij"));
+ test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+#if TEST_STD_VER >= 11
+ test1(S(""), S(""), S(""));
+ test1(S(""), S("12345"), S("12345"));
+ test1(S(""), S("1234567890"), S("1234567890"));
+ test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test1(S("abcde"), S(""), S("abcde"));
+ test1(S("abcde"), S("12345"), S("abcde12345"));
+ test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test1(S("abcdefghij"), S(""), S("abcdefghij"));
+ test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+ test2(S(""), S(""), S(""));
+ test2(S(""), S("12345"), S("12345"));
+ test2(S(""), S("1234567890"), S("1234567890"));
+ test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test2(S("abcde"), S(""), S("abcde"));
+ test2(S("abcde"), S("12345"), S("abcde12345"));
+ test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test2(S("abcdefghij"), S(""), S("abcdefghij"));
+ test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+ test3(S(""), S(""), S(""));
+ test3(S(""), S("12345"), S("12345"));
+ test3(S(""), S("1234567890"), S("1234567890"));
+ test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
+ test3(S("abcde"), S(""), S("abcde"));
+ test3(S("abcde"), S("12345"), S("abcde12345"));
+ test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
+ test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+ test3(S("abcdefghij"), S(""), S("abcdefghij"));
+ test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+ test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+ test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+ test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+ test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+ test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+ test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+#endif
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0(S(""), S(""), S(""));
- test0(S(""), S("12345"), S("12345"));
- test0(S(""), S("1234567890"), S("1234567890"));
- test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test0(S("abcde"), S(""), S("abcde"));
- test0(S("abcde"), S("12345"), S("abcde12345"));
- test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test0(S("abcdefghij"), S(""), S("abcdefghij"));
- test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::string S;
- test1(S(""), S(""), S(""));
- test1(S(""), S("12345"), S("12345"));
- test1(S(""), S("1234567890"), S("1234567890"));
- test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test1(S("abcde"), S(""), S("abcde"));
- test1(S("abcde"), S("12345"), S("abcde12345"));
- test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test1(S("abcdefghij"), S(""), S("abcdefghij"));
- test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
-
- test2(S(""), S(""), S(""));
- test2(S(""), S("12345"), S("12345"));
- test2(S(""), S("1234567890"), S("1234567890"));
- test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test2(S("abcde"), S(""), S("abcde"));
- test2(S("abcde"), S("12345"), S("abcde12345"));
- test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test2(S("abcdefghij"), S(""), S("abcdefghij"));
- test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
-
- test3(S(""), S(""), S(""));
- test3(S(""), S("12345"), S("12345"));
- test3(S(""), S("1234567890"), S("1234567890"));
- test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test3(S("abcde"), S(""), S("abcde"));
- test3(S("abcde"), S("12345"), S("abcde12345"));
- test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test3(S("abcdefghij"), S(""), S("abcdefghij"));
- test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
- }
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
- test0(S(""), S(""), S(""));
- test0(S(""), S("12345"), S("12345"));
- test0(S(""), S("1234567890"), S("1234567890"));
- test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test0(S("abcde"), S(""), S("abcde"));
- test0(S("abcde"), S("12345"), S("abcde12345"));
- test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test0(S("abcdefghij"), S(""), S("abcdefghij"));
- test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
-
- test1(S(""), S(""), S(""));
- test1(S(""), S("12345"), S("12345"));
- test1(S(""), S("1234567890"), S("1234567890"));
- test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test1(S("abcde"), S(""), S("abcde"));
- test1(S("abcde"), S("12345"), S("abcde12345"));
- test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test1(S("abcdefghij"), S(""), S("abcdefghij"));
- test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
-
- test2(S(""), S(""), S(""));
- test2(S(""), S("12345"), S("12345"));
- test2(S(""), S("1234567890"), S("1234567890"));
- test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test2(S("abcde"), S(""), S("abcde"));
- test2(S("abcde"), S("12345"), S("abcde12345"));
- test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test2(S("abcdefghij"), S(""), S("abcdefghij"));
- test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
-
- test3(S(""), S(""), S(""));
- test3(S(""), S("12345"), S("12345"));
- test3(S(""), S("1234567890"), S("1234567890"));
- test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
- test3(S("abcde"), S(""), S("abcde"));
- test3(S("abcde"), S("12345"), S("abcde12345"));
- test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
- test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
- test3(S("abcdefghij"), S(""), S("abcdefghij"));
- test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
- test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
- test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
- test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
- test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
- test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
- test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
- }
-#endif // TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
index 9b0072405df6a48..a8114af2600cad2 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const typename S::value_type* lhs, const S& rhs,
assert((lhs == rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test("", S(""), true);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test("", S(""), true);
- test("", S("abcde"), false);
- test("", S("abcdefghij"), false);
- test("", S("abcdefghijklmnopqrst"), false);
- test("abcde", S(""), false);
- test("abcde", S("abcde"), true);
- test("abcde", S("abcdefghij"), false);
- test("abcde", S("abcdefghijklmnopqrst"), false);
- test("abcdefghij", S(""), false);
- test("abcdefghij", S("abcde"), false);
- test("abcdefghij", S("abcdefghij"), true);
- test("abcdefghij", S("abcdefghijklmnopqrst"), false);
- test("abcdefghijklmnopqrst", S(""), false);
- test("abcdefghijklmnopqrst", S("abcde"), false);
- test("abcdefghijklmnopqrst", S("abcdefghij"), false);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test("", S(""), true);
- test("", S("abcde"), false);
- test("", S("abcdefghij"), false);
- test("", S("abcdefghijklmnopqrst"), false);
- test("abcde", S(""), false);
- test("abcde", S("abcde"), true);
- test("abcde", S("abcdefghij"), false);
- test("abcde", S("abcdefghijklmnopqrst"), false);
- test("abcdefghij", S(""), false);
- test("abcdefghij", S("abcde"), false);
- test("abcdefghij", S("abcdefghij"), true);
- test("abcdefghij", S("abcdefghijklmnopqrst"), false);
- test("abcdefghijklmnopqrst", S(""), false);
- test("abcdefghijklmnopqrst", S("abcde"), false);
- test("abcdefghijklmnopqrst", S("abcdefghij"), false);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
index 54021af1d11a95d..8e67e6e81a6e91d 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const typename S::value_type* rhs,
assert((lhs == rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), "", true);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), "", true);
- test(S(""), "abcde", false);
- test(S(""), "abcdefghij", false);
- test(S(""), "abcdefghijklmnopqrst", false);
- test(S("abcde"), "", false);
- test(S("abcde"), "abcde", true);
- test(S("abcde"), "abcdefghij", false);
- test(S("abcde"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghij"), "", false);
- test(S("abcdefghij"), "abcde", false);
- test(S("abcdefghij"), "abcdefghij", true);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghijklmnopqrst"), "", false);
- test(S("abcdefghijklmnopqrst"), "abcde", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), "", true);
- test(S(""), "abcde", false);
- test(S(""), "abcdefghij", false);
- test(S(""), "abcdefghijklmnopqrst", false);
- test(S("abcde"), "", false);
- test(S("abcde"), "abcde", true);
- test(S("abcde"), "abcdefghij", false);
- test(S("abcde"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghij"), "", false);
- test(S("abcdefghij"), "abcde", false);
- test(S("abcdefghij"), "abcdefghij", true);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghijklmnopqrst"), "", false);
- test(S("abcdefghijklmnopqrst"), "abcde", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
index 7cac0dfb76632fc..31bace312f1df8d 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
@@ -23,46 +23,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const S& rhs, bool x) {
assert((lhs == rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), S(""), true);
- test(S(""), S("abcde"), false);
- test(S(""), S("abcdefghij"), false);
- test(S(""), S("abcdefghijklmnopqrst"), false);
- test(S("abcde"), S(""), false);
- test(S("abcde"), S("abcde"), true);
- test(S("abcde"), S("abcdefghij"), false);
- test(S("abcde"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), S(""), false);
- test(S("abcdefghij"), S("abcde"), false);
- test(S("abcdefghij"), S("abcdefghij"), true);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), S(""), false);
- test(S("abcdefghijklmnopqrst"), S("abcde"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), S(""), true);
- test(S(""), S("abcde"), false);
- test(S(""), S("abcdefghij"), false);
- test(S(""), S("abcdefghijklmnopqrst"), false);
- test(S("abcde"), S(""), false);
- test(S("abcde"), S("abcde"), true);
- test(S("abcde"), S("abcdefghij"), false);
- test(S("abcde"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), S(""), false);
- test(S("abcdefghij"), S("abcde"), false);
- test(S("abcdefghij"), S("abcdefghij"), true);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), S(""), false);
- test(S("abcdefghijklmnopqrst"), S("abcde"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string_view.pass.cpp
index e151735cdd56a7a..c758c4adfe60428 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_string_view.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, SV rhs, bool x) {
assert((lhs == rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(S(""), SV(""), true);
+ test(S(""), SV("abcde"), false);
+ test(S(""), SV("abcdefghij"), false);
+ test(S(""), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), SV(""), false);
+ test(S("abcde"), SV("abcde"), true);
+ test(S("abcde"), SV("abcdefghij"), false);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), SV(""), false);
+ test(S("abcdefghij"), SV("abcde"), false);
+ test(S("abcdefghij"), SV("abcdefghij"), true);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), SV(""), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test(S(""), SV(""), true);
- test(S(""), SV("abcde"), false);
- test(S(""), SV("abcdefghij"), false);
- test(S(""), SV("abcdefghijklmnopqrst"), false);
- test(S("abcde"), SV(""), false);
- test(S("abcde"), SV("abcde"), true);
- test(S("abcde"), SV("abcdefghij"), false);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), SV(""), false);
- test(S("abcdefghij"), SV("abcde"), false);
- test(S("abcdefghij"), SV("abcdefghij"), true);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), SV(""), false);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(S(""), SV(""), true);
- test(S(""), SV("abcde"), false);
- test(S(""), SV("abcdefghij"), false);
- test(S(""), SV("abcdefghijklmnopqrst"), false);
- test(S("abcde"), SV(""), false);
- test(S("abcde"), SV("abcde"), true);
- test(S("abcde"), SV("abcdefghij"), false);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), SV(""), false);
- test(S("abcdefghij"), SV("abcde"), false);
- test(S("abcdefghij"), SV("abcdefghij"), true);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), SV(""), false);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_view_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_view_string.pass.cpp
index bd386eae6ce8ec7..39dd627033c4856 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_view_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_operator==/string_view_string.pass.cpp
@@ -21,50 +21,34 @@ TEST_CONSTEXPR_CXX20 void test(SV lhs, const S& rhs, bool x) {
assert((lhs == rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+
+ test(SV(""), S(""), true);
+ test(SV(""), S("abcde"), false);
+ test(SV(""), S("abcdefghij"), false);
+ test(SV(""), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcde"), S(""), false);
+ test(SV("abcde"), S("abcde"), true);
+ test(SV("abcde"), S("abcdefghij"), false);
+ test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcdefghij"), S(""), false);
+ test(SV("abcdefghij"), S("abcde"), false);
+ test(SV("abcdefghij"), S("abcdefghij"), true);
+ test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcdefghijklmnopqrst"), S(""), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test(SV(""), S(""), true);
- test(SV(""), S("abcde"), false);
- test(SV(""), S("abcdefghij"), false);
- test(SV(""), S("abcdefghijklmnopqrst"), false);
- test(SV("abcde"), S(""), false);
- test(SV("abcde"), S("abcde"), true);
- test(SV("abcde"), S("abcdefghij"), false);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghij"), S(""), false);
- test(SV("abcdefghij"), S("abcde"), false);
- test(SV("abcdefghij"), S("abcdefghij"), true);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghijklmnopqrst"), S(""), false);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(SV(""), S(""), true);
- test(SV(""), S("abcde"), false);
- test(SV(""), S("abcdefghij"), false);
- test(SV(""), S("abcdefghijklmnopqrst"), false);
- test(SV("abcde"), S(""), false);
- test(SV("abcde"), S("abcde"), true);
- test(SV("abcde"), S("abcdefghij"), false);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghij"), S(""), false);
- test(SV("abcdefghij"), S("abcde"), false);
- test(SV("abcdefghij"), S("abcdefghij"), true);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghijklmnopqrst"), S(""), false);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, min_allocator>();
#endif
-
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
index 66c97d7e814f231..ce0fbf55b5c5111 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const typename S::value_type* lhs, const S& rhs,
assert((lhs > rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test("", S(""), false);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test("", S(""), false);
- test("", S("abcde"), false);
- test("", S("abcdefghij"), false);
- test("", S("abcdefghijklmnopqrst"), false);
- test("abcde", S(""), true);
- test("abcde", S("abcde"), false);
- test("abcde", S("abcdefghij"), false);
- test("abcde", S("abcdefghijklmnopqrst"), false);
- test("abcdefghij", S(""), true);
- test("abcdefghij", S("abcde"), true);
- test("abcdefghij", S("abcdefghij"), false);
- test("abcdefghij", S("abcdefghijklmnopqrst"), false);
- test("abcdefghijklmnopqrst", S(""), true);
- test("abcdefghijklmnopqrst", S("abcde"), true);
- test("abcdefghijklmnopqrst", S("abcdefghij"), true);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test("", S(""), false);
- test("", S("abcde"), false);
- test("", S("abcdefghij"), false);
- test("", S("abcdefghijklmnopqrst"), false);
- test("abcde", S(""), true);
- test("abcde", S("abcde"), false);
- test("abcde", S("abcdefghij"), false);
- test("abcde", S("abcdefghijklmnopqrst"), false);
- test("abcdefghij", S(""), true);
- test("abcdefghij", S("abcde"), true);
- test("abcdefghij", S("abcdefghij"), false);
- test("abcdefghij", S("abcdefghijklmnopqrst"), false);
- test("abcdefghijklmnopqrst", S(""), true);
- test("abcdefghijklmnopqrst", S("abcde"), true);
- test("abcdefghijklmnopqrst", S("abcdefghij"), true);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
index 1f7fb5d26ec9052..2a77947bc7febea 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const typename S::value_type* rhs,
assert((lhs > rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), "", false);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), "", false);
- test(S(""), "abcde", false);
- test(S(""), "abcdefghij", false);
- test(S(""), "abcdefghijklmnopqrst", false);
- test(S("abcde"), "", true);
- test(S("abcde"), "abcde", false);
- test(S("abcde"), "abcdefghij", false);
- test(S("abcde"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghij"), "", true);
- test(S("abcdefghij"), "abcde", true);
- test(S("abcdefghij"), "abcdefghij", false);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghijklmnopqrst"), "", true);
- test(S("abcdefghijklmnopqrst"), "abcde", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), "", false);
- test(S(""), "abcde", false);
- test(S(""), "abcdefghij", false);
- test(S(""), "abcdefghijklmnopqrst", false);
- test(S("abcde"), "", true);
- test(S("abcde"), "abcde", false);
- test(S("abcde"), "abcdefghij", false);
- test(S("abcde"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghij"), "", true);
- test(S("abcdefghij"), "abcde", true);
- test(S("abcdefghij"), "abcdefghij", false);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghijklmnopqrst"), "", true);
- test(S("abcdefghijklmnopqrst"), "abcde", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
index 51070fd938f9683..794f9e76b4e857e 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
@@ -23,46 +23,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const S& rhs, bool x) {
assert((lhs > rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), S(""), false);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), S(""), false);
- test(S(""), S("abcde"), false);
- test(S(""), S("abcdefghij"), false);
- test(S(""), S("abcdefghijklmnopqrst"), false);
- test(S("abcde"), S(""), true);
- test(S("abcde"), S("abcde"), false);
- test(S("abcde"), S("abcdefghij"), false);
- test(S("abcde"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), S(""), true);
- test(S("abcdefghij"), S("abcde"), true);
- test(S("abcdefghij"), S("abcdefghij"), false);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), S(""), true);
- test(S("abcdefghijklmnopqrst"), S("abcde"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), S(""), false);
- test(S(""), S("abcde"), false);
- test(S(""), S("abcdefghij"), false);
- test(S(""), S("abcdefghijklmnopqrst"), false);
- test(S("abcde"), S(""), true);
- test(S("abcde"), S("abcde"), false);
- test(S("abcde"), S("abcdefghij"), false);
- test(S("abcde"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), S(""), true);
- test(S("abcdefghij"), S("abcde"), true);
- test(S("abcdefghij"), S("abcdefghij"), false);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), S(""), true);
- test(S("abcdefghijklmnopqrst"), S("abcde"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string_view.pass.cpp
index ed5d308c4521d63..de06981bb47870a 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_string_view.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, SV rhs, bool x) {
assert((lhs > rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(S(""), SV(""), false);
+ test(S(""), SV("abcde"), false);
+ test(S(""), SV("abcdefghij"), false);
+ test(S(""), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), SV(""), true);
+ test(S("abcde"), SV("abcde"), false);
+ test(S("abcde"), SV("abcdefghij"), false);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), SV(""), true);
+ test(S("abcdefghij"), SV("abcde"), true);
+ test(S("abcdefghij"), SV("abcdefghij"), false);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
+ 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_view SV;
- test(S(""), SV(""), false);
- test(S(""), SV("abcde"), false);
- test(S(""), SV("abcdefghij"), false);
- test(S(""), SV("abcdefghijklmnopqrst"), false);
- test(S("abcde"), SV(""), true);
- test(S("abcde"), SV("abcde"), false);
- test(S("abcde"), SV("abcdefghij"), false);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), SV(""), true);
- test(S("abcdefghij"), SV("abcde"), true);
- test(S("abcdefghij"), SV("abcdefghij"), false);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
- 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<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(S(""), SV(""), false);
- test(S(""), SV("abcde"), false);
- test(S(""), SV("abcdefghij"), false);
- test(S(""), SV("abcdefghijklmnopqrst"), false);
- test(S("abcde"), SV(""), true);
- test(S("abcde"), SV("abcde"), false);
- test(S("abcde"), SV("abcdefghij"), false);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), SV(""), true);
- test(S("abcdefghij"), SV("abcde"), true);
- test(S("abcdefghij"), SV("abcdefghij"), false);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
- 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<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_view_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_view_string.pass.cpp
index be508abd37e8a33..8026777a88db195 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_view_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt/string_view_string.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(SV lhs, const S& rhs, bool x) {
assert((lhs > rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(SV(""), S(""), false);
+ test(SV(""), S("abcde"), false);
+ test(SV(""), S("abcdefghij"), false);
+ test(SV(""), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcde"), S(""), true);
+ test(SV("abcde"), S("abcde"), false);
+ test(SV("abcde"), S("abcdefghij"), false);
+ test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcdefghij"), S(""), true);
+ test(SV("abcdefghij"), S("abcde"), true);
+ test(SV("abcdefghij"), S("abcdefghij"), false);
+ test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ 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"), false);
- test(SV(""), S("abcdefghij"), false);
- test(SV(""), S("abcdefghijklmnopqrst"), false);
- test(SV("abcde"), S(""), true);
- test(SV("abcde"), S("abcde"), false);
- test(SV("abcde"), S("abcdefghij"), false);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghij"), S(""), true);
- test(SV("abcdefghij"), S("abcde"), true);
- test(SV("abcdefghij"), S("abcdefghij"), false);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- 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<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(SV(""), S(""), false);
- test(SV(""), S("abcde"), false);
- test(SV(""), S("abcdefghij"), false);
- test(SV(""), S("abcdefghijklmnopqrst"), false);
- test(SV("abcde"), S(""), true);
- test(SV("abcde"), S("abcde"), false);
- test(SV("abcde"), S("abcdefghij"), false);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghij"), S(""), true);
- test(SV("abcdefghij"), S("abcde"), true);
- test(SV("abcdefghij"), S("abcdefghij"), false);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- 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<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
index b65da02351e6d98..35d3c69785325a3 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const typename S::value_type* lhs, const S& rhs,
assert((lhs >= rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test("", S(""), true);
+ test("", S("abcde"), false);
+ test("", S("abcdefghij"), false);
+ test("", S("abcdefghijklmnopqrst"), false);
+ test("abcde", S(""), true);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), false);
+ test("abcde", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghij", S(""), true);
+ test("abcdefghij", S("abcde"), true);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+ test("abcdefghijklmnopqrst", S(""), true);
+ test("abcdefghijklmnopqrst", S("abcde"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test("", S(""), true);
- test("", S("abcde"), false);
- test("", S("abcdefghij"), false);
- test("", S("abcdefghijklmnopqrst"), false);
- test("abcde", S(""), true);
- test("abcde", S("abcde"), true);
- test("abcde", S("abcdefghij"), false);
- test("abcde", S("abcdefghijklmnopqrst"), false);
- test("abcdefghij", S(""), true);
- test("abcdefghij", S("abcde"), true);
- test("abcdefghij", S("abcdefghij"), true);
- test("abcdefghij", S("abcdefghijklmnopqrst"), false);
- test("abcdefghijklmnopqrst", S(""), true);
- test("abcdefghijklmnopqrst", S("abcde"), true);
- test("abcdefghijklmnopqrst", S("abcdefghij"), true);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test("", S(""), true);
- test("", S("abcde"), false);
- test("", S("abcdefghij"), false);
- test("", S("abcdefghijklmnopqrst"), false);
- test("abcde", S(""), true);
- test("abcde", S("abcde"), true);
- test("abcde", S("abcdefghij"), false);
- test("abcde", S("abcdefghijklmnopqrst"), false);
- test("abcdefghij", S(""), true);
- test("abcdefghij", S("abcde"), true);
- test("abcdefghij", S("abcdefghij"), true);
- test("abcdefghij", S("abcdefghijklmnopqrst"), false);
- test("abcdefghijklmnopqrst", S(""), true);
- test("abcdefghijklmnopqrst", S("abcde"), true);
- test("abcdefghijklmnopqrst", S("abcdefghij"), true);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
index 2bb008c730848ab..3f8883e358da56e 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const typename S::value_type* rhs,
assert((lhs >= rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), "", true);
+ test(S(""), "abcde", false);
+ test(S(""), "abcdefghij", false);
+ test(S(""), "abcdefghijklmnopqrst", false);
+ test(S("abcde"), "", true);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", false);
+ test(S("abcde"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghij"), "", true);
+ test(S("abcdefghij"), "abcde", true);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+ test(S("abcdefghijklmnopqrst"), "", true);
+ test(S("abcdefghijklmnopqrst"), "abcde", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), "", true);
- test(S(""), "abcde", false);
- test(S(""), "abcdefghij", false);
- test(S(""), "abcdefghijklmnopqrst", false);
- test(S("abcde"), "", true);
- test(S("abcde"), "abcde", true);
- test(S("abcde"), "abcdefghij", false);
- test(S("abcde"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghij"), "", true);
- test(S("abcdefghij"), "abcde", true);
- test(S("abcdefghij"), "abcdefghij", true);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghijklmnopqrst"), "", true);
- test(S("abcdefghijklmnopqrst"), "abcde", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), "", true);
- test(S(""), "abcde", false);
- test(S(""), "abcdefghij", false);
- test(S(""), "abcdefghijklmnopqrst", false);
- test(S("abcde"), "", true);
- test(S("abcde"), "abcde", true);
- test(S("abcde"), "abcdefghij", false);
- test(S("abcde"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghij"), "", true);
- test(S("abcdefghij"), "abcde", true);
- test(S("abcdefghij"), "abcdefghij", true);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
- test(S("abcdefghijklmnopqrst"), "", true);
- test(S("abcdefghijklmnopqrst"), "abcde", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
index 9e42ab587387578..1dc65bf0b6db093 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
@@ -23,46 +23,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const S& rhs, bool x) {
assert((lhs >= rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), false);
+ test(S(""), S("abcdefghij"), false);
+ test(S(""), S("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), S(""), true);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), false);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), S(""), true);
+ test(S("abcdefghij"), S("abcde"), true);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), S(""), true);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), S(""), true);
- test(S(""), S("abcde"), false);
- test(S(""), S("abcdefghij"), false);
- test(S(""), S("abcdefghijklmnopqrst"), false);
- test(S("abcde"), S(""), true);
- test(S("abcde"), S("abcde"), true);
- test(S("abcde"), S("abcdefghij"), false);
- test(S("abcde"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), S(""), true);
- test(S("abcdefghij"), S("abcde"), true);
- test(S("abcdefghij"), S("abcdefghij"), true);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), S(""), true);
- test(S("abcdefghijklmnopqrst"), S("abcde"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), S(""), true);
- test(S(""), S("abcde"), false);
- test(S(""), S("abcdefghij"), false);
- test(S(""), S("abcdefghijklmnopqrst"), false);
- test(S("abcde"), S(""), true);
- test(S("abcde"), S("abcde"), true);
- test(S("abcde"), S("abcdefghij"), false);
- test(S("abcde"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), S(""), true);
- test(S("abcdefghij"), S("abcde"), true);
- test(S("abcdefghij"), S("abcdefghij"), true);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), S(""), true);
- test(S("abcdefghijklmnopqrst"), S("abcde"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string_view.pass.cpp
index aa43fe9ac291244..19c96ffb77e79da 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_string_view.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, SV rhs, bool x) {
assert((lhs >= rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(S(""), SV(""), true);
+ test(S(""), SV("abcde"), false);
+ test(S(""), SV("abcdefghij"), false);
+ test(S(""), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcde"), SV(""), true);
+ test(S("abcde"), SV("abcde"), true);
+ test(S("abcde"), SV("abcdefghij"), false);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghij"), SV(""), true);
+ test(S("abcdefghij"), SV("abcde"), true);
+ test(S("abcdefghij"), SV("abcdefghij"), true);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
+ test(S("abcdefghijklmnopqrst"), SV(""), true);
+ test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test(S(""), SV(""), true);
- test(S(""), SV("abcde"), false);
- test(S(""), SV("abcdefghij"), false);
- test(S(""), SV("abcdefghijklmnopqrst"), false);
- test(S("abcde"), SV(""), true);
- test(S("abcde"), SV("abcde"), true);
- test(S("abcde"), SV("abcdefghij"), false);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), SV(""), true);
- test(S("abcdefghij"), SV("abcde"), true);
- test(S("abcdefghij"), SV("abcdefghij"), true);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), SV(""), true);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(S(""), SV(""), true);
- test(S(""), SV("abcde"), false);
- test(S(""), SV("abcdefghij"), false);
- test(S(""), SV("abcdefghijklmnopqrst"), false);
- test(S("abcde"), SV(""), true);
- test(S("abcde"), SV("abcde"), true);
- test(S("abcde"), SV("abcdefghij"), false);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghij"), SV(""), true);
- test(S("abcdefghij"), SV("abcde"), true);
- test(S("abcdefghij"), SV("abcdefghij"), true);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
- test(S("abcdefghijklmnopqrst"), SV(""), true);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_view_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_view_string.pass.cpp
index e42a387de765107..d55b2f8fd34be45 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_view_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_opgt=/string_view_string.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(SV lhs, const S& rhs, bool x) {
assert((lhs >= rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(SV(""), S(""), true);
+ test(SV(""), S("abcde"), false);
+ test(SV(""), S("abcdefghij"), false);
+ test(SV(""), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcde"), S(""), true);
+ test(SV("abcde"), S("abcde"), true);
+ test(SV("abcde"), S("abcdefghij"), false);
+ test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcdefghij"), S(""), true);
+ test(SV("abcdefghij"), S("abcde"), true);
+ test(SV("abcdefghij"), S("abcdefghij"), true);
+ test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+ test(SV("abcdefghijklmnopqrst"), S(""), true);
+ test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
+ test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+ test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test(SV(""), S(""), true);
- test(SV(""), S("abcde"), false);
- test(SV(""), S("abcdefghij"), false);
- test(SV(""), S("abcdefghijklmnopqrst"), false);
- test(SV("abcde"), S(""), true);
- test(SV("abcde"), S("abcde"), true);
- test(SV("abcde"), S("abcdefghij"), false);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghij"), S(""), true);
- test(SV("abcdefghij"), S("abcde"), true);
- test(SV("abcdefghij"), S("abcdefghij"), true);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghijklmnopqrst"), S(""), true);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(SV(""), S(""), true);
- test(SV(""), S("abcde"), false);
- test(SV(""), S("abcdefghij"), false);
- test(SV(""), S("abcdefghijklmnopqrst"), false);
- test(SV("abcde"), S(""), true);
- test(SV("abcde"), S("abcde"), true);
- test(SV("abcde"), S("abcdefghij"), false);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghij"), S(""), true);
- test(SV("abcdefghij"), S("abcde"), true);
- test(SV("abcdefghij"), S("abcdefghij"), true);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
- test(SV("abcdefghijklmnopqrst"), S(""), true);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
index 06e4f28efc508a5..0c4dbe2f9193b96 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const typename S::value_type* lhs, const S& rhs,
assert((lhs < rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test("", S(""), false);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), false);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), false);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+}
+
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(""), false);
- test("abcde", S("abcde"), false);
- test("abcde", S("abcdefghij"), true);
- test("abcde", S("abcdefghijklmnopqrst"), true);
- test("abcdefghij", S(""), false);
- test("abcdefghij", S("abcde"), false);
- test("abcdefghij", S("abcdefghij"), false);
- test("abcdefghij", S("abcdefghijklmnopqrst"), true);
- test("abcdefghijklmnopqrst", S(""), false);
- test("abcdefghijklmnopqrst", S("abcde"), false);
- test("abcdefghijklmnopqrst", S("abcdefghij"), false);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test("", S(""), false);
- test("", S("abcde"), true);
- test("", S("abcdefghij"), true);
- test("", S("abcdefghijklmnopqrst"), true);
- test("abcde", S(""), false);
- test("abcde", S("abcde"), false);
- test("abcde", S("abcdefghij"), true);
- test("abcde", S("abcdefghijklmnopqrst"), true);
- test("abcdefghij", S(""), false);
- test("abcdefghij", S("abcde"), false);
- test("abcdefghij", S("abcdefghij"), false);
- test("abcdefghij", S("abcdefghijklmnopqrst"), true);
- test("abcdefghijklmnopqrst", S(""), false);
- test("abcdefghijklmnopqrst", S("abcde"), false);
- test("abcdefghijklmnopqrst", S("abcdefghij"), false);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
index d489ed3fc8c0ceb..bcdb1091140dfc6 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const typename S::value_type* rhs,
assert((lhs < rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), "", false);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", false);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", false);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+}
+
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"), "", false);
- test(S("abcde"), "abcde", false);
- test(S("abcde"), "abcdefghij", true);
- test(S("abcde"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghij"), "", false);
- test(S("abcdefghij"), "abcde", false);
- test(S("abcdefghij"), "abcdefghij", false);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghijklmnopqrst"), "", false);
- test(S("abcdefghijklmnopqrst"), "abcde", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), "", false);
- test(S(""), "abcde", true);
- test(S(""), "abcdefghij", true);
- test(S(""), "abcdefghijklmnopqrst", true);
- test(S("abcde"), "", false);
- test(S("abcde"), "abcde", false);
- test(S("abcde"), "abcdefghij", true);
- test(S("abcde"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghij"), "", false);
- test(S("abcdefghij"), "abcde", false);
- test(S("abcdefghij"), "abcdefghij", false);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghijklmnopqrst"), "", false);
- test(S("abcdefghijklmnopqrst"), "abcde", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
index fcf7d4df541eb45..6ca1dd27f31ab6f 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
@@ -23,46 +23,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const S& rhs, bool x) {
assert((lhs < rhs) == x);
}
+template <class S>
+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(""), false);
+ test(S("abcde"), S("abcde"), false);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), false);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+}
+
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(""), false);
- test(S("abcde"), S("abcde"), false);
- test(S("abcde"), S("abcdefghij"), true);
- test(S("abcde"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), S(""), false);
- test(S("abcdefghij"), S("abcde"), false);
- test(S("abcdefghij"), S("abcdefghij"), false);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), S(""), false);
- test(S("abcdefghijklmnopqrst"), S("abcde"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), S(""), false);
- test(S(""), S("abcde"), true);
- test(S(""), S("abcdefghij"), true);
- test(S(""), S("abcdefghijklmnopqrst"), true);
- test(S("abcde"), S(""), false);
- test(S("abcde"), S("abcde"), false);
- test(S("abcde"), S("abcdefghij"), true);
- test(S("abcde"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), S(""), false);
- test(S("abcdefghij"), S("abcde"), false);
- test(S("abcdefghij"), S("abcdefghij"), false);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), S(""), false);
- test(S("abcdefghijklmnopqrst"), S("abcde"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string_view.pass.cpp
index 0c728a975215935..56549d17677364e 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string_view.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, SV rhs, bool x) {
assert((lhs < rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(S(""), SV(""), false);
+ test(S(""), SV("abcde"), true);
+ test(S(""), SV("abcdefghij"), true);
+ test(S(""), SV("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), SV(""), false);
+ test(S("abcde"), SV("abcde"), false);
+ test(S("abcde"), SV("abcdefghij"), true);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), SV(""), false);
+ test(S("abcdefghij"), SV("abcde"), false);
+ test(S("abcdefghij"), SV("abcdefghij"), false);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), SV(""), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- 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(""), false);
- test(S("abcde"), SV("abcde"), false);
- test(S("abcde"), SV("abcdefghij"), true);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), SV(""), false);
- test(S("abcdefghij"), SV("abcde"), false);
- test(S("abcdefghij"), SV("abcdefghij"), false);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), SV(""), false);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(S(""), SV(""), false);
- test(S(""), SV("abcde"), true);
- test(S(""), SV("abcdefghij"), true);
- test(S(""), SV("abcdefghijklmnopqrst"), true);
- test(S("abcde"), SV(""), false);
- test(S("abcde"), SV("abcde"), false);
- test(S("abcde"), SV("abcdefghij"), true);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), SV(""), false);
- test(S("abcdefghij"), SV("abcde"), false);
- test(S("abcdefghij"), SV("abcdefghij"), false);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), SV(""), false);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_view_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_view_string.pass.cpp
index 7cc8a2a9dead1c8..72e9d4bf96682a9 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_view_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_view_string.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(SV lhs, const S& rhs, bool x) {
assert((lhs < rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(SV(""), S(""), false);
+ test(SV(""), S("abcde"), true);
+ test(SV(""), S("abcdefghij"), true);
+ test(SV(""), S("abcdefghijklmnopqrst"), true);
+ test(SV("abcde"), S(""), false);
+ test(SV("abcde"), S("abcde"), false);
+ test(SV("abcde"), S("abcdefghij"), true);
+ test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(SV("abcdefghij"), S(""), false);
+ test(SV("abcdefghij"), S("abcde"), false);
+ test(SV("abcdefghij"), S("abcdefghij"), false);
+ test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(SV("abcdefghijklmnopqrst"), S(""), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ 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(""), false);
- test(SV("abcde"), S("abcde"), false);
- test(SV("abcde"), S("abcdefghij"), true);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghij"), S(""), false);
- test(SV("abcdefghij"), S("abcde"), false);
- test(SV("abcdefghij"), S("abcdefghij"), false);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghijklmnopqrst"), S(""), false);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(SV(""), S(""), false);
- test(SV(""), S("abcde"), true);
- test(SV(""), S("abcdefghij"), true);
- test(SV(""), S("abcdefghijklmnopqrst"), true);
- test(SV("abcde"), S(""), false);
- test(SV("abcde"), S("abcde"), false);
- test(SV("abcde"), S("abcdefghij"), true);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghij"), S(""), false);
- test(SV("abcdefghij"), S("abcde"), false);
- test(SV("abcdefghij"), S("abcdefghij"), false);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghijklmnopqrst"), S(""), false);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
index 1242431248eb52e..85c6f04ecc2c146 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const typename S::value_type* lhs, const S& rhs,
assert((lhs <= rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test("", S(""), true);
+ test("", S("abcde"), true);
+ test("", S("abcdefghij"), true);
+ test("", S("abcdefghijklmnopqrst"), true);
+ test("abcde", S(""), false);
+ test("abcde", S("abcde"), true);
+ test("abcde", S("abcdefghij"), true);
+ test("abcde", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghij", S(""), false);
+ test("abcdefghij", S("abcde"), false);
+ test("abcdefghij", S("abcdefghij"), true);
+ test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+ test("abcdefghijklmnopqrst", S(""), false);
+ test("abcdefghijklmnopqrst", S("abcde"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+ test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test("", S(""), true);
- test("", S("abcde"), true);
- test("", S("abcdefghij"), true);
- test("", S("abcdefghijklmnopqrst"), true);
- test("abcde", S(""), false);
- test("abcde", S("abcde"), true);
- test("abcde", S("abcdefghij"), true);
- test("abcde", S("abcdefghijklmnopqrst"), true);
- test("abcdefghij", S(""), false);
- test("abcdefghij", S("abcde"), false);
- test("abcdefghij", S("abcdefghij"), true);
- test("abcdefghij", S("abcdefghijklmnopqrst"), true);
- test("abcdefghijklmnopqrst", S(""), false);
- test("abcdefghijklmnopqrst", S("abcde"), false);
- test("abcdefghijklmnopqrst", S("abcdefghij"), false);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test("", S(""), true);
- test("", S("abcde"), true);
- test("", S("abcdefghij"), true);
- test("", S("abcdefghijklmnopqrst"), true);
- test("abcde", S(""), false);
- test("abcde", S("abcde"), true);
- test("abcde", S("abcdefghij"), true);
- test("abcde", S("abcdefghijklmnopqrst"), true);
- test("abcdefghij", S(""), false);
- test("abcdefghij", S("abcde"), false);
- test("abcdefghij", S("abcdefghij"), true);
- test("abcdefghij", S("abcdefghijklmnopqrst"), true);
- test("abcdefghijklmnopqrst", S(""), false);
- test("abcdefghijklmnopqrst", S("abcde"), false);
- test("abcdefghijklmnopqrst", S("abcdefghij"), false);
- test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
index 8107c3c25fd410c..16db9337823297b 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
@@ -22,46 +22,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const typename S::value_type* rhs,
assert((lhs <= rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), "", true);
+ test(S(""), "abcde", true);
+ test(S(""), "abcdefghij", true);
+ test(S(""), "abcdefghijklmnopqrst", true);
+ test(S("abcde"), "", false);
+ test(S("abcde"), "abcde", true);
+ test(S("abcde"), "abcdefghij", true);
+ test(S("abcde"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghij"), "", false);
+ test(S("abcdefghij"), "abcde", false);
+ test(S("abcdefghij"), "abcdefghij", true);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+ test(S("abcdefghijklmnopqrst"), "", false);
+ test(S("abcdefghijklmnopqrst"), "abcde", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), "", true);
- test(S(""), "abcde", true);
- test(S(""), "abcdefghij", true);
- test(S(""), "abcdefghijklmnopqrst", true);
- test(S("abcde"), "", false);
- test(S("abcde"), "abcde", true);
- test(S("abcde"), "abcdefghij", true);
- test(S("abcde"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghij"), "", false);
- test(S("abcdefghij"), "abcde", false);
- test(S("abcdefghij"), "abcdefghij", true);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghijklmnopqrst"), "", false);
- test(S("abcdefghijklmnopqrst"), "abcde", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), "", true);
- test(S(""), "abcde", true);
- test(S(""), "abcdefghij", true);
- test(S(""), "abcdefghijklmnopqrst", true);
- test(S("abcde"), "", false);
- test(S("abcde"), "abcde", true);
- test(S("abcde"), "abcdefghij", true);
- test(S("abcde"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghij"), "", false);
- test(S("abcdefghij"), "abcde", false);
- test(S("abcdefghij"), "abcdefghij", true);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
- test(S("abcdefghijklmnopqrst"), "", false);
- test(S("abcdefghijklmnopqrst"), "abcde", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
index 508e8bdb7853c45..a97001417791564 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
@@ -23,46 +23,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, const S& rhs, bool x) {
assert((lhs <= rhs) == x);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), S(""), true);
+ test(S(""), S("abcde"), true);
+ test(S(""), S("abcdefghij"), true);
+ test(S(""), S("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), S(""), false);
+ test(S("abcde"), S("abcde"), true);
+ test(S("abcde"), S("abcdefghij"), true);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), S(""), false);
+ test(S("abcdefghij"), S("abcde"), false);
+ test(S("abcdefghij"), S("abcdefghij"), true);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), S(""), false);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), S(""), true);
- test(S(""), S("abcde"), true);
- test(S(""), S("abcdefghij"), true);
- test(S(""), S("abcdefghijklmnopqrst"), true);
- test(S("abcde"), S(""), false);
- test(S("abcde"), S("abcde"), true);
- test(S("abcde"), S("abcdefghij"), true);
- test(S("abcde"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), S(""), false);
- test(S("abcdefghij"), S("abcde"), false);
- test(S("abcdefghij"), S("abcdefghij"), true);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), S(""), false);
- test(S("abcdefghijklmnopqrst"), S("abcde"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), S(""), true);
- test(S(""), S("abcde"), true);
- test(S(""), S("abcdefghij"), true);
- test(S(""), S("abcdefghijklmnopqrst"), true);
- test(S("abcde"), S(""), false);
- test(S("abcde"), S("abcde"), true);
- test(S("abcde"), S("abcdefghij"), true);
- test(S("abcde"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), S(""), false);
- test(S("abcdefghij"), S("abcde"), false);
- test(S("abcdefghij"), S("abcdefghij"), true);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), S(""), false);
- test(S("abcdefghijklmnopqrst"), S("abcde"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp
index e9ea2fb8f444088..2ee253820c11e95 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_string_view.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(const S& lhs, SV rhs, bool x) {
assert((lhs <= rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(S(""), SV(""), true);
+ test(S(""), SV("abcde"), true);
+ test(S(""), SV("abcdefghij"), true);
+ test(S(""), SV("abcdefghijklmnopqrst"), true);
+ test(S("abcde"), SV(""), false);
+ test(S("abcde"), SV("abcde"), true);
+ test(S("abcde"), SV("abcdefghij"), true);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghij"), SV(""), false);
+ test(S("abcdefghij"), SV("abcde"), false);
+ test(S("abcdefghij"), SV("abcdefghij"), true);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
+ test(S("abcdefghijklmnopqrst"), SV(""), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test(S(""), SV(""), true);
- test(S(""), SV("abcde"), true);
- test(S(""), SV("abcdefghij"), true);
- test(S(""), SV("abcdefghijklmnopqrst"), true);
- test(S("abcde"), SV(""), false);
- test(S("abcde"), SV("abcde"), true);
- test(S("abcde"), SV("abcdefghij"), true);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), SV(""), false);
- test(S("abcdefghij"), SV("abcde"), false);
- test(S("abcdefghij"), SV("abcdefghij"), true);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), SV(""), false);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(S(""), SV(""), true);
- test(S(""), SV("abcde"), true);
- test(S(""), SV("abcdefghij"), true);
- test(S(""), SV("abcdefghijklmnopqrst"), true);
- test(S("abcde"), SV(""), false);
- test(S("abcde"), SV("abcde"), true);
- test(S("abcde"), SV("abcdefghij"), true);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghij"), SV(""), false);
- test(S("abcdefghij"), SV("abcde"), false);
- test(S("abcdefghij"), SV("abcdefghij"), true);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
- test(S("abcdefghijklmnopqrst"), SV(""), false);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_view_string.pass.cpp b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_view_string.pass.cpp
index b46e0b2b1373f21..88951e4da9101bf 100644
--- a/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_view_string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt=/string_view_string.pass.cpp
@@ -21,48 +21,32 @@ TEST_CONSTEXPR_CXX20 void test(SV lhs, const S& rhs, bool x) {
assert((lhs <= rhs) == x);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test(SV(""), S(""), true);
+ test(SV(""), S("abcde"), true);
+ test(SV(""), S("abcdefghij"), true);
+ test(SV(""), S("abcdefghijklmnopqrst"), true);
+ test(SV("abcde"), S(""), false);
+ test(SV("abcde"), S("abcde"), true);
+ test(SV("abcde"), S("abcdefghij"), true);
+ test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
+ test(SV("abcdefghij"), S(""), false);
+ test(SV("abcdefghij"), S("abcde"), false);
+ test(SV("abcdefghij"), S("abcdefghij"), true);
+ test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+ test(SV("abcdefghijklmnopqrst"), S(""), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+ test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test(SV(""), S(""), true);
- test(SV(""), S("abcde"), true);
- test(SV(""), S("abcdefghij"), true);
- test(SV(""), S("abcdefghijklmnopqrst"), true);
- test(SV("abcde"), S(""), false);
- test(SV("abcde"), S("abcde"), true);
- test(SV("abcde"), S("abcdefghij"), true);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghij"), S(""), false);
- test(SV("abcdefghij"), S("abcde"), false);
- test(SV("abcdefghij"), S("abcdefghij"), true);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghijklmnopqrst"), S(""), false);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::basic_string_view<char, std::char_traits<char>> SV;
- test(SV(""), S(""), true);
- test(SV(""), S("abcde"), true);
- test(SV(""), S("abcdefghij"), true);
- test(SV(""), S("abcdefghijklmnopqrst"), true);
- test(SV("abcde"), S(""), false);
- test(SV("abcde"), S("abcde"), true);
- test(SV("abcde"), S("abcdefghij"), true);
- test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghij"), S(""), false);
- test(SV("abcdefghij"), S("abcde"), false);
- test(SV("abcdefghij"), S("abcdefghij"), true);
- test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
- test(SV("abcdefghijklmnopqrst"), S(""), false);
- test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
- test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
index 0fcdc02124588fd..837599ae9ef551b 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
@@ -27,22 +27,18 @@ TEST_CONSTEXPR_CXX20 void test(const S& s) {
assert(T::eq(str[0], typename S::value_type()));
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""));
+ test(S("abcde"));
+ test(S("abcdefghij"));
+ test(S("abcdefghijklmnopqrst"));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""));
- test(S("abcde"));
- test(S("abcdefghij"));
- test(S("abcdefghijklmnopqrst"));
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""));
- test(S("abcde"));
- test(S("abcdefghij"));
- test(S("abcdefghijklmnopqrst"));
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
index 3d7c8c8f4cb430d..27762fbd9390d51 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string.accessors/data.pass.cpp
@@ -39,26 +39,14 @@ TEST_CONSTEXPR_CXX20 void test_nonconst(S& s) {
assert(T::eq(str[0], typename S::value_type()));
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test_const(S(""));
- test_const(S("abcde"));
- test_const(S("abcdefghij"));
- test_const(S("abcdefghijklmnopqrst"));
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test_const(S(""));
- test_const(S("abcde"));
- test_const(S("abcdefghij"));
- test_const(S("abcdefghijklmnopqrst"));
- }
-#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test_const(S(""));
+ test_const(S("abcde"));
+ test_const(S("abcdefghij"));
+ test_const(S("abcdefghijklmnopqrst"));
#if TEST_STD_VER > 14
{
- typedef std::string S;
S s1("");
test_nonconst(s1);
S s2("abcde");
@@ -69,6 +57,13 @@ TEST_CONSTEXPR_CXX20 bool test() {
test_nonconst(s4);
}
#endif
+}
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
index 819e4a046d6fd16..a6158aeb38dc2e8 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
@@ -22,24 +22,23 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, const typename S::allocator_type& a)
assert(s.get_allocator() == a);
}
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ using S = std::basic_string<char, std::char_traits<char>, Alloc>;
+ test(S(""), Alloc());
+ test(S("abcde", Alloc(a)), Alloc(a));
+ test(S("abcdefghij", Alloc(a)), Alloc(a));
+ test(S("abcdefghijklmnopqrst", Alloc(a)), Alloc(a));
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef test_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(""), A());
- test(S("abcde", A(1)), A(1));
- test(S("abcdefghij", A(2)), A(2));
- test(S("abcdefghijklmnopqrst", A(3)), A(3));
- }
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(1));
+ test_string(test_allocator<char>(2));
+ test_string(test_allocator<char>(3));
#if TEST_STD_VER >= 11
- {
- typedef min_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test(S(""), A());
- test(S("abcde", A()), A());
- test(S("abcdefghij", A()), A());
- test(S("abcdefghijklmnopqrst", A()), A());
- }
+ test_string(min_allocator<char>());
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
index dbabaac65050405..e1d23924517ffbf 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
@@ -30,46 +30,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, const typename S::value_type* str, in
assert(sign(s.compare(str)) == sign(x));
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), "", 0);
+ test(S(""), "abcde", -5);
+ test(S(""), "abcdefghij", -10);
+ test(S(""), "abcdefghijklmnopqrst", -20);
+ test(S("abcde"), "", 5);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdefghij", -5);
+ test(S("abcde"), "abcdefghijklmnopqrst", -15);
+ test(S("abcdefghij"), "", 10);
+ test(S("abcdefghij"), "abcde", 5);
+ test(S("abcdefghij"), "abcdefghij", 0);
+ test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
+ test(S("abcdefghijklmnopqrst"), "", 20);
+ test(S("abcdefghijklmnopqrst"), "abcde", 15);
+ test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
+ test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), "", 0);
- test(S(""), "abcde", -5);
- test(S(""), "abcdefghij", -10);
- test(S(""), "abcdefghijklmnopqrst", -20);
- test(S("abcde"), "", 5);
- test(S("abcde"), "abcde", 0);
- test(S("abcde"), "abcdefghij", -5);
- test(S("abcde"), "abcdefghijklmnopqrst", -15);
- test(S("abcdefghij"), "", 10);
- test(S("abcdefghij"), "abcde", 5);
- test(S("abcdefghij"), "abcdefghij", 0);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
- test(S("abcdefghijklmnopqrst"), "", 20);
- test(S("abcdefghijklmnopqrst"), "abcde", 15);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), "", 0);
- test(S(""), "abcde", -5);
- test(S(""), "abcdefghij", -10);
- test(S(""), "abcdefghijklmnopqrst", -20);
- test(S("abcde"), "", 5);
- test(S("abcde"), "abcde", 0);
- test(S("abcde"), "abcdefghij", -5);
- test(S("abcde"), "abcdefghijklmnopqrst", -15);
- test(S("abcdefghij"), "", 10);
- test(S("abcdefghij"), "abcde", 5);
- test(S("abcdefghij"), "abcdefghij", 0);
- test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
- test(S("abcdefghijklmnopqrst"), "", 20);
- test(S("abcdefghijklmnopqrst"), "abcde", 15);
- test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
- test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
index 49916cbd56f9944..c6281d9e377f474 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
@@ -5916,8 +5916,11 @@ TEST_CONSTEXPR_CXX20 bool test56() {
return true;
}
-template <class S, class SV>
+template <class CharT, template <class> class Alloc>
void test() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+
test0<S, SV>();
test1<S, SV>();
test2<S, SV>();
@@ -6038,10 +6041,9 @@ void test() {
}
int main(int, char**) {
- test<std::string, std::string_view>();
+ test<char, std::allocator>();
#if TEST_STD_VER >= 11
- test<std::basic_string<char, std::char_traits<char>, min_allocator<char>>,
- std::basic_string_view<char, std::char_traits<char>>>();
+ test<char, min_allocator>();
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
index 46d55ae56bdec95..d4a5133ed3907f8 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
@@ -351,20 +351,17 @@ TEST_CONSTEXPR_CXX20 void test2() {
test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#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
index c3a7d0d500e1e66..018daaa2f262e4f 100644
--- 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
@@ -42,7 +42,7 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::size_type pos1, typename
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test0() {
+TEST_CONSTEXPR_CXX20 bool test0() {
test(S(""), 0, 0, S(""), 0);
test(S(""), 0, 0, S("abcde"), -5);
test(S(""), 0, 0, S("abcdefghij"), -10);
@@ -143,10 +143,11 @@ TEST_CONSTEXPR_CXX20 void test0() {
test(S("abcde"), 5, 1, S("abcde"), -5);
test(S("abcde"), 5, 1, S("abcdefghij"), -10);
test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), -20);
+ return true;
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test1() {
+TEST_CONSTEXPR_CXX20 bool test1() {
test(S("abcde"), 6, 0, S(""), 0);
test(S("abcde"), 6, 0, S("abcde"), 0);
test(S("abcde"), 6, 0, S("abcdefghij"), 0);
@@ -247,10 +248,11 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("abcdefghij"), 11, 0, S("abcde"), 0);
test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0);
test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0);
+ return true;
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test2() {
+TEST_CONSTEXPR_CXX20 bool test2() {
test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0);
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), -5);
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), -10);
@@ -347,39 +349,31 @@ TEST_CONSTEXPR_CXX20 void test2() {
test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0);
test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0);
test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0);
+ return true;
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- }
+template <class S>
+void test() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+
+#if TEST_STD_VER > 17
+ static_assert(test0<S>());
+ static_assert(test1<S>());
+ static_assert(test2<S>());
#endif
+}
+int main(int, char**) {
+ test<std::string>();
#if TEST_STD_VER >= 11
+ test<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // LWG 2946
std::string s = " !";
assert(s.compare(0, 1, {"abc", 1}) < 0);
}
#endif
- return true;
-}
-
-int main(int, char**) {
- test();
-#if TEST_STD_VER > 17
- static_assert(test());
-#endif
-
return 0;
}
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
index 80469814a15a052..006f8495886b83a 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp
@@ -350,22 +350,20 @@ TEST_CONSTEXPR_CXX20 void test2() {
test(S("abcdefghijklmnopqrst"), 21, 0, SV("abcdefghijklmnopqrst"), 0);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+
+ test0<S, SV>();
+ test1<S, SV>();
+ test2<S, SV>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- test2<S, SV>();
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- test2<S, SV>();
- }
+ test_string<char, min_allocator>();
#endif
return true;
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
index f63cd5066585867..7378b604c91c87e 100644
--- 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
@@ -30,49 +30,30 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, const S& str, int x) {
assert(sign(s.compare(str)) == sign(x));
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), S(""), 0);
- test(S(""), S("abcde"), -5);
- test(S(""), S("abcdefghij"), -10);
- test(S(""), S("abcdefghijklmnopqrst"), -20);
- test(S("abcde"), S(""), 5);
- test(S("abcde"), S("abcde"), 0);
- test(S("abcde"), S("abcdefghij"), -5);
- test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
- test(S("abcdefghij"), S(""), 10);
- test(S("abcdefghij"), S("abcde"), 5);
- test(S("abcdefghij"), S("abcdefghij"), 0);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
- test(S("abcdefghijklmnopqrst"), S(""), 20);
- test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), S(""), 0);
- test(S(""), S("abcde"), -5);
- test(S(""), S("abcdefghij"), -10);
- test(S(""), S("abcdefghijklmnopqrst"), -20);
- test(S("abcde"), S(""), 5);
- test(S("abcde"), S("abcde"), 0);
- test(S("abcde"), S("abcdefghij"), -5);
- test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
- test(S("abcdefghij"), S(""), 10);
- test(S("abcdefghij"), S("abcde"), 5);
- test(S("abcdefghij"), S("abcdefghij"), 0);
- test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
- test(S("abcdefghijklmnopqrst"), S(""), 20);
- test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
- test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
- test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
- }
-#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), -5);
+ test(S(""), S("abcdefghij"), -10);
+ test(S(""), S("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), S(""), 5);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdefghij"), -5);
+ test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), S(""), 10);
+ test(S("abcdefghij"), S("abcde"), 5);
+ test(S("abcdefghij"), S("abcdefghij"), 0);
+ test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), S(""), 20);
+ test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
+}
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // LWG 2946
std::string s = " !";
assert(s.compare({"abc", 1}) < 0);
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
index 2f97d4819772a49..a03e34328f51a59 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_compare/string_view.pass.cpp
@@ -30,48 +30,33 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, SV sv, int x) {
assert(sign(s.compare(sv)) == sign(x));
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+
+ test(S(""), SV(""), 0);
+ test(S(""), SV("abcde"), -5);
+ test(S(""), SV("abcdefghij"), -10);
+ test(S(""), SV("abcdefghijklmnopqrst"), -20);
+ test(S("abcde"), SV(""), 5);
+ test(S("abcde"), SV("abcde"), 0);
+ test(S("abcde"), SV("abcdefghij"), -5);
+ test(S("abcde"), SV("abcdefghijklmnopqrst"), -15);
+ test(S("abcdefghij"), SV(""), 10);
+ test(S("abcdefghij"), SV("abcde"), 5);
+ test(S("abcdefghij"), SV("abcdefghij"), 0);
+ test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), -10);
+ test(S("abcdefghijklmnopqrst"), SV(""), 20);
+ test(S("abcdefghijklmnopqrst"), SV("abcde"), 15);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), 10);
+ test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), 0);
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test(S(""), SV(""), 0);
- test(S(""), SV("abcde"), -5);
- test(S(""), SV("abcdefghij"), -10);
- test(S(""), SV("abcdefghijklmnopqrst"), -20);
- test(S("abcde"), SV(""), 5);
- test(S("abcde"), SV("abcde"), 0);
- test(S("abcde"), SV("abcdefghij"), -5);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), -15);
- test(S("abcdefghij"), SV(""), 10);
- test(S("abcdefghij"), SV("abcde"), 5);
- test(S("abcdefghij"), SV("abcdefghij"), 0);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), -10);
- test(S("abcdefghijklmnopqrst"), SV(""), 20);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), 15);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), 10);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), 0);
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test(S(""), SV(""), 0);
- test(S(""), SV("abcde"), -5);
- test(S(""), SV("abcdefghij"), -10);
- test(S(""), SV("abcdefghijklmnopqrst"), -20);
- test(S("abcde"), SV(""), 5);
- test(S("abcde"), SV("abcde"), 0);
- test(S("abcde"), SV("abcdefghij"), -5);
- test(S("abcde"), SV("abcdefghijklmnopqrst"), -15);
- test(S("abcdefghij"), SV(""), 10);
- test(S("abcdefghij"), SV("abcde"), 5);
- test(S("abcdefghij"), SV("abcdefghij"), 0);
- test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), -10);
- test(S("abcdefghijklmnopqrst"), SV(""), 20);
- test(S("abcdefghijklmnopqrst"), SV("abcde"), 15);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), 10);
- test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), 0);
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
index 6fddd3629c6f73c..fd97e5bd6e79c02 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
@@ -33,68 +33,41 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::value_type c, typename S:
assert(x < s.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), 'q', 0, S::npos);
- test(S(""), 'q', 1, S::npos);
- test(S("kitcj"), 'q', 0, 0);
- test(S("qkamf"), 'q', 1, 1);
- test(S("nhmko"), 'q', 2, 2);
- test(S("tpsaf"), 'q', 4, 4);
- test(S("lahfb"), 'q', 5, S::npos);
- test(S("irkhs"), 'q', 6, S::npos);
- test(S("gmfhdaipsr"), 'q', 0, 0);
- test(S("kantesmpgj"), 'q', 1, 1);
- test(S("odaftiegpm"), 'q', 5, 5);
- test(S("oknlrstdpi"), 'q', 9, 9);
- test(S("eolhfgpjqk"), 'q', 10, S::npos);
- test(S("pcdrofikas"), 'q', 11, S::npos);
- test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
- test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
- test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
- test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
- test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
- test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), 'q', 0, S::npos);
+ test(S(""), 'q', 1, S::npos);
+ test(S("kitcj"), 'q', 0, 0);
+ test(S("qkamf"), 'q', 1, 1);
+ test(S("nhmko"), 'q', 2, 2);
+ test(S("tpsaf"), 'q', 4, 4);
+ test(S("lahfb"), 'q', 5, S::npos);
+ test(S("irkhs"), 'q', 6, S::npos);
+ test(S("gmfhdaipsr"), 'q', 0, 0);
+ test(S("kantesmpgj"), 'q', 1, 1);
+ test(S("odaftiegpm"), 'q', 5, 5);
+ test(S("oknlrstdpi"), 'q', 9, 9);
+ test(S("eolhfgpjqk"), 'q', 10, S::npos);
+ test(S("pcdrofikas"), 'q', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+ test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
- test(S(""), 'q', S::npos);
- test(S("q"), 'q', S::npos);
- test(S("qqq"), 'q', S::npos);
- test(S("csope"), 'q', 0);
- test(S("gfsmthlkon"), 'q', 0);
- test(S("laenfsbridchgotmkqpj"), 'q', 0);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), 'q', 0, S::npos);
- test(S(""), 'q', 1, S::npos);
- test(S("kitcj"), 'q', 0, 0);
- test(S("qkamf"), 'q', 1, 1);
- test(S("nhmko"), 'q', 2, 2);
- test(S("tpsaf"), 'q', 4, 4);
- test(S("lahfb"), 'q', 5, S::npos);
- test(S("irkhs"), 'q', 6, S::npos);
- test(S("gmfhdaipsr"), 'q', 0, 0);
- test(S("kantesmpgj"), 'q', 1, 1);
- test(S("odaftiegpm"), 'q', 5, 5);
- test(S("oknlrstdpi"), 'q', 9, 9);
- test(S("eolhfgpjqk"), 'q', 10, S::npos);
- test(S("pcdrofikas"), 'q', 11, S::npos);
- test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
- test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
- test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
- test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
- test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
- test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+ test(S(""), 'q', S::npos);
+ test(S("q"), 'q', S::npos);
+ test(S("qqq"), 'q', S::npos);
+ test(S("csope"), 'q', 0);
+ test(S("gfsmthlkon"), 'q', 0);
+ test(S("laenfsbridchgotmkqpj"), 'q', 0);
+}
- test(S(""), 'q', S::npos);
- test(S("q"), 'q', S::npos);
- test(S("qqq"), 'q', S::npos);
- test(S("csope"), 'q', 0);
- test(S("gfsmthlkon"), 'q', 0);
- test(S("laenfsbridchgotmkqpj"), 'q', 0);
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
index bc4f976d5adf5dd..927ec97ae0218f3 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
@@ -136,18 +136,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
index e567546596de865..2da628b8437d5c3 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
@@ -365,22 +365,18 @@ TEST_CONSTEXPR_CXX20 void test3() {
test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
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
index 5a9bb039a3579ed..23e1906943401b6 100644
--- 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
@@ -136,21 +136,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
-#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // 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.not.of/string_view_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
index 98dfeafe8efc59c..d63eb8c2f1673ff 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.not.of/string_view_size.pass.cpp
@@ -136,20 +136,19 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), S::npos);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+
+ test0<S, SV>();
+ test1<S, SV>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
index a6eafab0423891e..100d3f4bf25107d 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
@@ -33,64 +33,39 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::value_type c, typename S:
assert(x < s.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), 'e', 0, S::npos);
- test(S(""), 'e', 1, S::npos);
- test(S("kitcj"), 'e', 0, S::npos);
- test(S("qkamf"), 'e', 1, S::npos);
- test(S("nhmko"), 'e', 2, S::npos);
- test(S("tpsaf"), 'e', 4, S::npos);
- test(S("lahfb"), 'e', 5, S::npos);
- test(S("irkhs"), 'e', 6, S::npos);
- test(S("gmfhdaipsr"), 'e', 0, S::npos);
- test(S("kantesmpgj"), 'e', 1, 4);
- test(S("odaftiegpm"), 'e', 5, 6);
- test(S("oknlrstdpi"), 'e', 9, S::npos);
- test(S("eolhfgpjqk"), 'e', 10, S::npos);
- test(S("pcdrofikas"), 'e', 11, S::npos);
- test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
- test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
- test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
- test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
- test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
- test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), 'e', 0, S::npos);
+ test(S(""), 'e', 1, S::npos);
+ test(S("kitcj"), 'e', 0, S::npos);
+ test(S("qkamf"), 'e', 1, S::npos);
+ test(S("nhmko"), 'e', 2, S::npos);
+ test(S("tpsaf"), 'e', 4, S::npos);
+ test(S("lahfb"), 'e', 5, S::npos);
+ test(S("irkhs"), 'e', 6, S::npos);
+ test(S("gmfhdaipsr"), 'e', 0, S::npos);
+ test(S("kantesmpgj"), 'e', 1, 4);
+ test(S("odaftiegpm"), 'e', 5, 6);
+ test(S("oknlrstdpi"), 'e', 9, S::npos);
+ test(S("eolhfgpjqk"), 'e', 10, S::npos);
+ test(S("pcdrofikas"), 'e', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+ test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+ test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+ test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+ test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+ test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
- test(S(""), 'e', S::npos);
- test(S("csope"), 'e', 4);
- test(S("gfsmthlkon"), 'e', S::npos);
- test(S("laenfsbridchgotmkqpj"), 'e', 2);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), 'e', 0, S::npos);
- test(S(""), 'e', 1, S::npos);
- test(S("kitcj"), 'e', 0, S::npos);
- test(S("qkamf"), 'e', 1, S::npos);
- test(S("nhmko"), 'e', 2, S::npos);
- test(S("tpsaf"), 'e', 4, S::npos);
- test(S("lahfb"), 'e', 5, S::npos);
- test(S("irkhs"), 'e', 6, S::npos);
- test(S("gmfhdaipsr"), 'e', 0, S::npos);
- test(S("kantesmpgj"), 'e', 1, 4);
- test(S("odaftiegpm"), 'e', 5, 6);
- test(S("oknlrstdpi"), 'e', 9, S::npos);
- test(S("eolhfgpjqk"), 'e', 10, S::npos);
- test(S("pcdrofikas"), 'e', 11, S::npos);
- test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
- test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
- test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
- test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
- test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
- test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+ test(S(""), 'e', S::npos);
+ test(S("csope"), 'e', 4);
+ test(S("gfsmthlkon"), 'e', S::npos);
+ test(S("laenfsbridchgotmkqpj"), 'e', 2);
+}
- test(S(""), 'e', S::npos);
- test(S("csope"), 'e', 4);
- test(S("gfsmthlkon"), 'e', S::npos);
- test(S("laenfsbridchgotmkqpj"), 'e', 2);
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
index faf9557a6efd974..6d805393245e782 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
@@ -137,18 +137,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
index 71a026b98e0870d..14d23b8ece135e2 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
@@ -365,22 +365,18 @@ TEST_CONSTEXPR_CXX20 void test3() {
test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
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
index f70a0018aa8afdd..ed872091dcffe9d 100644
--- 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
@@ -136,21 +136,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0);
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
-#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // 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.first.of/string_view_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
index 250da8e9f05a9be..541d0f171a91e57 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.first.of/string_view_size.pass.cpp
@@ -136,20 +136,19 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), 0);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+
+ test0<S, SV>();
+ test1<S, SV>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
index e4cbe382d7808c1..a23206d51430c07 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
@@ -33,64 +33,39 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::value_type c, typename S:
assert(x < s.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), 'i', 0, S::npos);
- test(S(""), 'i', 1, S::npos);
- test(S("kitcj"), 'i', 0, 0);
- test(S("qkamf"), 'i', 1, 1);
- test(S("nhmko"), 'i', 2, 2);
- test(S("tpsaf"), 'i', 4, 4);
- test(S("lahfb"), 'i', 5, 4);
- test(S("irkhs"), 'i', 6, 4);
- test(S("gmfhdaipsr"), 'i', 0, 0);
- test(S("kantesmpgj"), 'i', 1, 1);
- test(S("odaftiegpm"), 'i', 5, 4);
- test(S("oknlrstdpi"), 'i', 9, 8);
- test(S("eolhfgpjqk"), 'i', 10, 9);
- test(S("pcdrofikas"), 'i', 11, 9);
- test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
- test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
- test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
- test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
- test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
- test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), 'i', 0, S::npos);
+ test(S(""), 'i', 1, S::npos);
+ test(S("kitcj"), 'i', 0, 0);
+ test(S("qkamf"), 'i', 1, 1);
+ test(S("nhmko"), 'i', 2, 2);
+ test(S("tpsaf"), 'i', 4, 4);
+ test(S("lahfb"), 'i', 5, 4);
+ test(S("irkhs"), 'i', 6, 4);
+ test(S("gmfhdaipsr"), 'i', 0, 0);
+ test(S("kantesmpgj"), 'i', 1, 1);
+ test(S("odaftiegpm"), 'i', 5, 4);
+ test(S("oknlrstdpi"), 'i', 9, 8);
+ test(S("eolhfgpjqk"), 'i', 10, 9);
+ test(S("pcdrofikas"), 'i', 11, 9);
+ test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+ test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+ test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+ test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+ test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+ test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
- test(S(""), 'i', S::npos);
- test(S("csope"), 'i', 4);
- test(S("gfsmthlkon"), 'i', 9);
- test(S("laenfsbridchgotmkqpj"), 'i', 19);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), 'i', 0, S::npos);
- test(S(""), 'i', 1, S::npos);
- test(S("kitcj"), 'i', 0, 0);
- test(S("qkamf"), 'i', 1, 1);
- test(S("nhmko"), 'i', 2, 2);
- test(S("tpsaf"), 'i', 4, 4);
- test(S("lahfb"), 'i', 5, 4);
- test(S("irkhs"), 'i', 6, 4);
- test(S("gmfhdaipsr"), 'i', 0, 0);
- test(S("kantesmpgj"), 'i', 1, 1);
- test(S("odaftiegpm"), 'i', 5, 4);
- test(S("oknlrstdpi"), 'i', 9, 8);
- test(S("eolhfgpjqk"), 'i', 10, 9);
- test(S("pcdrofikas"), 'i', 11, 9);
- test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
- test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
- test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
- test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
- test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
- test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+ test(S(""), 'i', S::npos);
+ test(S("csope"), 'i', 4);
+ test(S("gfsmthlkon"), 'i', 9);
+ test(S("laenfsbridchgotmkqpj"), 'i', 19);
+}
- test(S(""), 'i', S::npos);
- test(S("csope"), 'i', 4);
- test(S("gfsmthlkon"), 'i', 9);
- test(S("laenfsbridchgotmkqpj"), 'i', 19);
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
index a2bdce68f307304..1cb761ee31a641a 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
@@ -137,18 +137,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
index aa3204f9deb61d5..4fe72a5a9e5c1a8 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
@@ -365,22 +365,18 @@ TEST_CONSTEXPR_CXX20 void test3() {
test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
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
index 1ced857f0060766..ae088ba98b5ff5f 100644
--- 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
@@ -136,21 +136,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
-#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // 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.not.of/string_view_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
index 28584aa573fc4f4..478015095a7accb 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.not.of/string_view_size.pass.cpp
@@ -136,20 +136,19 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), S::npos);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+
+ test0<S, SV>();
+ test1<S, SV>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
index 50b90b9f392abb8..fd278d9b917ebab 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
@@ -33,64 +33,39 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::value_type c, typename S:
assert(x < s.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), 'm', 0, S::npos);
- test(S(""), 'm', 1, S::npos);
- test(S("kitcj"), 'm', 0, S::npos);
- test(S("qkamf"), 'm', 1, S::npos);
- test(S("nhmko"), 'm', 2, 2);
- test(S("tpsaf"), 'm', 4, S::npos);
- test(S("lahfb"), 'm', 5, S::npos);
- test(S("irkhs"), 'm', 6, S::npos);
- test(S("gmfhdaipsr"), 'm', 0, S::npos);
- test(S("kantesmpgj"), 'm', 1, S::npos);
- test(S("odaftiegpm"), 'm', 5, S::npos);
- test(S("oknlrstdpi"), 'm', 9, S::npos);
- test(S("eolhfgpjqk"), 'm', 10, S::npos);
- test(S("pcdrofikas"), 'm', 11, S::npos);
- test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
- test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
- test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
- test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
- test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
- test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), 'm', 0, S::npos);
+ test(S(""), 'm', 1, S::npos);
+ test(S("kitcj"), 'm', 0, S::npos);
+ test(S("qkamf"), 'm', 1, S::npos);
+ test(S("nhmko"), 'm', 2, 2);
+ test(S("tpsaf"), 'm', 4, S::npos);
+ test(S("lahfb"), 'm', 5, S::npos);
+ test(S("irkhs"), 'm', 6, S::npos);
+ test(S("gmfhdaipsr"), 'm', 0, S::npos);
+ test(S("kantesmpgj"), 'm', 1, S::npos);
+ test(S("odaftiegpm"), 'm', 5, S::npos);
+ test(S("oknlrstdpi"), 'm', 9, S::npos);
+ test(S("eolhfgpjqk"), 'm', 10, S::npos);
+ test(S("pcdrofikas"), 'm', 11, S::npos);
+ test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+ test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+ test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+ test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+ test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+ test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
- test(S(""), 'm', S::npos);
- test(S("csope"), 'm', S::npos);
- test(S("gfsmthlkon"), 'm', 3);
- test(S("laenfsbridchgotmkqpj"), 'm', 15);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), 'm', 0, S::npos);
- test(S(""), 'm', 1, S::npos);
- test(S("kitcj"), 'm', 0, S::npos);
- test(S("qkamf"), 'm', 1, S::npos);
- test(S("nhmko"), 'm', 2, 2);
- test(S("tpsaf"), 'm', 4, S::npos);
- test(S("lahfb"), 'm', 5, S::npos);
- test(S("irkhs"), 'm', 6, S::npos);
- test(S("gmfhdaipsr"), 'm', 0, S::npos);
- test(S("kantesmpgj"), 'm', 1, S::npos);
- test(S("odaftiegpm"), 'm', 5, S::npos);
- test(S("oknlrstdpi"), 'm', 9, S::npos);
- test(S("eolhfgpjqk"), 'm', 10, S::npos);
- test(S("pcdrofikas"), 'm', 11, S::npos);
- test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
- test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
- test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
- test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
- test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
- test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+ test(S(""), 'm', S::npos);
+ test(S("csope"), 'm', S::npos);
+ test(S("gfsmthlkon"), 'm', 3);
+ test(S("laenfsbridchgotmkqpj"), 'm', 15);
+}
- test(S(""), 'm', S::npos);
- test(S("csope"), 'm', S::npos);
- test(S("gfsmthlkon"), 'm', 3);
- test(S("laenfsbridchgotmkqpj"), 'm', 15);
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
index d3b843998e27b3f..f177671e8ebfe2c 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
@@ -137,18 +137,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 19);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
index 2c015bf17231a03..0dc4f92ba33b7b6 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
@@ -365,22 +365,18 @@ TEST_CONSTEXPR_CXX20 void test3() {
test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, 19);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
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
index e12bcd7b1bb1bc6..c4c7c251445feb9 100644
--- 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
@@ -136,21 +136,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 19);
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
-#endif
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // 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.last.of/string_view_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
index a2b4fb1311166ba..3eae90abd78fbda 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find.last.of/string_view_size.pass.cpp
@@ -136,20 +136,18 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("pniotcfrhqsmgdkjbael"), SV("htaobedqikfplcgjsmrn"), 19);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test0<S, SV>();
+ test1<S, SV>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp
index 8ff6406257c8c86..c0c89c90b301919 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find/char_size.pass.cpp
@@ -33,64 +33,39 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::value_type c, typename S:
assert(0 <= x && x + 1 <= s.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), 'c', 0, S::npos);
- test(S(""), 'c', 1, S::npos);
- test(S("abcde"), 'c', 0, 2);
- test(S("abcde"), 'c', 1, 2);
- test(S("abcde"), 'c', 2, 2);
- test(S("abcde"), 'c', 4, S::npos);
- test(S("abcde"), 'c', 5, S::npos);
- test(S("abcde"), 'c', 6, S::npos);
- test(S("abcdeabcde"), 'c', 0, 2);
- test(S("abcdeabcde"), 'c', 1, 2);
- test(S("abcdeabcde"), 'c', 5, 7);
- test(S("abcdeabcde"), 'c', 9, S::npos);
- test(S("abcdeabcde"), 'c', 10, S::npos);
- test(S("abcdeabcde"), 'c', 11, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
- test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
- test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
- test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), 'c', 0, S::npos);
+ test(S(""), 'c', 1, S::npos);
+ test(S("abcde"), 'c', 0, 2);
+ test(S("abcde"), 'c', 1, 2);
+ test(S("abcde"), 'c', 2, 2);
+ test(S("abcde"), 'c', 4, S::npos);
+ test(S("abcde"), 'c', 5, S::npos);
+ test(S("abcde"), 'c', 6, S::npos);
+ test(S("abcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcde"), 'c', 5, 7);
+ test(S("abcdeabcde"), 'c', 9, S::npos);
+ test(S("abcdeabcde"), 'c', 10, S::npos);
+ test(S("abcdeabcde"), 'c', 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
- test(S(""), 'c', S::npos);
- test(S("abcde"), 'c', 2);
- test(S("abcdeabcde"), 'c', 2);
- test(S("abcdeabcdeabcdeabcde"), 'c', 2);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), 'c', 0, S::npos);
- test(S(""), 'c', 1, S::npos);
- test(S("abcde"), 'c', 0, 2);
- test(S("abcde"), 'c', 1, 2);
- test(S("abcde"), 'c', 2, 2);
- test(S("abcde"), 'c', 4, S::npos);
- test(S("abcde"), 'c', 5, S::npos);
- test(S("abcde"), 'c', 6, S::npos);
- test(S("abcdeabcde"), 'c', 0, 2);
- test(S("abcdeabcde"), 'c', 1, 2);
- test(S("abcdeabcde"), 'c', 5, 7);
- test(S("abcdeabcde"), 'c', 9, S::npos);
- test(S("abcdeabcde"), 'c', 10, S::npos);
- test(S("abcdeabcde"), 'c', 11, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
- test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
- test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
- test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+ test(S(""), 'c', S::npos);
+ test(S("abcde"), 'c', 2);
+ test(S("abcdeabcde"), 'c', 2);
+ test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+}
- test(S(""), 'c', S::npos);
- test(S("abcde"), 'c', 2);
- test(S("abcdeabcde"), 'c', 2);
- test(S("abcdeabcdeabcdeabcde"), 'c', 2);
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
index 54e76831ed9e44d..e07302f2624f4b7 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
@@ -141,18 +141,16 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
index 47179c17756c652..5fda0e2af64c779 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
@@ -365,22 +365,18 @@ TEST_CONSTEXPR_CXX20 void test3() {
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, S::npos);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
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
index 08d4ae24d1e90bf..60ed469ce991b14 100644
--- 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
@@ -136,20 +136,17 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
-
#if TEST_STD_VER >= 11
{ // LWG 2946
std::string s = " !";
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
index 34d7302b40cc12b..68c08e2d504bd95 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_find/string_view_size.pass.cpp
@@ -136,20 +136,18 @@ TEST_CONSTEXPR_CXX20 void test1() {
test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0);
}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
+ test0<S, SV>();
+ test1<S, SV>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, std::allocator>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
- }
+ test_string<char, min_allocator>();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
index a31da1a1dbc9b3c..b8f2ad0112d4ab6 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
@@ -33,64 +33,39 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, typename S::value_type c, typename S:
assert(x + 1 <= s.size());
}
-TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test(S(""), 'b', 0, S::npos);
- test(S(""), 'b', 1, S::npos);
- test(S("abcde"), 'b', 0, S::npos);
- test(S("abcde"), 'b', 1, 1);
- test(S("abcde"), 'b', 2, 1);
- test(S("abcde"), 'b', 4, 1);
- test(S("abcde"), 'b', 5, 1);
- test(S("abcde"), 'b', 6, 1);
- test(S("abcdeabcde"), 'b', 0, S::npos);
- test(S("abcdeabcde"), 'b', 1, 1);
- test(S("abcdeabcde"), 'b', 5, 1);
- test(S("abcdeabcde"), 'b', 9, 6);
- test(S("abcdeabcde"), 'b', 10, 6);
- test(S("abcdeabcde"), 'b', 11, 6);
- test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
- test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
- test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
- test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
- test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test(S(""), 'b', 0, S::npos);
+ test(S(""), 'b', 1, S::npos);
+ test(S("abcde"), 'b', 0, S::npos);
+ test(S("abcde"), 'b', 1, 1);
+ test(S("abcde"), 'b', 2, 1);
+ test(S("abcde"), 'b', 4, 1);
+ test(S("abcde"), 'b', 5, 1);
+ test(S("abcde"), 'b', 6, 1);
+ test(S("abcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcde"), 'b', 5, 1);
+ test(S("abcdeabcde"), 'b', 9, 6);
+ test(S("abcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcde"), 'b', 11, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
- test(S(""), 'b', S::npos);
- test(S("abcde"), 'b', 1);
- test(S("abcdeabcde"), 'b', 6);
- test(S("abcdeabcdeabcdeabcde"), 'b', 16);
- }
-#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test(S(""), 'b', 0, S::npos);
- test(S(""), 'b', 1, S::npos);
- test(S("abcde"), 'b', 0, S::npos);
- test(S("abcde"), 'b', 1, 1);
- test(S("abcde"), 'b', 2, 1);
- test(S("abcde"), 'b', 4, 1);
- test(S("abcde"), 'b', 5, 1);
- test(S("abcde"), 'b', 6, 1);
- test(S("abcdeabcde"), 'b', 0, S::npos);
- test(S("abcdeabcde"), 'b', 1, 1);
- test(S("abcdeabcde"), 'b', 5, 1);
- test(S("abcdeabcde"), 'b', 9, 6);
- test(S("abcdeabcde"), 'b', 10, 6);
- test(S("abcdeabcde"), 'b', 11, 6);
- test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
- test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
- test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
- test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
- test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
- test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+ test(S(""), 'b', S::npos);
+ test(S("abcde"), 'b', 1);
+ test(S("abcdeabcde"), 'b', 6);
+ test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+}
- test(S(""), 'b', S::npos);
- test(S("abcde"), 'b', 1);
- test(S("abcdeabcde"), 'b', 6);
- test(S("abcdeabcdeabcdeabcde"), 'b', 16);
- }
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
index 30b1ce73380e5d4..1d396fb6b8efeb3 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
@@ -39,130 +39,122 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, const typename S::value_type* str, ty
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test0() {
- test(S(""), "", 0, 0);
- test(S(""), "abcde", 0, S::npos);
- test(S(""), "abcdeabcde", 0, S::npos);
- test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
- test(S(""), "", 1, 0);
- test(S(""), "abcde", 1, S::npos);
- test(S(""), "abcdeabcde", 1, S::npos);
- test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
- test(S("abcde"), "", 0, 0);
- test(S("abcde"), "abcde", 0, 0);
- test(S("abcde"), "abcdeabcde", 0, S::npos);
- test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
- test(S("abcde"), "", 1, 1);
- test(S("abcde"), "abcde", 1, 0);
- test(S("abcde"), "abcdeabcde", 1, S::npos);
- test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
- test(S("abcde"), "", 2, 2);
- test(S("abcde"), "abcde", 2, 0);
- test(S("abcde"), "abcdeabcde", 2, S::npos);
- test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
- test(S("abcde"), "", 4, 4);
- test(S("abcde"), "abcde", 4, 0);
- test(S("abcde"), "abcdeabcde", 4, S::npos);
- test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
- test(S("abcde"), "", 5, 5);
- test(S("abcde"), "abcde", 5, 0);
- test(S("abcde"), "abcdeabcde", 5, S::npos);
- test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
- test(S("abcde"), "", 6, 5);
- test(S("abcde"), "abcde", 6, 0);
- test(S("abcde"), "abcdeabcde", 6, S::npos);
- test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
- test(S("abcdeabcde"), "", 0, 0);
- test(S("abcdeabcde"), "abcde", 0, 0);
- test(S("abcdeabcde"), "abcdeabcde", 0, 0);
- test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
- test(S("abcdeabcde"), "", 1, 1);
- test(S("abcdeabcde"), "abcde", 1, 0);
- test(S("abcdeabcde"), "abcdeabcde", 1, 0);
- test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
- test(S("abcdeabcde"), "", 5, 5);
- test(S("abcdeabcde"), "abcde", 5, 5);
- test(S("abcdeabcde"), "abcdeabcde", 5, 0);
- test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
- test(S("abcdeabcde"), "", 9, 9);
- test(S("abcdeabcde"), "abcde", 9, 5);
- test(S("abcdeabcde"), "abcdeabcde", 9, 0);
- test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
- test(S("abcdeabcde"), "", 10, 10);
- test(S("abcdeabcde"), "abcde", 10, 5);
- test(S("abcdeabcde"), "abcdeabcde", 10, 0);
- test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
- test(S("abcdeabcde"), "", 11, 10);
- test(S("abcdeabcde"), "abcde", 11, 5);
- test(S("abcdeabcde"), "abcdeabcde", 11, 0);
- test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
- test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
- test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
- test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
- test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
- test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
- test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
- test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
- test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
- test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
- test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
- test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
- test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
-}
-
-template <class S>
-TEST_CONSTEXPR_CXX20 void test1() {
- test(S(""), "", 0);
- test(S(""), "abcde", S::npos);
- test(S(""), "abcdeabcde", S::npos);
- test(S(""), "abcdeabcdeabcdeabcde", S::npos);
- test(S("abcde"), "", 5);
- test(S("abcde"), "abcde", 0);
- test(S("abcde"), "abcdeabcde", S::npos);
- test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
- test(S("abcdeabcde"), "", 10);
- test(S("abcdeabcde"), "abcde", 5);
- test(S("abcdeabcde"), "abcdeabcde", 0);
- test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
- test(S("abcdeabcdeabcdeabcde"), "", 20);
- test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
- test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
-}
-
-TEST_CONSTEXPR_CXX20 bool test() {
+TEST_CONSTEXPR_CXX20 void test_string() {
{
- typedef std::string S;
- test0<S>();
- test1<S>();
+ test(S(""), "", 0, 0);
+ test(S(""), "abcde", 0, S::npos);
+ test(S(""), "abcdeabcde", 0, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S(""), "", 1, 0);
+ test(S(""), "abcde", 1, S::npos);
+ test(S(""), "abcdeabcde", 1, S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 0, 0);
+ test(S("abcde"), "abcde", 0, 0);
+ test(S("abcde"), "abcdeabcde", 0, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcde"), "", 1, 1);
+ test(S("abcde"), "abcde", 1, 0);
+ test(S("abcde"), "abcdeabcde", 1, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcde"), "", 2, 2);
+ test(S("abcde"), "abcde", 2, 0);
+ test(S("abcde"), "abcdeabcde", 2, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+ test(S("abcde"), "", 4, 4);
+ test(S("abcde"), "abcde", 4, 0);
+ test(S("abcde"), "abcdeabcde", 4, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+ test(S("abcde"), "", 5, 5);
+ test(S("abcde"), "abcde", 5, 0);
+ test(S("abcde"), "abcdeabcde", 5, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcde"), "", 6, 5);
+ test(S("abcde"), "abcde", 6, 0);
+ test(S("abcde"), "abcdeabcde", 6, S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+ test(S("abcdeabcde"), "", 0, 0);
+ test(S("abcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+ test(S("abcdeabcde"), "", 1, 1);
+ test(S("abcdeabcde"), "abcde", 1, 0);
+ test(S("abcdeabcde"), "abcdeabcde", 1, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+ test(S("abcdeabcde"), "", 5, 5);
+ test(S("abcdeabcde"), "abcde", 5, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 5, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+ test(S("abcdeabcde"), "", 9, 9);
+ test(S("abcdeabcde"), "abcde", 9, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 9, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+ test(S("abcdeabcde"), "", 10, 10);
+ test(S("abcdeabcde"), "abcde", 10, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 10, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+ test(S("abcdeabcde"), "", 11, 10);
+ test(S("abcdeabcde"), "abcde", 11, 5);
+ test(S("abcdeabcde"), "abcdeabcde", 11, 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
}
-#if TEST_STD_VER >= 11
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
+ test(S(""), "", 0);
+ test(S(""), "abcde", S::npos);
+ test(S(""), "abcdeabcde", S::npos);
+ test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcde"), "", 5);
+ test(S("abcde"), "abcde", 0);
+ test(S("abcde"), "abcdeabcde", S::npos);
+ test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcde"), "", 10);
+ test(S("abcdeabcde"), "abcde", 5);
+ test(S("abcdeabcde"), "abcdeabcde", 0);
+ test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+ test(S("abcdeabcdeabcdeabcde"), "", 20);
+ test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
+ test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
}
+}
+
+TEST_CONSTEXPR_CXX20 bool tests() {
+ test_string<std::string>();
+#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
}
int main(int, char**) {
- test();
+ tests();
#if TEST_STD_VER > 17
- static_assert(test());
+ static_assert(tests());
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
index 0c050f7596e0587..8e981a5e1087dd8 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
@@ -365,22 +365,18 @@ TEST_CONSTEXPR_CXX20 void test3() {
test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, 0);
}
+template <class S>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ test0<S>();
+ test1<S>();
+ test2<S>();
+ test3<S>();
+}
+
TEST_CONSTEXPR_CXX20 bool test() {
- {
- typedef std::string S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::string>();
#if TEST_STD_VER >= 11
- {
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
- test2<S>();
- test3<S>();
- }
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
#endif
return true;
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
index 576f908655d6d70..f9d09dcabcfd235 100644
--- 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
@@ -33,124 +33,113 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, const S& str, typename S::size_type x
}
template <class S>
-TEST_CONSTEXPR_CXX20 void test0() {
- test(S(""), S(""), 0, 0);
- test(S(""), S("abcde"), 0, S::npos);
- test(S(""), S("abcdeabcde"), 0, S::npos);
- test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
- test(S(""), S(""), 1, 0);
- test(S(""), S("abcde"), 1, S::npos);
- test(S(""), S("abcdeabcde"), 1, S::npos);
- test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
- test(S("abcde"), S(""), 0, 0);
- test(S("abcde"), S("abcde"), 0, 0);
- test(S("abcde"), S("abcdeabcde"), 0, S::npos);
- test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
- test(S("abcde"), S(""), 1, 1);
- test(S("abcde"), S("abcde"), 1, 0);
- test(S("abcde"), S("abcdeabcde"), 1, S::npos);
- test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
- test(S("abcde"), S(""), 2, 2);
- test(S("abcde"), S("abcde"), 2, 0);
- test(S("abcde"), S("abcdeabcde"), 2, S::npos);
- test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
- test(S("abcde"), S(""), 4, 4);
- test(S("abcde"), S("abcde"), 4, 0);
- test(S("abcde"), S("abcdeabcde"), 4, S::npos);
- test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
- test(S("abcde"), S(""), 5, 5);
- test(S("abcde"), S("abcde"), 5, 0);
- test(S("abcde"), S("abcdeabcde"), 5, S::npos);
- test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
- test(S("abcde"), S(""), 6, 5);
- test(S("abcde"), S("abcde"), 6, 0);
- test(S("abcde"), S("abcdeabcde"), 6, S::npos);
- test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
- test(S("abcdeabcde"), S(""), 0, 0);
- test(S("abcdeabcde"), S("abcde"), 0, 0);
- test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
- test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
- test(S("abcdeabcde"), S(""), 1, 1);
- test(S("abcdeabcde"), S("abcde"), 1, 0);
- test(S("abcdeabcde"), S("abcdeabcde"), 1, 0);
- test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
- test(S("abcdeabcde"), S(""), 5, 5);
- test(S("abcdeabcde"), S("abcde"), 5, 5);
- test(S("abcdeabcde"), S("abcdeabcde"), 5, 0);
- test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
- test(S("abcdeabcde"), S(""), 9, 9);
- test(S("abcdeabcde"), S("abcde"), 9, 5);
- test(S("abcdeabcde"), S("abcdeabcde"), 9, 0);
- test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
- test(S("abcdeabcde"), S(""), 10, 10);
- test(S("abcdeabcde"), S("abcde"), 10, 5);
- test(S("abcdeabcde"), S("abcdeabcde"), 10, 0);
- test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
- test(S("abcdeabcde"), S(""), 11, 10);
- test(S("abcdeabcde"), S("abcde"), 11, 5);
- test(S("abcdeabcde"), S("abcdeabcde"), 11, 0);
- test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
- test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
- test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0);
- test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
- test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0);
- test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
- test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0);
- test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
- test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0);
- test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20);
- test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
-}
-
-template <class S>
-TEST_CONSTEXPR_CXX20 void test1() {
- test(S(""), S(""), 0);
- test(S(""), S("abcde"), S::npos);
- test(S(""), S("abcdeabcde"), S::npos);
- test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
- test(S("abcde"), S(""), 5);
- test(S("abcde"), S("abcde"), 0);
- test(S("abcde"), S("abcdeabcde"), S::npos);
- test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
- test(S("abcdeabcde"), S(""), 10);
- test(S("abcdeabcde"), S("abcde"), 5);
- test(S("abcdeabcde"), S("abcdeabcde"), 0);
- test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
- test(S("abcdeabcdeabcdeabcde"), S(""), 20);
- test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10);
- test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
-}
-
-TEST_CONSTEXPR_CXX20 bool test() {
+TEST_CONSTEXPR_CXX20 void test_string() {
{
- typedef std::string S;
- test0<S>();
- test1<S>();
+ test(S(""), S(""), 0, 0);
+ test(S(""), S("abcde"), 0, S::npos);
+ test(S(""), S("abcdeabcde"), 0, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), S(""), 1, 0);
+ test(S(""), S("abcde"), 1, S::npos);
+ test(S(""), S("abcdeabcde"), 1, S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 0, 0);
+ test(S("abcde"), S("abcde"), 0, 0);
+ test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), S(""), 1, 1);
+ test(S("abcde"), S("abcde"), 1, 0);
+ test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), S(""), 2, 2);
+ test(S("abcde"), S("abcde"), 2, 0);
+ test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), S(""), 4, 4);
+ test(S("abcde"), S("abcde"), 4, 0);
+ test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), S(""), 5, 5);
+ test(S("abcde"), S("abcde"), 5, 0);
+ test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), S(""), 6, 5);
+ test(S("abcde"), S("abcde"), 6, 0);
+ test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcde"), S("abcde"), 1, 0);
+ test(S("abcdeabcde"), S("abcdeabcde"), 1, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), S(""), 5, 5);
+ test(S("abcdeabcde"), S("abcde"), 5, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 5, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), S(""), 9, 9);
+ test(S("abcdeabcde"), S("abcde"), 9, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 9, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcde"), S("abcde"), 10, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 10, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), S(""), 11, 10);
+ test(S("abcdeabcde"), S("abcde"), 11, 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 11, 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
}
-#if TEST_STD_VER >= 11
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- test0<S>();
- test1<S>();
+ test(S(""), S(""), 0);
+ test(S(""), S("abcde"), S::npos);
+ test(S(""), S("abcdeabcde"), S::npos);
+ test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), S(""), 5);
+ test(S("abcde"), S("abcde"), 0);
+ test(S("abcde"), S("abcdeabcde"), S::npos);
+ test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), S(""), 10);
+ test(S("abcdeabcde"), S("abcde"), 5);
+ test(S("abcdeabcde"), S("abcdeabcde"), 0);
+ test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), S(""), 20);
+ test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10);
+ test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
}
-#endif
+}
+TEST_CONSTEXPR_CXX20 bool tests() {
+ test_string<std::string>();
#if TEST_STD_VER >= 11
+ test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
{ // LWG 2946
std::string s = " !";
assert(s.rfind({"abc", 1}) == std::string::npos);
@@ -161,9 +150,9 @@ TEST_CONSTEXPR_CXX20 bool test() {
}
int main(int, char**) {
- test();
+ tests();
#if TEST_STD_VER > 17
- static_assert(test());
+ static_assert(tests());
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
index d3049e6189378f7..e42fd3a0ee2de5d 100644
--- a/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.ops/string_rfind/string_view_size.pass.cpp
@@ -32,133 +32,127 @@ TEST_CONSTEXPR_CXX20 void test(const S& s, SV sv, typename S::size_type x) {
assert(0 <= x && x + sv.size() <= s.size());
}
-template <class S, class SV>
-TEST_CONSTEXPR_CXX20 void test0() {
- test(S(""), SV(""), 0, 0);
- test(S(""), SV("abcde"), 0, S::npos);
- test(S(""), SV("abcdeabcde"), 0, S::npos);
- test(S(""), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
- test(S(""), SV(""), 1, 0);
- test(S(""), SV("abcde"), 1, S::npos);
- test(S(""), SV("abcdeabcde"), 1, S::npos);
- test(S(""), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
- test(S("abcde"), SV(""), 0, 0);
- test(S("abcde"), SV("abcde"), 0, 0);
- test(S("abcde"), SV("abcdeabcde"), 0, S::npos);
- test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
- test(S("abcde"), SV(""), 1, 1);
- test(S("abcde"), SV("abcde"), 1, 0);
- test(S("abcde"), SV("abcdeabcde"), 1, S::npos);
- test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
- test(S("abcde"), SV(""), 2, 2);
- test(S("abcde"), SV("abcde"), 2, 0);
- test(S("abcde"), SV("abcdeabcde"), 2, S::npos);
- test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 2, S::npos);
- test(S("abcde"), SV(""), 4, 4);
- test(S("abcde"), SV("abcde"), 4, 0);
- test(S("abcde"), SV("abcdeabcde"), 4, S::npos);
- test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 4, S::npos);
- test(S("abcde"), SV(""), 5, 5);
- test(S("abcde"), SV("abcde"), 5, 0);
- test(S("abcde"), SV("abcdeabcde"), 5, S::npos);
- test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
- test(S("abcde"), SV(""), 6, 5);
- test(S("abcde"), SV("abcde"), 6, 0);
- test(S("abcde"), SV("abcdeabcde"), 6, S::npos);
- test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 6, S::npos);
- test(S("abcdeabcde"), SV(""), 0, 0);
- test(S("abcdeabcde"), SV("abcde"), 0, 0);
- test(S("abcdeabcde"), SV("abcdeabcde"), 0, 0);
- test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
- test(S("abcdeabcde"), SV(""), 1, 1);
- test(S("abcdeabcde"), SV("abcde"), 1, 0);
- test(S("abcdeabcde"), SV("abcdeabcde"), 1, 0);
- test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
- test(S("abcdeabcde"), SV(""), 5, 5);
- test(S("abcdeabcde"), SV("abcde"), 5, 5);
- test(S("abcdeabcde"), SV("abcdeabcde"), 5, 0);
- test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
- test(S("abcdeabcde"), SV(""), 9, 9);
- test(S("abcdeabcde"), SV("abcde"), 9, 5);
- test(S("abcdeabcde"), SV("abcdeabcde"), 9, 0);
- test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 9, S::npos);
- test(S("abcdeabcde"), SV(""), 10, 10);
- test(S("abcdeabcde"), SV("abcde"), 10, 5);
- test(S("abcdeabcde"), SV("abcdeabcde"), 10, 0);
- test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos);
- test(S("abcdeabcde"), SV(""), 11, 10);
- test(S("abcdeabcde"), SV("abcde"), 11, 5);
- test(S("abcdeabcde"), SV("abcdeabcde"), 11, 0);
- test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 11, S::npos);
- test(S("abcdeabcdeabcdeabcde"), SV(""), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, 0);
- test(S("abcdeabcdeabcdeabcde"), SV(""), 1, 1);
- test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 1, 0);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 1, 0);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, 0);
- test(S("abcdeabcdeabcdeabcde"), SV(""), 10, 10);
- test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 10, 10);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10, 10);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, 0);
- test(S("abcdeabcdeabcdeabcde"), SV(""), 19, 19);
- test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 19, 15);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 19, 10);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 19, 0);
- test(S("abcdeabcdeabcdeabcde"), SV(""), 20, 20);
- test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 20, 15);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 20, 10);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 20, 0);
- test(S("abcdeabcdeabcdeabcde"), SV(""), 21, 20);
- test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 21, 15);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 21, 10);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 21, 0);
-}
-
-template <class S, class SV>
-TEST_CONSTEXPR_CXX20 void test1() {
- test(S(""), SV(""), 0);
- test(S(""), SV("abcde"), S::npos);
- test(S(""), SV("abcdeabcde"), S::npos);
- test(S(""), SV("abcdeabcdeabcdeabcde"), S::npos);
- test(S("abcde"), SV(""), 5);
- test(S("abcde"), SV("abcde"), 0);
- test(S("abcde"), SV("abcdeabcde"), S::npos);
- test(S("abcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
- test(S("abcdeabcde"), SV(""), 10);
- test(S("abcdeabcde"), SV("abcde"), 5);
- test(S("abcdeabcde"), SV("abcdeabcde"), 0);
- test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
- test(S("abcdeabcdeabcdeabcde"), SV(""), 20);
- test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 15);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10);
- test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0);
-}
+template <class CharT, template <class> class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
-TEST_CONSTEXPR_CXX20 bool test() {
{
- typedef std::string S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
+ test(S(""), SV(""), 0, 0);
+ test(S(""), SV("abcde"), 0, S::npos);
+ test(S(""), SV("abcdeabcde"), 0, S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S(""), SV(""), 1, 0);
+ test(S(""), SV("abcde"), 1, S::npos);
+ test(S(""), SV("abcdeabcde"), 1, S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV(""), 0, 0);
+ test(S("abcde"), SV("abcde"), 0, 0);
+ test(S("abcde"), SV("abcdeabcde"), 0, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcde"), SV(""), 1, 1);
+ test(S("abcde"), SV("abcde"), 1, 0);
+ test(S("abcde"), SV("abcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcde"), SV(""), 2, 2);
+ test(S("abcde"), SV("abcde"), 2, 0);
+ test(S("abcde"), SV("abcdeabcde"), 2, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 2, S::npos);
+ test(S("abcde"), SV(""), 4, 4);
+ test(S("abcde"), SV("abcde"), 4, 0);
+ test(S("abcde"), SV("abcdeabcde"), 4, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 4, S::npos);
+ test(S("abcde"), SV(""), 5, 5);
+ test(S("abcde"), SV("abcde"), 5, 0);
+ test(S("abcde"), SV("abcdeabcde"), 5, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcde"), SV(""), 6, 5);
+ test(S("abcde"), SV("abcde"), 6, 0);
+ test(S("abcde"), SV("abcdeabcde"), 6, S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), 6, S::npos);
+ test(S("abcdeabcde"), SV(""), 0, 0);
+ test(S("abcdeabcde"), SV("abcde"), 0, 0);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 0, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, S::npos);
+ test(S("abcdeabcde"), SV(""), 1, 1);
+ test(S("abcdeabcde"), SV("abcde"), 1, 0);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 1, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, S::npos);
+ test(S("abcdeabcde"), SV(""), 5, 5);
+ test(S("abcdeabcde"), SV("abcde"), 5, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 5, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 5, S::npos);
+ test(S("abcdeabcde"), SV(""), 9, 9);
+ test(S("abcdeabcde"), SV("abcde"), 9, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 9, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 9, S::npos);
+ test(S("abcdeabcde"), SV(""), 10, 10);
+ test(S("abcdeabcde"), SV("abcde"), 10, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 10, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, S::npos);
+ test(S("abcdeabcde"), SV(""), 11, 10);
+ test(S("abcdeabcde"), SV("abcde"), 11, 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 11, 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), 11, S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 1, 1);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 1, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 10, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 19, 19);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 19, 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 19, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 19, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 20, 20);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 20, 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 20, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 20, 0);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 21, 20);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 21, 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 21, 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 21, 0);
}
-#if TEST_STD_VER >= 11
+
{
- typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
- typedef std::string_view SV;
- test0<S, SV>();
- test1<S, SV>();
+ test(S(""), SV(""), 0);
+ test(S(""), SV("abcde"), S::npos);
+ test(S(""), SV("abcdeabcde"), S::npos);
+ test(S(""), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcde"), SV(""), 5);
+ test(S("abcde"), SV("abcde"), 0);
+ test(S("abcde"), SV("abcdeabcde"), S::npos);
+ test(S("abcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcde"), SV(""), 10);
+ test(S("abcdeabcde"), SV("abcde"), 5);
+ test(S("abcdeabcde"), SV("abcdeabcde"), 0);
+ test(S("abcdeabcde"), SV("abcdeabcdeabcdeabcde"), S::npos);
+ test(S("abcdeabcdeabcdeabcde"), SV(""), 20);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcde"), 15);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcde"), 10);
+ test(S("abcdeabcdeabcdeabcde"), SV("abcdeabcdeabcdeabcde"), 0);
}
+}
+
+TEST_CONSTEXPR_CXX20 bool tests() {
+ test_string<char, std::allocator>();
+#if TEST_STD_VER >= 11
+ test_string<char, min_allocator>();
#endif
return true;
}
int main(int, char**) {
- test();
+ tests();
#if TEST_STD_VER > 17
- static_assert(test());
+ static_assert(tests());
#endif
return 0;
diff --git a/libcxx/test/std/strings/basic.string/string.require/contiguous.pass.cpp b/libcxx/test/std/strings/basic.string/string.require/contiguous.pass.cpp
index 0baf3060f11e353..78908901686cf30 100644
--- a/libcxx/test/std/strings/basic.string/string.require/contiguous.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.require/contiguous.pass.cpp
@@ -8,7 +8,7 @@
// <array>
-// An string is a contiguous container
+// A string is a contiguous container
#include <string>
#include <cassert>
@@ -23,29 +23,33 @@ TEST_CONSTEXPR_CXX20 void test_contiguous(const C& c) {
assert(*(c.begin() + static_cast<typename C::
diff erence_type>(i)) == *(std::addressof(*c.begin()) + i));
}
-TEST_CONSTEXPR_CXX20 bool test() {
+template <class Alloc>
+TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
+ typedef std::basic_string<char, std::char_traits<char>, Alloc> S;
+
{
- typedef std::string S;
test_contiguous(S());
test_contiguous(S("1"));
test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890"));
}
-
{
- typedef test_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test_contiguous(S(A(3)));
- test_contiguous(S("1", A(5)));
- test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+ test_contiguous(S(Alloc()));
+ test_contiguous(S("1", Alloc()));
+ test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc()));
}
-#if TEST_STD_VER >= 11
{
- typedef min_allocator<char> A;
- typedef std::basic_string<char, std::char_traits<char>, A> S;
- test_contiguous(S(A{}));
- test_contiguous(S("1", A()));
- test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+ test_contiguous(S(Alloc(a)));
+ test_contiguous(S("1", Alloc(a)));
+ test_contiguous(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a)));
}
+}
+
+TEST_CONSTEXPR_CXX20 bool test() {
+ test_string(std::allocator<char>());
+ test_string(test_allocator<char>());
+ test_string(test_allocator<char>(3));
+#if TEST_STD_VER >= 11
+ test_string(min_allocator<char>());
#endif
return true;
diff --git a/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.char.pass.cpp b/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.char.pass.cpp
index 6a5929f82a59f65..eb9399d62eaa3b7 100644
--- a/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.char.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.char.pass.cpp
@@ -16,19 +16,21 @@
#include "test_macros.h"
+template <class S>
+constexpr void test_string() {
+ S s1{};
+ S s2{"abcde", 5};
+
+ ASSERT_NOEXCEPT(s1.starts_with('e'));
+
+ assert(!s1.starts_with('a'));
+ assert(!s1.starts_with('x'));
+ assert(s2.starts_with('a'));
+ assert(!s2.starts_with('x'));
+}
+
constexpr bool test() {
- {
- typedef std::string S;
- S s1{};
- S s2{"abcde", 5};
-
- ASSERT_NOEXCEPT(s1.starts_with('e'));
-
- assert(!s1.starts_with('a'));
- assert(!s1.starts_with('x'));
- assert(s2.starts_with('a'));
- assert(!s2.starts_with('x'));
- }
+ test_string<std::string>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.ptr.pass.cpp b/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.ptr.pass.cpp
index 8f0dc046c83a406..3647489a0f15f3e 100644
--- a/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.ptr.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.ptr.pass.cpp
@@ -16,47 +16,49 @@
#include "test_macros.h"
-constexpr bool test() {
- {
- typedef std::string S;
- const char* s = "abcde";
- S s0{};
- S s1{s, 1};
- S s2{s, 2};
- // S s3 { s, 3 };
- // S s4 { s, 4 };
- // S s5 { s, 5 };
- S sNot{"def", 3};
+template <class S>
+constexpr void test_string() {
+ const char* s = "abcde";
+ S s0{};
+ S s1{s, 1};
+ S s2{s, 2};
+ // S s3 { s, 3 };
+ // S s4 { s, 4 };
+ // S s5 { s, 5 };
+ S sNot{"def", 3};
+
+ LIBCPP_ASSERT_NOEXCEPT(s0.starts_with(""));
- LIBCPP_ASSERT_NOEXCEPT(s0.starts_with(""));
+ assert(s0.starts_with(""));
+ assert(!s0.starts_with("a"));
- assert(s0.starts_with(""));
- assert(!s0.starts_with("a"));
+ assert(s1.starts_with(""));
+ assert(s1.starts_with("a"));
+ assert(!s1.starts_with("ab"));
+ assert(!s1.starts_with("abc"));
+ assert(!s1.starts_with("abcd"));
+ assert(!s1.starts_with("abcde"));
+ assert(!s1.starts_with("def"));
- assert(s1.starts_with(""));
- assert(s1.starts_with("a"));
- assert(!s1.starts_with("ab"));
- assert(!s1.starts_with("abc"));
- assert(!s1.starts_with("abcd"));
- assert(!s1.starts_with("abcde"));
- assert(!s1.starts_with("def"));
+ assert(s2.starts_with(""));
+ assert(s2.starts_with("a"));
+ assert(s2.starts_with("ab"));
+ assert(!s2.starts_with("abc"));
+ assert(!s2.starts_with("abcd"));
+ assert(!s2.starts_with("abcde"));
+ assert(!s2.starts_with("def"));
- assert(s2.starts_with(""));
- assert(s2.starts_with("a"));
- assert(s2.starts_with("ab"));
- assert(!s2.starts_with("abc"));
- assert(!s2.starts_with("abcd"));
- assert(!s2.starts_with("abcde"));
- assert(!s2.starts_with("def"));
+ assert(sNot.starts_with(""));
+ assert(!sNot.starts_with("a"));
+ assert(!sNot.starts_with("ab"));
+ assert(!sNot.starts_with("abc"));
+ assert(!sNot.starts_with("abcd"));
+ assert(!sNot.starts_with("abcde"));
+ assert(sNot.starts_with("def"));
+}
- assert(sNot.starts_with(""));
- assert(!sNot.starts_with("a"));
- assert(!sNot.starts_with("ab"));
- assert(!sNot.starts_with("abc"));
- assert(!sNot.starts_with("abcd"));
- assert(!sNot.starts_with("abcde"));
- assert(sNot.starts_with("def"));
- }
+constexpr bool test() {
+ test_string<std::string>();
return true;
}
diff --git a/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.string_view.pass.cpp b/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.string_view.pass.cpp
index c3c1eb03ba23cfc..c09afbae378498f 100644
--- a/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.string_view.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.starts_with/starts_with.string_view.pass.cpp
@@ -16,9 +16,10 @@
#include "test_macros.h"
-constexpr bool test() {
- typedef std::string S;
- typedef std::string_view SV;
+template <class CharT, template <class> class Alloc>
+constexpr void test_string() {
+ using S = std::basic_string<CharT, std::char_traits<CharT>, Alloc<CharT> >;
+ using SV = std::basic_string_view<CharT, std::char_traits<CharT> >;
const char* s = "abcde";
S s0;
@@ -65,6 +66,10 @@ constexpr bool test() {
assert(!sNot.starts_with(sv4));
assert(!sNot.starts_with(sv5));
assert(sNot.starts_with(svNot));
+}
+
+constexpr bool test() {
+ test_string<char, std::allocator>();
return true;
}
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 0efbe4c78b5490c..e071aaabc6f41b7 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -5608,7 +5608,6 @@ libcxx/test/std/re/re.traits/translate_nocase.pass.cpp
libcxx/test/std/re/re.traits/translate.pass.cpp
libcxx/test/std/re/re.traits/types.pass.cpp
libcxx/test/std/re/re.traits/value.pass.cpp
-libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
libcxx/test/std/thread/futures/futures.async/async.pass.cpp
libcxx/test/std/thread/futures/futures.async/async_race.38682.pass.cpp
libcxx/test/std/thread/futures/futures.async/async_race.pass.cpp
More information about the libcxx-commits
mailing list