mirror of
https://github.com/clang-retro/llvm.git
synced 2026-12-04 08:09:27 -08:00
[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@esrlabs.com>
This commit is contained in:
1 parent
47b7f33b13
commit
6e1dcc9335
149 files changed
+2959
-4153
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user