Expand Up
@@ -20,7 +20,7 @@
#include " min_allocator.h"
template <class S >
void
TEST_CONSTEXPR_CXX20 void
test (S s, typename S::size_type pos, typename S::size_type n1,
const typename S::value_type* str, typename S::size_type n2,
S expected)
Expand Down
Expand Up
@@ -54,7 +54,7 @@ test(S s, typename S::size_type pos, typename S::size_type n1,
}
template <class S >
void test0 ()
TEST_CONSTEXPR_CXX20 bool test0 ()
{
test (S (" " ), 0 , 0 , " " , 0 , S (" " ));
test (S (" " ), 0 , 0 , " 12345" , 0 , S (" " ));
Expand Down
Expand Up
@@ -156,10 +156,12 @@ void test0()
test (S (" abcde" ), 0 , 4 , " 12345" , 0 , S (" e" ));
test (S (" abcde" ), 0 , 4 , " 12345" , 1 , S (" 1e" ));
test (S (" abcde" ), 0 , 4 , " 12345" , 2 , S (" 12e" ));
return true ;
}
template <class S >
void test1 ()
TEST_CONSTEXPR_CXX20 bool test1 ()
{
test (S (" abcde" ), 0 , 4 , " 12345" , 4 , S (" 1234e" ));
test (S (" abcde" ), 0 , 4 , " 12345" , 5 , S (" 12345e" ));
Expand Down
Expand Up
@@ -261,10 +263,12 @@ void test1()
test (S (" abcde" ), 1 , 3 , " 12345" , 5 , S (" a12345e" ));
test (S (" abcde" ), 1 , 3 , " 1234567890" , 0 , S (" ae" ));
test (S (" abcde" ), 1 , 3 , " 1234567890" , 1 , S (" a1e" ));
return true ;
}
template <class S >
void test2 ()
TEST_CONSTEXPR_CXX20 bool test2 ()
{
test (S (" abcde" ), 1 , 3 , " 1234567890" , 5 , S (" a12345e" ));
test (S (" abcde" ), 1 , 3 , " 1234567890" , 9 , S (" a123456789e" ));
Expand Down
Expand Up
@@ -366,10 +370,12 @@ void test2()
test (S (" abcde" ), 2 , 3 , " 1234567890" , 9 , S (" ab123456789" ));
test (S (" abcde" ), 2 , 3 , " 1234567890" , 10 , S (" ab1234567890" ));
test (S (" abcde" ), 2 , 3 , " 12345678901234567890" , 0 , S (" ab" ));
return true ;
}
template <class S >
void test3 ()
TEST_CONSTEXPR_CXX20 bool test3 ()
{
test (S (" abcde" ), 2 , 3 , " 12345678901234567890" , 1 , S (" ab1" ));
test (S (" abcde" ), 2 , 3 , " 12345678901234567890" , 10 , S (" ab1234567890" ));
Expand Down
Expand Up
@@ -471,10 +477,12 @@ void test3()
test (S (" abcde" ), 5 , 1 , " 12345678901234567890" , 10 , S (" abcde1234567890" ));
test (S (" abcde" ), 5 , 1 , " 12345678901234567890" , 19 , S (" abcde1234567890123456789" ));
test (S (" abcde" ), 5 , 1 , " 12345678901234567890" , 20 , S (" abcde12345678901234567890" ));
return true ;
}
template <class S >
void test4 ()
TEST_CONSTEXPR_CXX20 bool test4 ()
{
test (S (" abcde" ), 6 , 0 , " " , 0 , S (" can't happen" ));
test (S (" abcde" ), 6 , 0 , " 12345" , 0 , S (" can't happen" ));
Expand Down
Expand Up
@@ -576,10 +584,12 @@ void test4()
test (S (" abcdefghij" ), 0 , 11 , " 12345" , 0 , S (" " ));
test (S (" abcdefghij" ), 0 , 11 , " 12345" , 1 , S (" 1" ));
test (S (" abcdefghij" ), 0 , 11 , " 12345" , 2 , S (" 12" ));
return true ;
}
template <class S >
void test5 ()
TEST_CONSTEXPR_CXX20 bool test5 ()
{
test (S (" abcdefghij" ), 0 , 11 , " 12345" , 4 , S (" 1234" ));
test (S (" abcdefghij" ), 0 , 11 , " 12345" , 5 , S (" 12345" ));
Expand Down
Expand Up
@@ -681,10 +691,12 @@ void test5()
test (S (" abcdefghij" ), 1 , 10 , " 12345" , 5 , S (" a12345" ));
test (S (" abcdefghij" ), 1 , 10 , " 1234567890" , 0 , S (" a" ));
test (S (" abcdefghij" ), 1 , 10 , " 1234567890" , 1 , S (" a1" ));
return true ;
}
template <class S >
void test6 ()
TEST_CONSTEXPR_CXX20 bool test6 ()
{
test (S (" abcdefghij" ), 1 , 10 , " 1234567890" , 5 , S (" a12345" ));
test (S (" abcdefghij" ), 1 , 10 , " 1234567890" , 9 , S (" a123456789" ));
Expand Down
Expand Up
@@ -786,10 +798,12 @@ void test6()
test (S (" abcdefghij" ), 5 , 6 , " 1234567890" , 9 , S (" abcde123456789" ));
test (S (" abcdefghij" ), 5 , 6 , " 1234567890" , 10 , S (" abcde1234567890" ));
test (S (" abcdefghij" ), 5 , 6 , " 12345678901234567890" , 0 , S (" abcde" ));
return true ;
}
template <class S >
void test7 ()
TEST_CONSTEXPR_CXX20 bool test7 ()
{
test (S (" abcdefghij" ), 5 , 6 , " 12345678901234567890" , 1 , S (" abcde1" ));
test (S (" abcdefghij" ), 5 , 6 , " 12345678901234567890" , 10 , S (" abcde1234567890" ));
Expand Down
Expand Up
@@ -891,10 +905,12 @@ void test7()
test (S (" abcdefghij" ), 11 , 0 , " 12345678901234567890" , 10 , S (" can't happen" ));
test (S (" abcdefghij" ), 11 , 0 , " 12345678901234567890" , 19 , S (" can't happen" ));
test (S (" abcdefghij" ), 11 , 0 , " 12345678901234567890" , 20 , S (" can't happen" ));
return true ;
}
template <class S >
void test8 ()
TEST_CONSTEXPR_CXX20 bool test8 ()
{
test (S (" abcdefghijklmnopqrst" ), 0 , 0 , " " , 0 , S (" abcdefghijklmnopqrst" ));
test (S (" abcdefghijklmnopqrst" ), 0 , 0 , " 12345" , 0 , S (" abcdefghijklmnopqrst" ));
Expand Down
Expand Up
@@ -996,10 +1012,12 @@ void test8()
test (S (" abcdefghijklmnopqrst" ), 1 , 0 , " 12345" , 0 , S (" abcdefghijklmnopqrst" ));
test (S (" abcdefghijklmnopqrst" ), 1 , 0 , " 12345" , 1 , S (" a1bcdefghijklmnopqrst" ));
test (S (" abcdefghijklmnopqrst" ), 1 , 0 , " 12345" , 2 , S (" a12bcdefghijklmnopqrst" ));
return true ;
}
template <class S >
void test9 ()
TEST_CONSTEXPR_CXX20 bool test9 ()
{
test (S (" abcdefghijklmnopqrst" ), 1 , 0 , " 12345" , 4 , S (" a1234bcdefghijklmnopqrst" ));
test (S (" abcdefghijklmnopqrst" ), 1 , 0 , " 12345" , 5 , S (" a12345bcdefghijklmnopqrst" ));
Expand Down
Expand Up
@@ -1101,10 +1119,12 @@ void test9()
test (S (" abcdefghijklmnopqrst" ), 10 , 0 , " 12345" , 5 , S (" abcdefghij12345klmnopqrst" ));
test (S (" abcdefghijklmnopqrst" ), 10 , 0 , " 1234567890" , 0 , S (" abcdefghijklmnopqrst" ));
test (S (" abcdefghijklmnopqrst" ), 10 , 0 , " 1234567890" , 1 , S (" abcdefghij1klmnopqrst" ));
return true ;
}
template <class S >
void test10 ()
TEST_CONSTEXPR_CXX20 bool test10 ()
{
test (S (" abcdefghijklmnopqrst" ), 10 , 0 , " 1234567890" , 5 , S (" abcdefghij12345klmnopqrst" ));
test (S (" abcdefghijklmnopqrst" ), 10 , 0 , " 1234567890" , 9 , S (" abcdefghij123456789klmnopqrst" ));
Expand Down
Expand Up
@@ -1206,10 +1226,12 @@ void test10()
test (S (" abcdefghijklmnopqrst" ), 19 , 0 , " 1234567890" , 9 , S (" abcdefghijklmnopqrs123456789t" ));
test (S (" abcdefghijklmnopqrst" ), 19 , 0 , " 1234567890" , 10 , S (" abcdefghijklmnopqrs1234567890t" ));
test (S (" abcdefghijklmnopqrst" ), 19 , 0 , " 12345678901234567890" , 0 , S (" abcdefghijklmnopqrst" ));
return true ;
}
template <class S >
void test11 ()
TEST_CONSTEXPR_CXX20 bool test11 ()
{
test (S (" abcdefghijklmnopqrst" ), 19 , 0 , " 12345678901234567890" , 1 , S (" abcdefghijklmnopqrs1t" ));
test (S (" abcdefghijklmnopqrst" ), 19 , 0 , " 12345678901234567890" , 10 , S (" abcdefghijklmnopqrs1234567890t" ));
Expand Down
Expand Up
@@ -1295,41 +1317,46 @@ void test11()
test (S (" abcdefghijklmnopqrst" ), 21 , 0 , " 12345678901234567890" , 10 , S (" can't happen" ));
test (S (" abcdefghijklmnopqrst" ), 21 , 0 , " 12345678901234567890" , 19 , S (" can't happen" ));
test (S (" abcdefghijklmnopqrst" ), 21 , 0 , " 12345678901234567890" , 20 , S (" can't happen" ));
return true ;
}
template <class S >
void test () {
test0<S>();
test1<S>();
test2<S>();
test3<S>();
test4<S>();
test5<S>();
test6<S>();
test7<S>();
test8<S>();
test9<S>();
test10<S>();
test11<S>();
#if TEST_STD_VER > 17
// static_assert(test0<S>());
// static_assert(test1<S>());
// static_assert(test2<S>());
// static_assert(test3<S>());
// static_assert(test4<S>());
// static_assert(test5<S>());
// static_assert(test6<S>());
// static_assert(test7<S>());
// static_assert(test8<S>());
// static_assert(test9<S>());
// static_assert(test10<S>());
// static_assert(test11<S>());
#endif
}
int main (int , char **)
{
{
typedef std::string S;
test0<S>();
test1<S>();
test2<S>();
test3<S>();
test4<S>();
test5<S>();
test6<S>();
test7<S>();
test8<S>();
test9<S>();
test10<S>();
test11<S>();
}
test<std::string>();
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char , std::char_traits<char >, min_allocator<char >> S;
test0<S>();
test1<S>();
test2<S>();
test3<S>();
test4<S>();
test5<S>();
test6<S>();
test7<S>();
test8<S>();
test9<S>();
test10<S>();
test11<S>();
}
test<std::basic_string<char , std::char_traits<char >, min_allocator<char >>>();
#endif
return 0 ;
Expand Down