[libc++][NFC] Remove some of the code duplication in the string tests

Reviewed By: ldionne, #libc, huixie90

Spies: huixie90, libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D131856
This commit is contained in:
Nikolas Klauser
2022-08-26 17:48:11 +02:00
parent 9343ec861a
commit 786366b18f
67 changed files with 1709 additions and 3048 deletions

View File

@@ -71,59 +71,38 @@ test_npos(S s, SV sv, typename S::size_type pos, S expected)
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
typedef std::string_view SV;
test(S(), SV(), 0, 0, S());
test(S(), SV(), 1, 0, S());
test(S(), SV("12345"), 0, 3, S("123"));
test(S(), SV("12345"), 1, 4, S("2345"));
test(S(), SV("12345"), 3, 15, S("45"));
test(S(), SV("12345"), 5, 15, S(""));
test(S(), SV("12345"), 6, 15, S("not happening"));
test(S(), SV("12345678901234567890"), 0, 0, S());
test(S(), SV("12345678901234567890"), 1, 1, S("2"));
test(S(), SV("12345678901234567890"), 2, 3, S("345"));
test(S(), SV("12345678901234567890"), 12, 13, S("34567890"));
test(S(), SV("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), SV(), 0, 0, S("12345"));
test(S("12345"), SV("12345"), 2, 2, S("1234534"));
test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890"));
test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890"));
test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(), SV(), 0, 0, S());
test(S(), SV(), 1, 0, S());
test(S(), SV("12345"), 0, 3, S("123"));
test(S(), SV("12345"), 1, 4, S("2345"));
test(S(), SV("12345"), 3, 15, S("45"));
test(S(), SV("12345"), 5, 15, S(""));
test(S(), SV("12345"), 6, 15, S("not happening"));
test(S(), SV("12345678901234567890"), 0, 0, S());
test(S(), SV("12345678901234567890"), 1, 1, S("2"));
test(S(), SV("12345678901234567890"), 2, 3, S("345"));
test(S(), SV("12345678901234567890"), 12, 13, S("34567890"));
test(S(), SV("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), SV(), 0, 0, S("12345"));
test(S("12345"), SV("12345"), 2, 2, S("1234534"));
test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890"));
test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890"));
test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
test_string<std::string>();
#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(), 0, 0, S());
test(S(), SV(), 1, 0, S());
test(S(), SV("12345"), 0, 3, S("123"));
test(S(), SV("12345"), 1, 4, S("2345"));
test(S(), SV("12345"), 3, 15, S("45"));
test(S(), SV("12345"), 5, 15, S(""));
test(S(), SV("12345"), 6, 15, S("not happening"));
test(S(), SV("12345678901234567890"), 0, 0, S());
test(S(), SV("12345678901234567890"), 1, 1, S("2"));
test(S(), SV("12345678901234567890"), 2, 3, S("345"));
test(S(), SV("12345678901234567890"), 12, 13, S("34567890"));
test(S(), SV("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), SV(), 0, 0, S("12345"));
test(S("12345"), SV("12345"), 2, 2, S("1234534"));
test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890"));
test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890"));
test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{
typedef std::string S;
typedef std::string_view SV;
@@ -195,7 +174,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
s.append(sv, 0, std::string::npos);
assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
return true;
}

View File

@@ -52,125 +52,71 @@ test_exceptions(S s, It first, It last)
}
#endif
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() {
{
typedef std::string S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
test(S(), s, s+1, S("A"));
test(S(), s, s+10, S("ABCDEFGHIJ"));
test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), s, s, S("12345"));
test(S("12345"), s, s+1, S("12345A"));
test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), s, s, S("1234567890"));
test(S("1234567890"), s, s+1, S("1234567890A"));
test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), s, s, S("12345678901234567890"));
test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
test(S("12345678901234567890"), s, s+52,
S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), cpp17_input_iterator<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_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
test(S(), s, s+1, S("A"));
test(S(), s, s+10, S("ABCDEFGHIJ"));
test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), s, s, S("12345"));
test(S("12345"), s, s+1, S("12345A"));
test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), s, s, S("1234567890"));
test(S("1234567890"), s, s+1, S("1234567890A"));
test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), s, s, S("12345678901234567890"));
test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
test(S("12345678901234567890"), s, s+52,
S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), cpp17_input_iterator<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_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
#ifndef TEST_HAS_NO_EXCEPTIONS
if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw
typedef std::string S;

View File

@@ -26,38 +26,26 @@ test(S s, const typename S::value_type* str, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), "", S());
test(S(), "12345", S("12345"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S("12345"));
test(S("12345"), "12345", S("1234512345"));
test(S("12345"), "1234567890", S("123451234567890"));
test(S("12345678901234567890"), "", S("12345678901234567890"));
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890",
S("1234567890123456789012345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), "", S());
test(S(), "12345", S("12345"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S("12345"));
test(S("12345"), "12345", S("1234512345"));
test(S("12345"), "1234567890", S("123451234567890"));
test(S("12345678901234567890"), "", S("12345678901234567890"));
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890",
S("1234567890123456789012345678901234567890"));
}
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(), "12345", S("12345"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S("12345"));
test(S("12345"), "12345", S("1234512345"));
test(S("12345"), "1234567890", S("123451234567890"));
test(S("12345678901234567890"), "", S("12345678901234567890"));
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890",
S("1234567890123456789012345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{ // test appending to self
@@ -75,7 +63,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
s_long.append(s_long.c_str());
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
}
return true;
}

View File

@@ -27,46 +27,30 @@ test(S s, const typename S::value_type* str, typename S::size_type n, S expected
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S("12345"));
test(S("12345"), "12345", 5, S("1234512345"));
test(S("12345"), "1234567890", 10, S("123451234567890"));
test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("1234567890123456789012345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S("12345"));
test(S("12345"), "12345", 5, S("1234512345"));
test(S("12345"), "1234567890", 10, S("123451234567890"));
test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("1234567890123456789012345678901234567890"));
}
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, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S("12345"));
test(S("12345"), "12345", 5, S("1234512345"));
test(S("12345"), "1234567890", 10, S("123451234567890"));
test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("1234567890123456789012345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{ // test appending to self

View File

@@ -26,38 +26,26 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S("12345"));
test(S("12345"), 1, 'a', S("12345a"));
test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S("12345"));
test(S("12345"), 1, 'a', S("12345a"));
test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
}
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, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S("12345"));
test(S("12345"), 1, 'a', S("12345a"));
test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -26,57 +26,37 @@ test(S s, S str, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S("12345"));
test(S("12345"), S("12345"), S("1234512345"));
test(S("12345"), S("1234567890"), S("123451234567890"));
test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), S(), S("1234567890"));
test(S("1234567890"), S("12345"), S("123456789012345"));
test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S(), S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S("12345"));
test(S("12345"), S("12345"), S("1234512345"));
test(S("12345"), S("1234567890"), S("123451234567890"));
test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), S(), S("1234567890"));
test(S("1234567890"), S("12345"), S("123456789012345"));
test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S(), S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S("12345"));
test(S("12345"), S("12345"), S("1234512345"));
test(S("12345"), S("1234567890"), S("123451234567890"));
test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), S(), S("1234567890"));
test(S("1234567890"), S("12345"), S("123456789012345"));
test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S(), S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
#if TEST_STD_VER > 3
#if TEST_STD_VER >= 11
{ // LWG 2946
std::string s;
s.append({"abc", 1});

View File

@@ -71,57 +71,37 @@ test_npos(S s, S str, typename S::size_type pos, S expected)
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S("12345"));
test(S("12345"), S("12345"), 2, 2, S("1234534"));
test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S("12345"));
test(S("12345"), S("12345"), 2, 2, S("1234534"));
test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S("12345"));
test(S("12345"), S("12345"), 2, 2, S("1234534"));
test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("123456789012345678906789012345"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{
typedef std::string S;
test_npos(S(), S(), 0, S());

View File

@@ -27,56 +27,35 @@ test(S s, SV sv, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
typedef std::string_view SV;
test(S(), SV(), S());
test(S(), SV("12345"), S("12345"));
test(S(), SV("1234567890"), S("1234567890"));
test(S(), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), SV(), S("12345"));
test(S("12345"), SV("12345"), S("1234512345"));
test(S("12345"), SV("1234567890"), S("123451234567890"));
test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), SV(), S("1234567890"));
test(S("1234567890"), SV("12345"), S("123456789012345"));
test(S("1234567890"), SV("1234567890"), S("12345678901234567890"));
test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), SV(), S("12345678901234567890"));
test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), SV("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(), SV(), S());
test(S(), SV("12345"), S("12345"));
test(S(), SV("1234567890"), S("1234567890"));
test(S(), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), SV(), S("12345"));
test(S("12345"), SV("12345"), S("1234512345"));
test(S("12345"), SV("1234567890"), S("123451234567890"));
test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), SV(), S("1234567890"));
test(S("1234567890"), SV("12345"), S("123456789012345"));
test(S("1234567890"), SV("1234567890"), S("12345678901234567890"));
test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), SV(), S("12345678901234567890"));
test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), SV("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
test_string<std::string>();
#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(), S());
test(S(), SV("12345"), S("12345"));
test(S(), SV("1234567890"), S("1234567890"));
test(S(), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), SV(), S("12345"));
test(S("12345"), SV("12345"), S("1234512345"));
test(S("12345"), SV("1234567890"), S("123451234567890"));
test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), SV(), S("1234567890"));
test(S("1234567890"), SV("12345"), S("123456789012345"));
test(S("1234567890"), SV("1234567890"), S("12345678901234567890"));
test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), SV(), S("12345678901234567890"));
test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), SV("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -70,59 +70,38 @@ test_npos(S s, SV sv, typename S::size_type pos, S expected)
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
typedef std::string_view SV;
test(S(), SV(), 0, 0, S());
test(S(), SV(), 1, 0, S());
test(S(), SV("12345"), 0, 3, S("123"));
test(S(), SV("12345"), 1, 4, S("2345"));
test(S(), SV("12345"), 3, 15, S("45"));
test(S(), SV("12345"), 5, 15, S(""));
test(S(), SV("12345"), 6, 15, S("not happening"));
test(S(), SV("12345678901234567890"), 0, 0, S());
test(S(), SV("12345678901234567890"), 1, 1, S("2"));
test(S(), SV("12345678901234567890"), 2, 3, S("345"));
test(S(), SV("12345678901234567890"), 12, 13, S("34567890"));
test(S(), SV("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), SV(), 0, 0, S());
test(S("12345"), SV("12345"), 2, 2, S("34"));
test(S("12345"), SV("1234567890"), 0, 100, S("1234567890"));
test(S("12345678901234567890"), SV(), 0, 0, S());
test(S("12345678901234567890"), SV("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
S("6789012345"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(), SV(), 0, 0, S());
test(S(), SV(), 1, 0, S());
test(S(), SV("12345"), 0, 3, S("123"));
test(S(), SV("12345"), 1, 4, S("2345"));
test(S(), SV("12345"), 3, 15, S("45"));
test(S(), SV("12345"), 5, 15, S(""));
test(S(), SV("12345"), 6, 15, S("not happening"));
test(S(), SV("12345678901234567890"), 0, 0, S());
test(S(), SV("12345678901234567890"), 1, 1, S("2"));
test(S(), SV("12345678901234567890"), 2, 3, S("345"));
test(S(), SV("12345678901234567890"), 12, 13, S("34567890"));
test(S(), SV("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), SV(), 0, 0, S());
test(S("12345"), SV("12345"), 2, 2, S("34"));
test(S("12345"), SV("1234567890"), 0, 100, S("1234567890"));
test(S("12345678901234567890"), SV(), 0, 0, S());
test(S("12345678901234567890"), SV("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
S("6789012345"));
}
test_string<std::string>();
#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(), 0, 0, S());
test(S(), SV(), 1, 0, S());
test(S(), SV("12345"), 0, 3, S("123"));
test(S(), SV("12345"), 1, 4, S("2345"));
test(S(), SV("12345"), 3, 15, S("45"));
test(S(), SV("12345"), 5, 15, S(""));
test(S(), SV("12345"), 6, 15, S("not happening"));
test(S(), SV("12345678901234567890"), 0, 0, S());
test(S(), SV("12345678901234567890"), 1, 1, S("2"));
test(S(), SV("12345678901234567890"), 2, 3, S("345"));
test(S(), SV("12345678901234567890"), 12, 13, S("34567890"));
test(S(), SV("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), SV(), 0, 0, S());
test(S("12345"), SV("12345"), 2, 2, S("34"));
test(S("12345"), SV("1234567890"), 0, 100, S("1234567890"));
test(S("12345678901234567890"), SV(), 0, 0, S());
test(S("12345678901234567890"), SV("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
S("6789012345"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{
typedef std::string S;
typedef std::string_view SV;
@@ -190,7 +169,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
s.assign(sv, 0, std::string::npos);
assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
return true;
}

View File

@@ -52,125 +52,71 @@ test_exceptions(S s, It first, It last)
}
#endif
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() {
{
typedef std::string S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
test(S(), s, s+1, S("A"));
test(S(), s, s+10, S("ABCDEFGHIJ"));
test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), s, s, S());
test(S("12345"), s, s+1, S("A"));
test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), s, s, S());
test(S("1234567890"), s, s+1, S("A"));
test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), s, s, S());
test(S("12345678901234567890"), s, s+1, S("A"));
test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
test(S("12345678901234567890"), s, s+52,
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), cpp17_input_iterator<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_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), s, s, S());
test(S(), s, s+1, S("A"));
test(S(), s, s+10, S("ABCDEFGHIJ"));
test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), s, s, S());
test(S("12345"), s, s+1, S("A"));
test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), s, s, S());
test(S("1234567890"), s, s+1, S("A"));
test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345678901234567890"), s, s, S());
test(S("12345678901234567890"), s, s+1, S("A"));
test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
test(S("12345678901234567890"), s, s+52,
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), cpp17_input_iterator<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_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
#ifndef TEST_HAS_NO_EXCEPTIONS
if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw
typedef std::string S;
@@ -222,7 +168,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
std::string expected = sneaky + std::string(1, '\0');
test(sneaky, sneaky.data(), sneaky.data() + sneaky.size() + 1, expected);
}
return true;
}

View File

@@ -26,38 +26,26 @@ test(S s, const typename S::value_type* str, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), "", S());
test(S(), "12345", S("12345"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S());
test(S("12345"), "12345", S("12345"));
test(S("12345"), "1234567890", S("1234567890"));
test(S("12345678901234567890"), "", S());
test(S("12345678901234567890"), "12345", S("12345"));
test(S("12345678901234567890"), "12345678901234567890",
S("12345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), "", S());
test(S(), "12345", S("12345"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S());
test(S("12345"), "12345", S("12345"));
test(S("12345"), "1234567890", S("1234567890"));
test(S("12345678901234567890"), "", S());
test(S("12345678901234567890"), "12345", S("12345"));
test(S("12345678901234567890"), "12345678901234567890",
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(), "12345", S("12345"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S());
test(S("12345"), "12345", S("12345"));
test(S("12345"), "1234567890", S("1234567890"));
test(S("12345678901234567890"), "", S());
test(S("12345678901234567890"), "12345", S("12345"));
test(S("12345678901234567890"), "12345678901234567890",
S("12345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{ // test assignment to self

View File

@@ -27,47 +27,32 @@ test(S s, const typename S::value_type* str, typename S::size_type n, S expected
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S());
test(S("12345"), "12345", 5, S("12345"));
test(S("12345"), "1234567890", 10, S("1234567890"));
test(S("12345678901234567890"), "", 0, S());
test(S("12345678901234567890"), "12345", 5, S("12345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("12345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), "", 0, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S());
test(S("12345"), "12345", 5, S("12345"));
test(S("12345"), "1234567890", 10, S("1234567890"));
test(S("12345678901234567890"), "", 0, S());
test(S("12345678901234567890"), "12345", 5, S("12345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
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(), "", 0, S());
test(S(), "12345", 3, S("123"));
test(S(), "12345", 4, S("1234"));
test(S(), "12345678901234567890", 0, S());
test(S(), "12345678901234567890", 1, S("1"));
test(S(), "12345678901234567890", 3, S("123"));
test(S(), "12345678901234567890", 20, S("12345678901234567890"));
test(S("12345"), "", 0, S());
test(S("12345"), "12345", 5, S("12345"));
test(S("12345"), "1234567890", 10, S("1234567890"));
test(S("12345678901234567890"), "", 0, S());
test(S("12345678901234567890"), "12345", 5, S("12345"));
test(S("12345678901234567890"), "12345678901234567890", 20,
S("12345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{ // test assign to self
typedef std::string S;
S s_short = "123/";
@@ -84,7 +69,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
s_long.assign(s_long.data() + 2, 8 );
assert(s_long == "rem ipsu");
}
return true;
}

View File

@@ -27,54 +27,34 @@ test(S s, S str, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S());
test(S("12345"), S("12345"), S("12345"));
test(S("12345"), S("1234567890"), S("1234567890"));
test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), S(), S());
test(S("1234567890"), S("12345"), S("12345"));
test(S("1234567890"), S("1234567890"), S("1234567890"));
test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), S(), S());
test(S("12345678901234567890"), S("12345"), S("12345"));
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S());
test(S("12345"), S("12345"), S("12345"));
test(S("12345"), S("1234567890"), S("1234567890"));
test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), S(), S());
test(S("1234567890"), S("12345"), S("12345"));
test(S("1234567890"), S("1234567890"), S("1234567890"));
test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), S(), S());
test(S("12345678901234567890"), S("12345"), S("12345"));
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S());
test(S("12345"), S("12345"), S("12345"));
test(S("12345"), S("1234567890"), S("1234567890"));
test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), S(), S());
test(S("1234567890"), S("12345"), S("12345"));
test(S("1234567890"), S("1234567890"), S("1234567890"));
test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), S(), S());
test(S("12345678901234567890"), S("12345"), S("12345"));
test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("12345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -26,38 +26,26 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S());
test(S("12345"), 1, 'a', S(1, 'a'));
test(S("12345"), 10, 'a', S(10, 'a'));
test(S("12345678901234567890"), 0, 'a', S());
test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), 0, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S());
test(S("12345"), 1, 'a', S(1, 'a'));
test(S("12345"), 10, 'a', S(10, 'a'));
test(S("12345678901234567890"), 0, 'a', S());
test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
}
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, 'a', S());
test(S(), 1, 'a', S(1, 'a'));
test(S(), 10, 'a', S(10, 'a'));
test(S(), 100, 'a', S(100, 'a'));
test(S("12345"), 0, 'a', S());
test(S("12345"), 1, 'a', S(1, 'a'));
test(S("12345"), 10, 'a', S(10, 'a'));
test(S("12345678901234567890"), 0, 'a', S());
test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -71,57 +71,37 @@ test_npos(S s, S str, typename S::size_type pos, S expected)
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S());
test(S("12345"), S("12345"), 2, 2, S("34"));
test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
test(S("12345678901234567890"), S(), 0, 0, S());
test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("6789012345"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S());
test(S("12345"), S("12345"), 2, 2, S("34"));
test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
test(S("12345678901234567890"), S(), 0, 0, S());
test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("6789012345"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), 0, 0, S());
test(S(), S(), 1, 0, S());
test(S(), S("12345"), 0, 3, S("123"));
test(S(), S("12345"), 1, 4, S("2345"));
test(S(), S("12345"), 3, 15, S("45"));
test(S(), S("12345"), 5, 15, S(""));
test(S(), S("12345"), 6, 15, S("not happening"));
test(S(), S("12345678901234567890"), 0, 0, S());
test(S(), S("12345678901234567890"), 1, 1, S("2"));
test(S(), S("12345678901234567890"), 2, 3, S("345"));
test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
test(S("12345"), S(), 0, 0, S());
test(S("12345"), S("12345"), 2, 2, S("34"));
test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
test(S("12345678901234567890"), S(), 0, 0, S());
test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
S("6789012345"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{
typedef std::string S;
test_npos(S(), S(), 0, S());

View File

@@ -38,67 +38,42 @@ testAlloc(S s, SV sv, const typename S::allocator_type& a)
assert(s.get_allocator() == a);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
typedef std::string_view SV;
test(S(), SV(), S());
test(S(), SV("12345"), S("12345"));
test(S(), SV("1234567890"), S("1234567890"));
test(S(), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), SV(), S());
test(S("12345"), SV("12345"), S("12345"));
test(S("12345"), SV("1234567890"), S("1234567890"));
test(S("12345"), SV("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), SV(), S());
test(S("1234567890"), SV("12345"), S("12345"));
test(S("1234567890"), SV("1234567890"), S("1234567890"));
test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), SV(), S());
test(S("12345678901234567890"), SV("12345"), S("12345"));
test(S("12345678901234567890"), SV("1234567890"), S("1234567890"));
test(S("12345678901234567890"), SV("12345678901234567890"),
S("12345678901234567890"));
using A = typename S::allocator_type;
testAlloc(S(), SV(), A());
testAlloc(S(), SV("12345"), A());
testAlloc(S(), SV("1234567890"), A());
testAlloc(S(), SV("12345678901234567890"), A());
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(), SV(), S());
test(S(), SV("12345"), S("12345"));
test(S(), SV("1234567890"), S("1234567890"));
test(S(), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), SV(), S());
test(S("12345"), SV("12345"), S("12345"));
test(S("12345"), SV("1234567890"), S("1234567890"));
test(S("12345"), SV("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), SV(), S());
test(S("1234567890"), SV("12345"), S("12345"));
test(S("1234567890"), SV("1234567890"), S("1234567890"));
test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), SV(), S());
test(S("12345678901234567890"), SV("12345"), S("12345"));
test(S("12345678901234567890"), SV("1234567890"), S("1234567890"));
test(S("12345678901234567890"), SV("12345678901234567890"),
S("12345678901234567890"));
testAlloc(S(), SV(), std::allocator<char>());
testAlloc(S(), SV("12345"), std::allocator<char>());
testAlloc(S(), SV("1234567890"), std::allocator<char>());
testAlloc(S(), SV("12345678901234567890"), std::allocator<char>());
}
test_string<std::string>();
#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(), S());
test(S(), SV("12345"), S("12345"));
test(S(), SV("1234567890"), S("1234567890"));
test(S(), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), SV(), S());
test(S("12345"), SV("12345"), S("12345"));
test(S("12345"), SV("1234567890"), S("1234567890"));
test(S("12345"), SV("12345678901234567890"), S("12345678901234567890"));
test(S("1234567890"), SV(), S());
test(S("1234567890"), SV("12345"), S("12345"));
test(S("1234567890"), SV("1234567890"), S("1234567890"));
test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890"));
test(S("12345678901234567890"), SV(), S());
test(S("12345678901234567890"), SV("12345"), S("12345"));
test(S("12345678901234567890"), SV("1234567890"), S("1234567890"));
test(S("12345678901234567890"), SV("12345678901234567890"),
S("12345678901234567890"));
testAlloc(S(), SV(), min_allocator<char>());
testAlloc(S(), SV("12345"), min_allocator<char>());
testAlloc(S(), SV("1234567890"), min_allocator<char>());
testAlloc(S(), SV("12345678901234567890"), min_allocator<char>());
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -49,132 +49,73 @@ test(S str, typename S::value_type* s, typename S::size_type n,
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
char s[50];
test(S(""), s, 0, 0);
test(S(""), s, 0, 1);
test(S(""), s, 1, 0);
test(S("abcde"), s, 0, 0);
test(S("abcde"), s, 0, 1);
test(S("abcde"), s, 0, 2);
test(S("abcde"), s, 0, 4);
test(S("abcde"), s, 0, 5);
test(S("abcde"), s, 0, 6);
test(S("abcde"), s, 1, 0);
test(S("abcde"), s, 1, 1);
test(S("abcde"), s, 1, 2);
test(S("abcde"), s, 1, 4);
test(S("abcde"), s, 1, 5);
test(S("abcde"), s, 2, 0);
test(S("abcde"), s, 2, 1);
test(S("abcde"), s, 2, 2);
test(S("abcde"), s, 2, 4);
test(S("abcde"), s, 4, 0);
test(S("abcde"), s, 4, 1);
test(S("abcde"), s, 4, 2);
test(S("abcde"), s, 5, 0);
test(S("abcde"), s, 5, 1);
test(S("abcde"), s, 6, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 1);
test(S("abcdefghijklmnopqrst"), s, 0, 2);
test(S("abcdefghijklmnopqrst"), s, 0, 10);
test(S("abcdefghijklmnopqrst"), s, 0, 19);
test(S("abcdefghijklmnopqrst"), s, 0, 20);
test(S("abcdefghijklmnopqrst"), s, 0, 21);
test(S("abcdefghijklmnopqrst"), s, 1, 0);
test(S("abcdefghijklmnopqrst"), s, 1, 1);
test(S("abcdefghijklmnopqrst"), s, 1, 2);
test(S("abcdefghijklmnopqrst"), s, 1, 9);
test(S("abcdefghijklmnopqrst"), s, 1, 18);
test(S("abcdefghijklmnopqrst"), s, 1, 19);
test(S("abcdefghijklmnopqrst"), s, 1, 20);
test(S("abcdefghijklmnopqrst"), s, 2, 0);
test(S("abcdefghijklmnopqrst"), s, 2, 1);
test(S("abcdefghijklmnopqrst"), s, 2, 2);
test(S("abcdefghijklmnopqrst"), s, 2, 9);
test(S("abcdefghijklmnopqrst"), s, 2, 17);
test(S("abcdefghijklmnopqrst"), s, 2, 18);
test(S("abcdefghijklmnopqrst"), s, 2, 19);
test(S("abcdefghijklmnopqrst"), s, 10, 0);
test(S("abcdefghijklmnopqrst"), s, 10, 1);
test(S("abcdefghijklmnopqrst"), s, 10, 2);
test(S("abcdefghijklmnopqrst"), s, 10, 5);
test(S("abcdefghijklmnopqrst"), s, 10, 9);
test(S("abcdefghijklmnopqrst"), s, 10, 10);
test(S("abcdefghijklmnopqrst"), s, 10, 11);
test(S("abcdefghijklmnopqrst"), s, 19, 0);
test(S("abcdefghijklmnopqrst"), s, 19, 1);
test(S("abcdefghijklmnopqrst"), s, 19, 2);
test(S("abcdefghijklmnopqrst"), s, 20, 0);
test(S("abcdefghijklmnopqrst"), s, 20, 1);
test(S("abcdefghijklmnopqrst"), s, 21, 0);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
char s[50];
test(S(""), s, 0, 0);
test(S(""), s, 0, 1);
test(S(""), s, 1, 0);
test(S("abcde"), s, 0, 0);
test(S("abcde"), s, 0, 1);
test(S("abcde"), s, 0, 2);
test(S("abcde"), s, 0, 4);
test(S("abcde"), s, 0, 5);
test(S("abcde"), s, 0, 6);
test(S("abcde"), s, 1, 0);
test(S("abcde"), s, 1, 1);
test(S("abcde"), s, 1, 2);
test(S("abcde"), s, 1, 4);
test(S("abcde"), s, 1, 5);
test(S("abcde"), s, 2, 0);
test(S("abcde"), s, 2, 1);
test(S("abcde"), s, 2, 2);
test(S("abcde"), s, 2, 4);
test(S("abcde"), s, 4, 0);
test(S("abcde"), s, 4, 1);
test(S("abcde"), s, 4, 2);
test(S("abcde"), s, 5, 0);
test(S("abcde"), s, 5, 1);
test(S("abcde"), s, 6, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 1);
test(S("abcdefghijklmnopqrst"), s, 0, 2);
test(S("abcdefghijklmnopqrst"), s, 0, 10);
test(S("abcdefghijklmnopqrst"), s, 0, 19);
test(S("abcdefghijklmnopqrst"), s, 0, 20);
test(S("abcdefghijklmnopqrst"), s, 0, 21);
test(S("abcdefghijklmnopqrst"), s, 1, 0);
test(S("abcdefghijklmnopqrst"), s, 1, 1);
test(S("abcdefghijklmnopqrst"), s, 1, 2);
test(S("abcdefghijklmnopqrst"), s, 1, 9);
test(S("abcdefghijklmnopqrst"), s, 1, 18);
test(S("abcdefghijklmnopqrst"), s, 1, 19);
test(S("abcdefghijklmnopqrst"), s, 1, 20);
test(S("abcdefghijklmnopqrst"), s, 2, 0);
test(S("abcdefghijklmnopqrst"), s, 2, 1);
test(S("abcdefghijklmnopqrst"), s, 2, 2);
test(S("abcdefghijklmnopqrst"), s, 2, 9);
test(S("abcdefghijklmnopqrst"), s, 2, 17);
test(S("abcdefghijklmnopqrst"), s, 2, 18);
test(S("abcdefghijklmnopqrst"), s, 2, 19);
test(S("abcdefghijklmnopqrst"), s, 10, 0);
test(S("abcdefghijklmnopqrst"), s, 10, 1);
test(S("abcdefghijklmnopqrst"), s, 10, 2);
test(S("abcdefghijklmnopqrst"), s, 10, 5);
test(S("abcdefghijklmnopqrst"), s, 10, 9);
test(S("abcdefghijklmnopqrst"), s, 10, 10);
test(S("abcdefghijklmnopqrst"), s, 10, 11);
test(S("abcdefghijklmnopqrst"), s, 19, 0);
test(S("abcdefghijklmnopqrst"), s, 19, 1);
test(S("abcdefghijklmnopqrst"), s, 19, 2);
test(S("abcdefghijklmnopqrst"), s, 20, 0);
test(S("abcdefghijklmnopqrst"), s, 20, 1);
test(S("abcdefghijklmnopqrst"), s, 21, 0);
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
char s[50];
test(S(""), s, 0, 0);
test(S(""), s, 0, 1);
test(S(""), s, 1, 0);
test(S("abcde"), s, 0, 0);
test(S("abcde"), s, 0, 1);
test(S("abcde"), s, 0, 2);
test(S("abcde"), s, 0, 4);
test(S("abcde"), s, 0, 5);
test(S("abcde"), s, 0, 6);
test(S("abcde"), s, 1, 0);
test(S("abcde"), s, 1, 1);
test(S("abcde"), s, 1, 2);
test(S("abcde"), s, 1, 4);
test(S("abcde"), s, 1, 5);
test(S("abcde"), s, 2, 0);
test(S("abcde"), s, 2, 1);
test(S("abcde"), s, 2, 2);
test(S("abcde"), s, 2, 4);
test(S("abcde"), s, 4, 0);
test(S("abcde"), s, 4, 1);
test(S("abcde"), s, 4, 2);
test(S("abcde"), s, 5, 0);
test(S("abcde"), s, 5, 1);
test(S("abcde"), s, 6, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 0);
test(S("abcdefghijklmnopqrst"), s, 0, 1);
test(S("abcdefghijklmnopqrst"), s, 0, 2);
test(S("abcdefghijklmnopqrst"), s, 0, 10);
test(S("abcdefghijklmnopqrst"), s, 0, 19);
test(S("abcdefghijklmnopqrst"), s, 0, 20);
test(S("abcdefghijklmnopqrst"), s, 0, 21);
test(S("abcdefghijklmnopqrst"), s, 1, 0);
test(S("abcdefghijklmnopqrst"), s, 1, 1);
test(S("abcdefghijklmnopqrst"), s, 1, 2);
test(S("abcdefghijklmnopqrst"), s, 1, 9);
test(S("abcdefghijklmnopqrst"), s, 1, 18);
test(S("abcdefghijklmnopqrst"), s, 1, 19);
test(S("abcdefghijklmnopqrst"), s, 1, 20);
test(S("abcdefghijklmnopqrst"), s, 2, 0);
test(S("abcdefghijklmnopqrst"), s, 2, 1);
test(S("abcdefghijklmnopqrst"), s, 2, 2);
test(S("abcdefghijklmnopqrst"), s, 2, 9);
test(S("abcdefghijklmnopqrst"), s, 2, 17);
test(S("abcdefghijklmnopqrst"), s, 2, 18);
test(S("abcdefghijklmnopqrst"), s, 2, 19);
test(S("abcdefghijklmnopqrst"), s, 10, 0);
test(S("abcdefghijklmnopqrst"), s, 10, 1);
test(S("abcdefghijklmnopqrst"), s, 10, 2);
test(S("abcdefghijklmnopqrst"), s, 10, 5);
test(S("abcdefghijklmnopqrst"), s, 10, 9);
test(S("abcdefghijklmnopqrst"), s, 10, 10);
test(S("abcdefghijklmnopqrst"), s, 10, 11);
test(S("abcdefghijklmnopqrst"), s, 19, 0);
test(S("abcdefghijklmnopqrst"), s, 19, 1);
test(S("abcdefghijklmnopqrst"), s, 19, 2);
test(S("abcdefghijklmnopqrst"), s, 20, 0);
test(S("abcdefghijklmnopqrst"), s, 20, 1);
test(S("abcdefghijklmnopqrst"), s, 21, 0);
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -28,38 +28,26 @@ test(S s, typename S::difference_type pos, S expected)
assert(i - s.begin() == pos);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S("abcde"), 0, S("bcde"));
test(S("abcde"), 1, S("acde"));
test(S("abcde"), 2, S("abde"));
test(S("abcde"), 4, S("abcd"));
test(S("abcdefghij"), 0, S("bcdefghij"));
test(S("abcdefghij"), 1, S("acdefghij"));
test(S("abcdefghij"), 5, S("abcdeghij"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S("abcde"), 0, S("bcde"));
test(S("abcde"), 1, S("acde"));
test(S("abcde"), 2, S("abde"));
test(S("abcde"), 4, S("abcd"));
test(S("abcdefghij"), 0, S("bcdefghij"));
test(S("abcdefghij"), 1, S("acdefghij"));
test(S("abcdefghij"), 5, S("abcdeghij"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S("abcde"), 0, S("bcde"));
test(S("abcde"), 1, S("acde"));
test(S("abcde"), 2, S("abde"));
test(S("abcde"), 4, S("abcd"));
test(S("abcdefghij"), 0, S("bcdefghij"));
test(S("abcdefghij"), 1, S("acdefghij"));
test(S("abcdefghij"), 5, S("abcdeghij"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -29,122 +29,68 @@ test(S s, typename S::difference_type pos, typename S::difference_type n, S expe
assert(i - s.begin() == pos);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(""), 0, 0, S(""));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), 0, 0, S(""));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 0, 0, S(""));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -26,20 +26,17 @@ test(S s, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S("abcde"), S("abcd"));
test(S("abcdefghij"), S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S("abcde"), S("abcd"));
test(S("abcdefghij"), S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S("abcde"), S("abcd"));
test(S("abcdefghij"), S("abcdefghi"));
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -88,214 +88,114 @@ test(S s, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(""), 0, 0, S(""));
test(S(""), 0, 1, S(""));
test(S(""), 1, 0, S("can't happen"));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 0, 6, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 1, 5, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 2, 4, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 4, 2, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcde"), 5, 1, S("abcde"));
test(S("abcde"), 6, 0, S("can't happen"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 0, 11, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 1, 10, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 5, 6, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 9, 2, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghij"), 10, 1, S("abcdefghij"));
test(S("abcdefghij"), 11, 0, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
test(S(""), 0, S(""));
test(S(""), 1, S("can't happen"));
test(S("abcde"), 0, S(""));
test(S("abcde"), 1, S("a"));
test(S("abcde"), 2, S("ab"));
test(S("abcde"), 4, S("abcd"));
test(S("abcde"), 5, S("abcde"));
test(S("abcde"), 6, S("can't happen"));
test(S("abcdefghij"), 0, S(""));
test(S("abcdefghij"), 1, S("a"));
test(S("abcdefghij"), 5, S("abcde"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghij"), 10, S("abcdefghij"));
test(S("abcdefghij"), 11, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, S(""));
test(S("abcdefghijklmnopqrst"), 1, S("a"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
test(S(""), S(""));
test(S("abcde"), S(""));
test(S("abcdefghij"), S(""));
test(S("abcdefghijklmnopqrst"), S(""));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), 0, 0, S(""));
test(S(""), 0, 1, S(""));
test(S(""), 1, 0, S("can't happen"));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 0, 6, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 1, 5, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 2, 4, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 4, 2, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcde"), 5, 1, S("abcde"));
test(S("abcde"), 6, 0, S("can't happen"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 0, 11, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 1, 10, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 5, 6, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 9, 2, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghij"), 10, 1, S("abcdefghij"));
test(S("abcdefghij"), 11, 0, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
test(S(""), 0, S(""));
test(S(""), 1, S("can't happen"));
test(S("abcde"), 0, S(""));
test(S("abcde"), 1, S("a"));
test(S("abcde"), 2, S("ab"));
test(S("abcde"), 4, S("abcd"));
test(S("abcde"), 5, S("abcde"));
test(S("abcde"), 6, S("can't happen"));
test(S("abcdefghij"), 0, S(""));
test(S("abcdefghij"), 1, S("a"));
test(S("abcdefghij"), 5, S("abcde"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghij"), 10, S("abcdefghij"));
test(S("abcdefghij"), 11, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, S(""));
test(S("abcdefghijklmnopqrst"), 1, S("a"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
test(S(""), S(""));
test(S("abcde"), S(""));
test(S("abcdefghij"), S(""));
test(S("abcdefghijklmnopqrst"), S(""));
}
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, 0, S(""));
test(S(""), 0, 1, S(""));
test(S(""), 1, 0, S("can't happen"));
test(S("abcde"), 0, 0, S("abcde"));
test(S("abcde"), 0, 1, S("bcde"));
test(S("abcde"), 0, 2, S("cde"));
test(S("abcde"), 0, 4, S("e"));
test(S("abcde"), 0, 5, S(""));
test(S("abcde"), 0, 6, S(""));
test(S("abcde"), 1, 0, S("abcde"));
test(S("abcde"), 1, 1, S("acde"));
test(S("abcde"), 1, 2, S("ade"));
test(S("abcde"), 1, 3, S("ae"));
test(S("abcde"), 1, 4, S("a"));
test(S("abcde"), 1, 5, S("a"));
test(S("abcde"), 2, 0, S("abcde"));
test(S("abcde"), 2, 1, S("abde"));
test(S("abcde"), 2, 2, S("abe"));
test(S("abcde"), 2, 3, S("ab"));
test(S("abcde"), 2, 4, S("ab"));
test(S("abcde"), 4, 0, S("abcde"));
test(S("abcde"), 4, 1, S("abcd"));
test(S("abcde"), 4, 2, S("abcd"));
test(S("abcde"), 5, 0, S("abcde"));
test(S("abcde"), 5, 1, S("abcde"));
test(S("abcde"), 6, 0, S("can't happen"));
test(S("abcdefghij"), 0, 0, S("abcdefghij"));
test(S("abcdefghij"), 0, 1, S("bcdefghij"));
test(S("abcdefghij"), 0, 5, S("fghij"));
test(S("abcdefghij"), 0, 9, S("j"));
test(S("abcdefghij"), 0, 10, S(""));
test(S("abcdefghij"), 0, 11, S(""));
test(S("abcdefghij"), 1, 0, S("abcdefghij"));
test(S("abcdefghij"), 1, 1, S("acdefghij"));
test(S("abcdefghij"), 1, 4, S("afghij"));
test(S("abcdefghij"), 1, 8, S("aj"));
test(S("abcdefghij"), 1, 9, S("a"));
test(S("abcdefghij"), 1, 10, S("a"));
test(S("abcdefghij"), 5, 0, S("abcdefghij"));
test(S("abcdefghij"), 5, 1, S("abcdeghij"));
test(S("abcdefghij"), 5, 2, S("abcdehij"));
test(S("abcdefghij"), 5, 4, S("abcdej"));
test(S("abcdefghij"), 5, 5, S("abcde"));
test(S("abcdefghij"), 5, 6, S("abcde"));
test(S("abcdefghij"), 9, 0, S("abcdefghij"));
test(S("abcdefghij"), 9, 1, S("abcdefghi"));
test(S("abcdefghij"), 9, 2, S("abcdefghi"));
test(S("abcdefghij"), 10, 0, S("abcdefghij"));
test(S("abcdefghij"), 10, 1, S("abcdefghij"));
test(S("abcdefghij"), 11, 0, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
test(S(""), 0, S(""));
test(S(""), 1, S("can't happen"));
test(S("abcde"), 0, S(""));
test(S("abcde"), 1, S("a"));
test(S("abcde"), 2, S("ab"));
test(S("abcde"), 4, S("abcd"));
test(S("abcde"), 5, S("abcde"));
test(S("abcde"), 6, S("can't happen"));
test(S("abcdefghij"), 0, S(""));
test(S("abcdefghij"), 1, S("a"));
test(S("abcdefghij"), 5, S("abcde"));
test(S("abcdefghij"), 9, S("abcdefghi"));
test(S("abcdefghij"), 10, S("abcdefghij"));
test(S("abcdefghij"), 11, S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, S(""));
test(S("abcdefghijklmnopqrst"), 1, S("a"));
test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
test(S(""), S(""));
test(S("abcde"), S(""));
test(S("abcdefghij"), S(""));
test(S("abcdefghijklmnopqrst"), S(""));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -32,44 +32,29 @@ test(S& s, typename S::const_iterator p, typename S::value_type c, S expected)
assert(i == p);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
S s;
test(s, s.begin(), '1', S("1"));
test(s, s.begin(), 'a', S("a1"));
test(s, s.end(), 'b', S("a1b"));
test(s, s.end()-1, 'c', S("a1cb"));
test(s, s.end()-2, 'd', S("a1dcb"));
test(s, s.end()-3, '2', S("a12dcb"));
test(s, s.end()-4, '3', S("a132dcb"));
test(s, s.end()-5, '4', S("a1432dcb"));
test(s, s.begin()+1, '5', S("a51432dcb"));
test(s, s.begin()+2, '6', S("a561432dcb"));
test(s, s.begin()+3, '7', S("a5671432dcb"));
test(s, s.begin()+4, 'A', S("a567A1432dcb"));
test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
S s;
test(s, s.begin(), '1', S("1"));
test(s, s.begin(), 'a', S("a1"));
test(s, s.end(), 'b', S("a1b"));
test(s, s.end()-1, 'c', S("a1cb"));
test(s, s.end()-2, 'd', S("a1dcb"));
test(s, s.end()-3, '2', S("a12dcb"));
test(s, s.end()-4, '3', S("a132dcb"));
test(s, s.end()-5, '4', S("a1432dcb"));
test(s, s.begin()+1, '5', S("a51432dcb"));
test(s, s.begin()+2, '6', S("a561432dcb"));
test(s, s.begin()+3, '7', S("a5671432dcb"));
test(s, s.begin()+4, 'A', S("a567A1432dcb"));
test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
test(s, s.begin(), '1', S("1"));
test(s, s.begin(), 'a', S("a1"));
test(s, s.end(), 'b', S("a1b"));
test(s, s.end()-1, 'c', S("a1cb"));
test(s, s.end()-2, 'd', S("a1dcb"));
test(s, s.end()-3, '2', S("a12dcb"));
test(s, s.end()-4, '3', S("a132dcb"));
test(s, s.end()-5, '4', S("a1432dcb"));
test(s, s.begin()+1, '5', S("a51432dcb"));
test(s, s.begin()+2, '6', S("a561432dcb"));
test(s, s.begin()+3, '7', S("a5671432dcb"));
test(s, s.begin()+4, 'A', S("a567A1432dcb"));
test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -56,99 +56,58 @@ test_exceptions(S s, typename S::difference_type pos, It first, It last)
}
#endif
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), 0, s, s, S());
test(S(), 0, s, s+1, S("A"));
test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), 0, s, s, S("12345"));
test(S("12345"), 1, s, s+1, S("1A2345"));
test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), 0, s, s, S("1234567890"));
test(S("1234567890"), 1, s, s+1, S("1A234567890"));
test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
test(S("12345678901234567890"), 20, s, s+52,
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("A"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345"));
test(S("12345"), 1, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("1A2345"));
test(S("12345"), 4, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
test(S("12345"), 5, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("1234567890"));
test(S("1234567890"), 1, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("1A234567890"));
test(S("1234567890"), 10, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), 8, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
test(S("12345678901234567890"), 3, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345678901234567890"));
test(S("12345678901234567890"), 3, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("123A45678901234567890"));
test(S("12345678901234567890"), 15, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
test(S("12345678901234567890"), 20, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52),
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), 0, s, s, S());
test(S(), 0, s, s+1, S("A"));
test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), 0, s, s, S("12345"));
test(S("12345"), 1, s, s+1, S("1A2345"));
test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), 0, s, s, S("1234567890"));
test(S("1234567890"), 1, s, s+1, S("1A234567890"));
test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
test(S("12345678901234567890"), 20, s, s+52,
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("A"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345"));
test(S("12345"), 1, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("1A2345"));
test(S("12345"), 4, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
test(S("12345"), 5, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("1234567890"));
test(S("1234567890"), 1, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("1A234567890"));
test(S("1234567890"), 10, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), 8, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
test(S("12345678901234567890"), 3, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345678901234567890"));
test(S("12345678901234567890"), 3, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("123A45678901234567890"));
test(S("12345678901234567890"), 15, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
test(S("12345678901234567890"), 20, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52),
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
test(S(), 0, s, s, S());
test(S(), 0, s, s+1, S("A"));
test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), 0, s, s, S("12345"));
test(S("12345"), 1, s, s+1, S("1A2345"));
test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), 0, s, s, S("1234567890"));
test(S("1234567890"), 1, s, s+1, S("1A234567890"));
test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
test(S("12345678901234567890"), 20, s, s+52,
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S());
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("A"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
test(S(), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("12345"), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345"));
test(S("12345"), 1, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("1A2345"));
test(S("12345"), 4, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
test(S("12345"), 5, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
test(S("1234567890"), 0, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("1234567890"));
test(S("1234567890"), 1, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("1A234567890"));
test(S("1234567890"), 10, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
test(S("1234567890"), 8, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
test(S("12345678901234567890"), 3, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), S("12345678901234567890"));
test(S("12345678901234567890"), 3, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+1), S("123A45678901234567890"));
test(S("12345678901234567890"), 15, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
test(S("12345678901234567890"), 20, cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52),
S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
#ifndef TEST_HAS_NO_EXCEPTIONS
if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw
typedef std::string S;
@@ -230,7 +189,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
return true;
}

View File

@@ -28,142 +28,78 @@ test(S s, typename S::difference_type pos, typename S::size_type n,
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(""), 0, 0, '1', S(""));
test(S(""), 0, 5, '1', S("11111"));
test(S(""), 0, 10, '1', S("1111111111"));
test(S(""), 0, 20, '1', S("11111111111111111111"));
test(S("abcde"), 0, 0, '1', S("abcde"));
test(S("abcde"), 0, 5, '1', S("11111abcde"));
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
test(S("abcde"), 1, 0, '1', S("abcde"));
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
test(S("abcde"), 2, 0, '1', S("abcde"));
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
test(S("abcde"), 4, 0, '1', S("abcde"));
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
test(S("abcde"), 5, 0, '1', S("abcde"));
test(S("abcde"), 5, 5, '1', S("abcde11111"));
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), 0, 0, '1', S(""));
test(S(""), 0, 5, '1', S("11111"));
test(S(""), 0, 10, '1', S("1111111111"));
test(S(""), 0, 20, '1', S("11111111111111111111"));
test(S("abcde"), 0, 0, '1', S("abcde"));
test(S("abcde"), 0, 5, '1', S("11111abcde"));
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
test(S("abcde"), 1, 0, '1', S("abcde"));
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
test(S("abcde"), 2, 0, '1', S("abcde"));
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
test(S("abcde"), 4, 0, '1', S("abcde"));
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
test(S("abcde"), 5, 0, '1', S("abcde"));
test(S("abcde"), 5, 5, '1', S("abcde11111"));
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 0, 0, '1', S(""));
test(S(""), 0, 5, '1', S("11111"));
test(S(""), 0, 10, '1', S("1111111111"));
test(S(""), 0, 20, '1', S("11111111111111111111"));
test(S("abcde"), 0, 0, '1', S("abcde"));
test(S("abcde"), 0, 5, '1', S("11111abcde"));
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
test(S("abcde"), 1, 0, '1', S("abcde"));
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
test(S("abcde"), 2, 0, '1', S("abcde"));
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
test(S("abcde"), 4, 0, '1', S("abcde"));
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
test(S("abcde"), 5, 0, '1', S("abcde"));
test(S("abcde"), 5, 5, '1', S("abcde11111"));
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -47,174 +47,94 @@ test(S s, typename S::size_type pos, const typename S::value_type* str, S expect
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(""), 0, "", S(""));
test(S(""), 0, "12345", S("12345"));
test(S(""), 0, "1234567890", S("1234567890"));
test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
test(S(""), 1, "", S("can't happen"));
test(S(""), 1, "12345", S("can't happen"));
test(S(""), 1, "1234567890", S("can't happen"));
test(S(""), 1, "12345678901234567890", S("can't happen"));
test(S("abcde"), 0, "", S("abcde"));
test(S("abcde"), 0, "12345", S("12345abcde"));
test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
test(S("abcde"), 1, "", S("abcde"));
test(S("abcde"), 1, "12345", S("a12345bcde"));
test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
test(S("abcde"), 2, "", S("abcde"));
test(S("abcde"), 2, "12345", S("ab12345cde"));
test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
test(S("abcde"), 4, "", S("abcde"));
test(S("abcde"), 4, "12345", S("abcd12345e"));
test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
test(S("abcde"), 5, "", S("abcde"));
test(S("abcde"), 5, "12345", S("abcde12345"));
test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
test(S("abcde"), 6, "", S("can't happen"));
test(S("abcde"), 6, "12345", S("can't happen"));
test(S("abcde"), 6, "1234567890", S("can't happen"));
test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
test(S("abcdefghij"), 0, "", S("abcdefghij"));
test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, "", S("abcdefghij"));
test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, "", S("abcdefghij"));
test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, "", S("abcdefghij"));
test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, "", S("abcdefghij"));
test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, "", S("can't happen"));
test(S("abcdefghij"), 11, "12345", S("can't happen"));
test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), 0, "", S(""));
test(S(""), 0, "12345", S("12345"));
test(S(""), 0, "1234567890", S("1234567890"));
test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
test(S(""), 1, "", S("can't happen"));
test(S(""), 1, "12345", S("can't happen"));
test(S(""), 1, "1234567890", S("can't happen"));
test(S(""), 1, "12345678901234567890", S("can't happen"));
test(S("abcde"), 0, "", S("abcde"));
test(S("abcde"), 0, "12345", S("12345abcde"));
test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
test(S("abcde"), 1, "", S("abcde"));
test(S("abcde"), 1, "12345", S("a12345bcde"));
test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
test(S("abcde"), 2, "", S("abcde"));
test(S("abcde"), 2, "12345", S("ab12345cde"));
test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
test(S("abcde"), 4, "", S("abcde"));
test(S("abcde"), 4, "12345", S("abcd12345e"));
test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
test(S("abcde"), 5, "", S("abcde"));
test(S("abcde"), 5, "12345", S("abcde12345"));
test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
test(S("abcde"), 6, "", S("can't happen"));
test(S("abcde"), 6, "12345", S("can't happen"));
test(S("abcde"), 6, "1234567890", S("can't happen"));
test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
test(S("abcdefghij"), 0, "", S("abcdefghij"));
test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, "", S("abcdefghij"));
test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, "", S("abcdefghij"));
test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, "", S("abcdefghij"));
test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, "", S("abcdefghij"));
test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, "", S("can't happen"));
test(S("abcdefghij"), 11, "12345", S("can't happen"));
test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 0, "", S(""));
test(S(""), 0, "12345", S("12345"));
test(S(""), 0, "1234567890", S("1234567890"));
test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
test(S(""), 1, "", S("can't happen"));
test(S(""), 1, "12345", S("can't happen"));
test(S(""), 1, "1234567890", S("can't happen"));
test(S(""), 1, "12345678901234567890", S("can't happen"));
test(S("abcde"), 0, "", S("abcde"));
test(S("abcde"), 0, "12345", S("12345abcde"));
test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
test(S("abcde"), 1, "", S("abcde"));
test(S("abcde"), 1, "12345", S("a12345bcde"));
test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
test(S("abcde"), 2, "", S("abcde"));
test(S("abcde"), 2, "12345", S("ab12345cde"));
test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
test(S("abcde"), 4, "", S("abcde"));
test(S("abcde"), 4, "12345", S("abcd12345e"));
test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
test(S("abcde"), 5, "", S("abcde"));
test(S("abcde"), 5, "12345", S("abcde12345"));
test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
test(S("abcde"), 6, "", S("can't happen"));
test(S("abcde"), 6, "12345", S("can't happen"));
test(S("abcde"), 6, "1234567890", S("can't happen"));
test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
test(S("abcdefghij"), 0, "", S("abcdefghij"));
test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, "", S("abcdefghij"));
test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, "", S("abcdefghij"));
test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, "", S("abcdefghij"));
test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, "", S("abcdefghij"));
test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, "", S("can't happen"));
test(S("abcdefghij"), 11, "12345", S("can't happen"));
test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{ // test inserting into self

View File

@@ -48,174 +48,94 @@ test(S s, typename S::size_type pos, typename S::size_type n,
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(""), 0, 0, '1', S(""));
test(S(""), 0, 5, '1', S("11111"));
test(S(""), 0, 10, '1', S("1111111111"));
test(S(""), 0, 20, '1', S("11111111111111111111"));
test(S(""), 1, 0, '1', S("can't happen"));
test(S(""), 1, 5, '1', S("can't happen"));
test(S(""), 1, 10, '1', S("can't happen"));
test(S(""), 1, 20, '1', S("can't happen"));
test(S("abcde"), 0, 0, '1', S("abcde"));
test(S("abcde"), 0, 5, '1', S("11111abcde"));
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
test(S("abcde"), 1, 0, '1', S("abcde"));
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
test(S("abcde"), 2, 0, '1', S("abcde"));
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
test(S("abcde"), 4, 0, '1', S("abcde"));
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
test(S("abcde"), 5, 0, '1', S("abcde"));
test(S("abcde"), 5, 5, '1', S("abcde11111"));
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
test(S("abcde"), 6, 0, '1', S("can't happen"));
test(S("abcde"), 6, 5, '1', S("can't happen"));
test(S("abcde"), 6, 10, '1', S("can't happen"));
test(S("abcde"), 6, 20, '1', S("can't happen"));
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), 0, 0, '1', S(""));
test(S(""), 0, 5, '1', S("11111"));
test(S(""), 0, 10, '1', S("1111111111"));
test(S(""), 0, 20, '1', S("11111111111111111111"));
test(S(""), 1, 0, '1', S("can't happen"));
test(S(""), 1, 5, '1', S("can't happen"));
test(S(""), 1, 10, '1', S("can't happen"));
test(S(""), 1, 20, '1', S("can't happen"));
test(S("abcde"), 0, 0, '1', S("abcde"));
test(S("abcde"), 0, 5, '1', S("11111abcde"));
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
test(S("abcde"), 1, 0, '1', S("abcde"));
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
test(S("abcde"), 2, 0, '1', S("abcde"));
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
test(S("abcde"), 4, 0, '1', S("abcde"));
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
test(S("abcde"), 5, 0, '1', S("abcde"));
test(S("abcde"), 5, 5, '1', S("abcde11111"));
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
test(S("abcde"), 6, 0, '1', S("can't happen"));
test(S("abcde"), 6, 5, '1', S("can't happen"));
test(S("abcde"), 6, 10, '1', S("can't happen"));
test(S("abcde"), 6, 20, '1', S("can't happen"));
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 0, 0, '1', S(""));
test(S(""), 0, 5, '1', S("11111"));
test(S(""), 0, 10, '1', S("1111111111"));
test(S(""), 0, 20, '1', S("11111111111111111111"));
test(S(""), 1, 0, '1', S("can't happen"));
test(S(""), 1, 5, '1', S("can't happen"));
test(S(""), 1, 10, '1', S("can't happen"));
test(S(""), 1, 20, '1', S("can't happen"));
test(S("abcde"), 0, 0, '1', S("abcde"));
test(S("abcde"), 0, 5, '1', S("11111abcde"));
test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
test(S("abcde"), 1, 0, '1', S("abcde"));
test(S("abcde"), 1, 5, '1', S("a11111bcde"));
test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
test(S("abcde"), 2, 0, '1', S("abcde"));
test(S("abcde"), 2, 5, '1', S("ab11111cde"));
test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
test(S("abcde"), 4, 0, '1', S("abcde"));
test(S("abcde"), 4, 5, '1', S("abcd11111e"));
test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
test(S("abcde"), 5, 0, '1', S("abcde"));
test(S("abcde"), 5, 5, '1', S("abcde11111"));
test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
test(S("abcde"), 6, 0, '1', S("can't happen"));
test(S("abcde"), 6, 5, '1', S("can't happen"));
test(S("abcde"), 6, 10, '1', S("can't happen"));
test(S("abcde"), 6, 20, '1', S("can't happen"));
test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -47,177 +47,97 @@ test(S s, typename S::size_type pos, S str, S expected)
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(""), 0, S(""), S(""));
test(S(""), 0, S("12345"), S("12345"));
test(S(""), 0, S("1234567890"), S("1234567890"));
test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
test(S(""), 1, S(""), S("can't happen"));
test(S(""), 1, S("12345"), S("can't happen"));
test(S(""), 1, S("1234567890"), S("can't happen"));
test(S(""), 1, S("12345678901234567890"), S("can't happen"));
test(S("abcde"), 0, S(""), S("abcde"));
test(S("abcde"), 0, S("12345"), S("12345abcde"));
test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
test(S("abcde"), 1, S(""), S("abcde"));
test(S("abcde"), 1, S("12345"), S("a12345bcde"));
test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
test(S("abcde"), 2, S(""), S("abcde"));
test(S("abcde"), 2, S("12345"), S("ab12345cde"));
test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
test(S("abcde"), 4, S(""), S("abcde"));
test(S("abcde"), 4, S("12345"), S("abcd12345e"));
test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
test(S("abcde"), 5, S(""), S("abcde"));
test(S("abcde"), 5, S("12345"), S("abcde12345"));
test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
test(S("abcde"), 6, S(""), S("can't happen"));
test(S("abcde"), 6, S("12345"), S("can't happen"));
test(S("abcde"), 6, S("1234567890"), S("can't happen"));
test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, S(""), S("can't happen"));
test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), 0, S(""), S(""));
test(S(""), 0, S("12345"), S("12345"));
test(S(""), 0, S("1234567890"), S("1234567890"));
test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
test(S(""), 1, S(""), S("can't happen"));
test(S(""), 1, S("12345"), S("can't happen"));
test(S(""), 1, S("1234567890"), S("can't happen"));
test(S(""), 1, S("12345678901234567890"), S("can't happen"));
test(S("abcde"), 0, S(""), S("abcde"));
test(S("abcde"), 0, S("12345"), S("12345abcde"));
test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
test(S("abcde"), 1, S(""), S("abcde"));
test(S("abcde"), 1, S("12345"), S("a12345bcde"));
test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
test(S("abcde"), 2, S(""), S("abcde"));
test(S("abcde"), 2, S("12345"), S("ab12345cde"));
test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
test(S("abcde"), 4, S(""), S("abcde"));
test(S("abcde"), 4, S("12345"), S("abcd12345e"));
test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
test(S("abcde"), 5, S(""), S("abcde"));
test(S("abcde"), 5, S("12345"), S("abcde12345"));
test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
test(S("abcde"), 6, S(""), S("can't happen"));
test(S("abcde"), 6, S("12345"), S("can't happen"));
test(S("abcde"), 6, S("1234567890"), S("can't happen"));
test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, S(""), S("can't happen"));
test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), 0, S(""), S(""));
test(S(""), 0, S("12345"), S("12345"));
test(S(""), 0, S("1234567890"), S("1234567890"));
test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
test(S(""), 1, S(""), S("can't happen"));
test(S(""), 1, S("12345"), S("can't happen"));
test(S(""), 1, S("1234567890"), S("can't happen"));
test(S(""), 1, S("12345678901234567890"), S("can't happen"));
test(S("abcde"), 0, S(""), S("abcde"));
test(S("abcde"), 0, S("12345"), S("12345abcde"));
test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
test(S("abcde"), 1, S(""), S("abcde"));
test(S("abcde"), 1, S("12345"), S("a12345bcde"));
test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
test(S("abcde"), 2, S(""), S("abcde"));
test(S("abcde"), 2, S("12345"), S("ab12345cde"));
test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
test(S("abcde"), 4, S(""), S("abcde"));
test(S("abcde"), 4, S("12345"), S("abcd12345e"));
test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
test(S("abcde"), 5, S(""), S("abcde"));
test(S("abcde"), 5, S("12345"), S("abcde12345"));
test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
test(S("abcde"), 6, S(""), S("can't happen"));
test(S("abcde"), 6, S("12345"), S("can't happen"));
test(S("abcde"), 6, S("1234567890"), S("can't happen"));
test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, S(""), S("can't happen"));
test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
#if TEST_STD_VER > 3
#if TEST_STD_VER >= 11
{ // LWG 2946
std::string s;
s.insert(0, {"abc", 1});

View File

@@ -47,176 +47,95 @@ test(S s, typename S::size_type pos, SV sv, S expected)
#endif
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
typedef std::string_view SV;
test(S(""), 0, SV(""), S(""));
test(S(""), 0, SV("12345"), S("12345"));
test(S(""), 0, SV("1234567890"), S("1234567890"));
test(S(""), 0, SV("12345678901234567890"), S("12345678901234567890"));
test(S(""), 1, SV(""), S("can't happen"));
test(S(""), 1, SV("12345"), S("can't happen"));
test(S(""), 1, SV("1234567890"), S("can't happen"));
test(S(""), 1, SV("12345678901234567890"), S("can't happen"));
test(S("abcde"), 0, SV(""), S("abcde"));
test(S("abcde"), 0, SV("12345"), S("12345abcde"));
test(S("abcde"), 0, SV("1234567890"), S("1234567890abcde"));
test(S("abcde"), 0, SV("12345678901234567890"), S("12345678901234567890abcde"));
test(S("abcde"), 1, SV(""), S("abcde"));
test(S("abcde"), 1, SV("12345"), S("a12345bcde"));
test(S("abcde"), 1, SV("1234567890"), S("a1234567890bcde"));
test(S("abcde"), 1, SV("12345678901234567890"), S("a12345678901234567890bcde"));
test(S("abcde"), 2, SV(""), S("abcde"));
test(S("abcde"), 2, SV("12345"), S("ab12345cde"));
test(S("abcde"), 2, SV("1234567890"), S("ab1234567890cde"));
test(S("abcde"), 2, SV("12345678901234567890"), S("ab12345678901234567890cde"));
test(S("abcde"), 4, SV(""), S("abcde"));
test(S("abcde"), 4, SV("12345"), S("abcd12345e"));
test(S("abcde"), 4, SV("1234567890"), S("abcd1234567890e"));
test(S("abcde"), 4, SV("12345678901234567890"), S("abcd12345678901234567890e"));
test(S("abcde"), 5, SV(""), S("abcde"));
test(S("abcde"), 5, SV("12345"), S("abcde12345"));
test(S("abcde"), 5, SV("1234567890"), S("abcde1234567890"));
test(S("abcde"), 5, SV("12345678901234567890"), S("abcde12345678901234567890"));
test(S("abcde"), 6, SV(""), S("can't happen"));
test(S("abcde"), 6, SV("12345"), S("can't happen"));
test(S("abcde"), 6, SV("1234567890"), S("can't happen"));
test(S("abcde"), 6, SV("12345678901234567890"), S("can't happen"));
test(S("abcdefghij"), 0, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 0, SV("12345"), S("12345abcdefghij"));
test(S("abcdefghij"), 0, SV("1234567890"), S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 1, SV("12345"), S("a12345bcdefghij"));
test(S("abcdefghij"), 1, SV("1234567890"), S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 5, SV("12345"), S("abcde12345fghij"));
test(S("abcdefghij"), 5, SV("1234567890"), S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, SV("12345678901234567890"), S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 9, SV("12345"), S("abcdefghi12345j"));
test(S("abcdefghij"), 9, SV("1234567890"), S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, SV("12345678901234567890"), S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 10, SV("12345"), S("abcdefghij12345"));
test(S("abcdefghij"), 10, SV("1234567890"), S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, SV(""), S("can't happen"));
test(S("abcdefghij"), 11, SV("12345"), S("can't happen"));
test(S("abcdefghij"), 11, SV("1234567890"), S("can't happen"));
test(S("abcdefghij"), 11, SV("12345678901234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("12345"), S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("1234567890"), S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("12345"), S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("12345"), S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("1234567890"), S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, SV("12345"), S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, SV("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, SV("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, SV("12345"), S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, SV("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, SV("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, SV(""), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("12345"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("1234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("12345678901234567890"), S("can't happen"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(""), 0, SV(""), S(""));
test(S(""), 0, SV("12345"), S("12345"));
test(S(""), 0, SV("1234567890"), S("1234567890"));
test(S(""), 0, SV("12345678901234567890"), S("12345678901234567890"));
test(S(""), 1, SV(""), S("can't happen"));
test(S(""), 1, SV("12345"), S("can't happen"));
test(S(""), 1, SV("1234567890"), S("can't happen"));
test(S(""), 1, SV("12345678901234567890"), S("can't happen"));
test(S("abcde"), 0, SV(""), S("abcde"));
test(S("abcde"), 0, SV("12345"), S("12345abcde"));
test(S("abcde"), 0, SV("1234567890"), S("1234567890abcde"));
test(S("abcde"), 0, SV("12345678901234567890"), S("12345678901234567890abcde"));
test(S("abcde"), 1, SV(""), S("abcde"));
test(S("abcde"), 1, SV("12345"), S("a12345bcde"));
test(S("abcde"), 1, SV("1234567890"), S("a1234567890bcde"));
test(S("abcde"), 1, SV("12345678901234567890"), S("a12345678901234567890bcde"));
test(S("abcde"), 2, SV(""), S("abcde"));
test(S("abcde"), 2, SV("12345"), S("ab12345cde"));
test(S("abcde"), 2, SV("1234567890"), S("ab1234567890cde"));
test(S("abcde"), 2, SV("12345678901234567890"), S("ab12345678901234567890cde"));
test(S("abcde"), 4, SV(""), S("abcde"));
test(S("abcde"), 4, SV("12345"), S("abcd12345e"));
test(S("abcde"), 4, SV("1234567890"), S("abcd1234567890e"));
test(S("abcde"), 4, SV("12345678901234567890"), S("abcd12345678901234567890e"));
test(S("abcde"), 5, SV(""), S("abcde"));
test(S("abcde"), 5, SV("12345"), S("abcde12345"));
test(S("abcde"), 5, SV("1234567890"), S("abcde1234567890"));
test(S("abcde"), 5, SV("12345678901234567890"), S("abcde12345678901234567890"));
test(S("abcde"), 6, SV(""), S("can't happen"));
test(S("abcde"), 6, SV("12345"), S("can't happen"));
test(S("abcde"), 6, SV("1234567890"), S("can't happen"));
test(S("abcde"), 6, SV("12345678901234567890"), S("can't happen"));
test(S("abcdefghij"), 0, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 0, SV("12345"), S("12345abcdefghij"));
test(S("abcdefghij"), 0, SV("1234567890"), S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 1, SV("12345"), S("a12345bcdefghij"));
test(S("abcdefghij"), 1, SV("1234567890"), S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 5, SV("12345"), S("abcde12345fghij"));
test(S("abcdefghij"), 5, SV("1234567890"), S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, SV("12345678901234567890"), S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 9, SV("12345"), S("abcdefghi12345j"));
test(S("abcdefghij"), 9, SV("1234567890"), S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, SV("12345678901234567890"), S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 10, SV("12345"), S("abcdefghij12345"));
test(S("abcdefghij"), 10, SV("1234567890"), S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, SV(""), S("can't happen"));
test(S("abcdefghij"), 11, SV("12345"), S("can't happen"));
test(S("abcdefghij"), 11, SV("1234567890"), S("can't happen"));
test(S("abcdefghij"), 11, SV("12345678901234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("12345"), S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("1234567890"), S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("12345"), S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("12345"), S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("1234567890"), S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, SV("12345"), S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, SV("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, SV("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, SV("12345"), S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, SV("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, SV("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, SV(""), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("12345"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("1234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("12345678901234567890"), S("can't happen"));
}
test_string<std::string>();
#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(""), 0, SV(""), S(""));
test(S(""), 0, SV("12345"), S("12345"));
test(S(""), 0, SV("1234567890"), S("1234567890"));
test(S(""), 0, SV("12345678901234567890"), S("12345678901234567890"));
test(S(""), 1, SV(""), S("can't happen"));
test(S(""), 1, SV("12345"), S("can't happen"));
test(S(""), 1, SV("1234567890"), S("can't happen"));
test(S(""), 1, SV("12345678901234567890"), S("can't happen"));
test(S("abcde"), 0, SV(""), S("abcde"));
test(S("abcde"), 0, SV("12345"), S("12345abcde"));
test(S("abcde"), 0, SV("1234567890"), S("1234567890abcde"));
test(S("abcde"), 0, SV("12345678901234567890"), S("12345678901234567890abcde"));
test(S("abcde"), 1, SV(""), S("abcde"));
test(S("abcde"), 1, SV("12345"), S("a12345bcde"));
test(S("abcde"), 1, SV("1234567890"), S("a1234567890bcde"));
test(S("abcde"), 1, SV("12345678901234567890"), S("a12345678901234567890bcde"));
test(S("abcde"), 2, SV(""), S("abcde"));
test(S("abcde"), 2, SV("12345"), S("ab12345cde"));
test(S("abcde"), 2, SV("1234567890"), S("ab1234567890cde"));
test(S("abcde"), 2, SV("12345678901234567890"), S("ab12345678901234567890cde"));
test(S("abcde"), 4, SV(""), S("abcde"));
test(S("abcde"), 4, SV("12345"), S("abcd12345e"));
test(S("abcde"), 4, SV("1234567890"), S("abcd1234567890e"));
test(S("abcde"), 4, SV("12345678901234567890"), S("abcd12345678901234567890e"));
test(S("abcde"), 5, SV(""), S("abcde"));
test(S("abcde"), 5, SV("12345"), S("abcde12345"));
test(S("abcde"), 5, SV("1234567890"), S("abcde1234567890"));
test(S("abcde"), 5, SV("12345678901234567890"), S("abcde12345678901234567890"));
test(S("abcde"), 6, SV(""), S("can't happen"));
test(S("abcde"), 6, SV("12345"), S("can't happen"));
test(S("abcde"), 6, SV("1234567890"), S("can't happen"));
test(S("abcde"), 6, SV("12345678901234567890"), S("can't happen"));
test(S("abcdefghij"), 0, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 0, SV("12345"), S("12345abcdefghij"));
test(S("abcdefghij"), 0, SV("1234567890"), S("1234567890abcdefghij"));
test(S("abcdefghij"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghij"));
test(S("abcdefghij"), 1, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 1, SV("12345"), S("a12345bcdefghij"));
test(S("abcdefghij"), 1, SV("1234567890"), S("a1234567890bcdefghij"));
test(S("abcdefghij"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghij"));
test(S("abcdefghij"), 5, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 5, SV("12345"), S("abcde12345fghij"));
test(S("abcdefghij"), 5, SV("1234567890"), S("abcde1234567890fghij"));
test(S("abcdefghij"), 5, SV("12345678901234567890"), S("abcde12345678901234567890fghij"));
test(S("abcdefghij"), 9, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 9, SV("12345"), S("abcdefghi12345j"));
test(S("abcdefghij"), 9, SV("1234567890"), S("abcdefghi1234567890j"));
test(S("abcdefghij"), 9, SV("12345678901234567890"), S("abcdefghi12345678901234567890j"));
test(S("abcdefghij"), 10, SV(""), S("abcdefghij"));
test(S("abcdefghij"), 10, SV("12345"), S("abcdefghij12345"));
test(S("abcdefghij"), 10, SV("1234567890"), S("abcdefghij1234567890"));
test(S("abcdefghij"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890"));
test(S("abcdefghij"), 11, SV(""), S("can't happen"));
test(S("abcdefghij"), 11, SV("12345"), S("can't happen"));
test(S("abcdefghij"), 11, SV("1234567890"), S("can't happen"));
test(S("abcdefghij"), 11, SV("12345678901234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 0, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("12345"), S("12345abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("1234567890"), S("1234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 0, SV("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("12345"), S("a12345bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 1, SV("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("12345"), S("abcdefghij12345klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("1234567890"), S("abcdefghij1234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 10, SV("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 19, SV("12345"), S("abcdefghijklmnopqrs12345t"));
test(S("abcdefghijklmnopqrst"), 19, SV("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
test(S("abcdefghijklmnopqrst"), 19, SV("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
test(S("abcdefghijklmnopqrst"), 20, SV(""), S("abcdefghijklmnopqrst"));
test(S("abcdefghijklmnopqrst"), 20, SV("12345"), S("abcdefghijklmnopqrst12345"));
test(S("abcdefghijklmnopqrst"), 20, SV("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test(S("abcdefghijklmnopqrst"), 20, SV("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test(S("abcdefghijklmnopqrst"), 21, SV(""), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("12345"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("1234567890"), S("can't happen"));
test(S("abcdefghijklmnopqrst"), 21, SV("12345678901234567890"), S("can't happen"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
{ // test inserting into self

View File

@@ -25,54 +25,34 @@ test(S s, const typename S::value_type* str, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), "", S());
test(S(), "12345", S("12345"));
test(S(), "1234567890", S("1234567890"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S("12345"));
test(S("12345"), "12345", S("1234512345"));
test(S("12345"), "1234567890", S("123451234567890"));
test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
test(S("1234567890"), "", S("1234567890"));
test(S("1234567890"), "12345", S("123456789012345"));
test(S("1234567890"), "1234567890", S("12345678901234567890"));
test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
test(S("12345678901234567890"), "", S("12345678901234567890"));
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
test(S("12345678901234567890"), "12345678901234567890",
S("1234567890123456789012345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), "", S());
test(S(), "12345", S("12345"));
test(S(), "1234567890", S("1234567890"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S("12345"));
test(S("12345"), "12345", S("1234512345"));
test(S("12345"), "1234567890", S("123451234567890"));
test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
test(S("1234567890"), "", S("1234567890"));
test(S("1234567890"), "12345", S("123456789012345"));
test(S("1234567890"), "1234567890", S("12345678901234567890"));
test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
test(S("12345678901234567890"), "", S("12345678901234567890"));
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
test(S("12345678901234567890"), "12345678901234567890",
S("1234567890123456789012345678901234567890"));
}
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(), "12345", S("12345"));
test(S(), "1234567890", S("1234567890"));
test(S(), "12345678901234567890", S("12345678901234567890"));
test(S("12345"), "", S("12345"));
test(S("12345"), "12345", S("1234512345"));
test(S("12345"), "1234567890", S("123451234567890"));
test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
test(S("1234567890"), "", S("1234567890"));
test(S("1234567890"), "12345", S("123456789012345"));
test(S("1234567890"), "1234567890", S("12345678901234567890"));
test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
test(S("12345678901234567890"), "", S("12345678901234567890"));
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
test(S("12345678901234567890"), "12345678901234567890",
S("1234567890123456789012345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
return true;

View File

@@ -26,57 +26,37 @@ test(S s, S str, S expected)
assert(s == expected);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test_string() {
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S("12345"));
test(S("12345"), S("12345"), S("1234512345"));
test(S("12345"), S("1234567890"), S("123451234567890"));
test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), S(), S("1234567890"));
test(S("1234567890"), S("12345"), S("123456789012345"));
test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S(), S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S("12345"));
test(S("12345"), S("12345"), S("1234512345"));
test(S("12345"), S("1234567890"), S("123451234567890"));
test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), S(), S("1234567890"));
test(S("1234567890"), S("12345"), S("123456789012345"));
test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S(), S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
test_string<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
test(S(), S("1234567890"), S("1234567890"));
test(S(), S("12345678901234567890"), S("12345678901234567890"));
test(S("12345"), S(), S("12345"));
test(S("12345"), S("12345"), S("1234512345"));
test(S("12345"), S("1234567890"), S("123451234567890"));
test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
test(S("1234567890"), S(), S("1234567890"));
test(S("1234567890"), S("12345"), S("123456789012345"));
test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S(), S("12345678901234567890"));
test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
test(S("12345678901234567890"), S("12345678901234567890"),
S("1234567890123456789012345678901234567890"));
}
test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char>>>();
#endif
#if TEST_STD_VER > 3
#if TEST_STD_VER >= 11
{ // LWG 2946
std::string s;
s += {"abc", 1};

View File

@@ -283,7 +283,7 @@ void test() {
#endif
}
#if TEST_STD_VER > 3
#if TEST_STD_VER >= 11
{ // LWG 2946
std::string s = " ";
s.replace(s.cbegin(), s.cend(), {"abc", 1});

View File

@@ -381,7 +381,7 @@ void test() {
#endif
}
#if TEST_STD_VER > 3
#if TEST_STD_VER >= 11
{ // LWG 2946
std::string s = " ";
s.replace(0, 1, {"abc", 1});

View File

@@ -31,46 +31,30 @@ 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;