mirror of
https://github.com/clang-retro/llvm.git
synced 2026-12-04 08:09:27 -08:00
[libc++] Prepare string.modifiers tests for constexpr
Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D119329
This commit is contained in:
1 parent
e43b1ce4d5
commit
dcffa7d3e1
56 files changed
+2065
-1177
No files matched your search
+25
-16
@@ -20,7 +20,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, SV sv, typename S::size_type pos, typename S::size_type n, S expected)
|
||||
{
|
||||
if (pos <= sv.size())
|
||||
@@ -46,7 +46,7 @@ test(S s, SV sv, typename S::size_type pos, typename S::size_type n, S expected)
|
||||
}
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test_npos(S s, SV sv, typename S::size_type pos, S expected)
|
||||
{
|
||||
if (pos <= sv.size())
|
||||
@@ -71,9 +71,8 @@ test_npos(S s, SV sv, typename S::size_type pos, S expected)
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
test(S(), SV(), 0, 0, S());
|
||||
@@ -97,9 +96,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234"));
|
||||
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
|
||||
S("123456789012345678906789012345"));
|
||||
}
|
||||
}
|
||||
#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());
|
||||
@@ -123,9 +122,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234"));
|
||||
test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10,
|
||||
S("123456789012345678906789012345"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
test_npos(S(), SV(), 0, S());
|
||||
@@ -135,9 +134,9 @@ int main(int, char**)
|
||||
test_npos(S(), SV("12345"), 3, S("45"));
|
||||
test_npos(S(), SV("12345"), 5, S(""));
|
||||
test_npos(S(), SV("12345"), 6, S("not happening"));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
std::string s;
|
||||
std::string_view sv = "EFGH";
|
||||
char arr[] = "IJKL";
|
||||
@@ -169,9 +168,9 @@ int main(int, char**)
|
||||
s.append(arr, 0); // calls append(const char *, len)
|
||||
assert(s == "");
|
||||
s.clear();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
std::string s = "ABCD";
|
||||
std::string_view sv = s;
|
||||
s.append(sv);
|
||||
@@ -184,9 +183,9 @@ int main(int, char**)
|
||||
sv = s;
|
||||
s.append(sv, sv.size());
|
||||
assert(s == "ABCDABCDABCDABCD");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
std::string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
std::string_view sv = s;
|
||||
s.append(sv);
|
||||
@@ -195,7 +194,17 @@ int main(int, char**)
|
||||
sv = s;
|
||||
s.append(sv, 0, std::string::npos);
|
||||
assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+20
-11
@@ -18,19 +18,28 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
bool test() {
|
||||
{
|
||||
std::string s("123");
|
||||
s.append({'a', 'b', 'c'});
|
||||
assert(s == "123abc");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s("123");
|
||||
s.append({'a', 'b', 'c'});
|
||||
assert(s == "123abc");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
std::string s("123");
|
||||
s.append({'a', 'b', 'c'});
|
||||
assert(s == "123abc");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s("123");
|
||||
s.append({'a', 'b', 'c'});
|
||||
assert(s == "123abc");
|
||||
}
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+25
-16
@@ -19,7 +19,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S, class It>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, It first, It last, S expected)
|
||||
{
|
||||
s.append(first, last);
|
||||
@@ -31,7 +31,7 @@ test(S s, It first, It last, S expected)
|
||||
struct Widget { operator char() const { throw 42; } };
|
||||
|
||||
template <class S, class It>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test_exceptions(S s, It first, It last)
|
||||
{
|
||||
S original = s;
|
||||
@@ -52,9 +52,8 @@ test_exceptions(S s, It first, It last)
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
test(S(), s, s, S());
|
||||
@@ -111,9 +110,9 @@ int main(int, char**)
|
||||
S("12345678901234567890""ABCDEFGHIJ"));
|
||||
test(S("12345678901234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52),
|
||||
S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
}
|
||||
#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());
|
||||
@@ -170,10 +169,10 @@ int main(int, char**)
|
||||
S("12345678901234567890""ABCDEFGHIJ"));
|
||||
test(S("12345678901234567890"), cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+52),
|
||||
S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{ // test iterator operations that throw
|
||||
{ // test iterator operations that throw
|
||||
typedef std::string S;
|
||||
typedef ThrowingIterator<char> TIter;
|
||||
typedef cpp17_input_iterator<TIter> IIter;
|
||||
@@ -188,10 +187,10 @@ int main(int, char**)
|
||||
|
||||
Widget w[100];
|
||||
test_exceptions(S(), w, w+100);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{ // test appending to self
|
||||
{ // test appending to self
|
||||
typedef std::string S;
|
||||
S s_short = "123/";
|
||||
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
|
||||
@@ -205,18 +204,18 @@ int main(int, char**)
|
||||
|
||||
s_long.append(s_long.begin(), s_long.end());
|
||||
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
|
||||
}
|
||||
}
|
||||
|
||||
{ // test appending a different type
|
||||
{ // test appending a different type
|
||||
typedef std::string S;
|
||||
const uint8_t p[] = "ABCD";
|
||||
|
||||
S s;
|
||||
s.append(p, p + 4);
|
||||
assert(s == "ABCD");
|
||||
}
|
||||
}
|
||||
|
||||
{ // regression-test appending to self in sneaky ways
|
||||
{ // regression-test appending to self in sneaky ways
|
||||
std::string s_short = "hello";
|
||||
std::string s_long = "Lorem ipsum dolor sit amet, consectetur/";
|
||||
std::string s_othertype = "hello";
|
||||
@@ -231,7 +230,7 @@ int main(int, char**)
|
||||
|
||||
s_sneaky.reserve(12);
|
||||
test(s_sneaky, s_sneaky.data(), s_sneaky.data() + 6, std::string("hellohello\0", 11));
|
||||
}
|
||||
}
|
||||
|
||||
{ // test with a move iterator that returns char&&
|
||||
typedef forward_iterator<const char*> It;
|
||||
@@ -250,5 +249,15 @@ int main(int, char**)
|
||||
assert(s == "ABCD");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+17
-8
@@ -26,9 +26,8 @@ test(S s, const typename S::value_type* str, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), "", S());
|
||||
test(S(), "12345", S("12345"));
|
||||
@@ -42,9 +41,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
|
||||
test(S("12345678901234567890"), "12345678901234567890",
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#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"));
|
||||
@@ -58,10 +57,10 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
|
||||
test(S("12345678901234567890"), "12345678901234567890",
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{ // test appending to self
|
||||
{ // test appending to self
|
||||
typedef std::string S;
|
||||
S s_short = "123/";
|
||||
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
|
||||
@@ -75,7 +74,17 @@ int main(int, char**)
|
||||
|
||||
s_long.append(s_long.c_str());
|
||||
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+18
-9
@@ -19,7 +19,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
|
||||
{
|
||||
s.append(str, n);
|
||||
@@ -27,9 +27,8 @@ test(S s, const typename S::value_type* str, typename S::size_type n, S expected
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), "", 0, S());
|
||||
test(S(), "12345", 3, S("123"));
|
||||
@@ -47,9 +46,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
|
||||
test(S("12345678901234567890"), "12345678901234567890", 20,
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#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"));
|
||||
@@ -67,10 +66,10 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
|
||||
test(S("12345678901234567890"), "12345678901234567890", 20,
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{ // test appending to self
|
||||
{ // test appending to self
|
||||
typedef std::string S;
|
||||
S s_short = "123/";
|
||||
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
|
||||
@@ -84,7 +83,17 @@ int main(int, char**)
|
||||
|
||||
s_long.append(s_long.data(), s_long.size());
|
||||
assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+18
-9
@@ -23,7 +23,7 @@ struct veryLarge
|
||||
};
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, typename S::value_type c, S expected)
|
||||
{
|
||||
s.push_back(c);
|
||||
@@ -31,31 +31,40 @@ test(S s, typename S::value_type c, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), 'a', S(1, 'a'));
|
||||
test(S("12345"), 'a', S("12345a"));
|
||||
test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), 'a', S(1, 'a'));
|
||||
test(S("12345"), 'a', S("12345a"));
|
||||
test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
{
|
||||
// https://llvm.org/PR31454
|
||||
std::basic_string<veryLarge> s;
|
||||
veryLarge vl = {};
|
||||
s.push_back(vl);
|
||||
s.push_back(vl);
|
||||
s.push_back(vl);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+16
-7
@@ -18,7 +18,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, typename S::size_type n, typename S::value_type c, S expected)
|
||||
{
|
||||
s.append(n, c);
|
||||
@@ -26,9 +26,8 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), 0, 'a', S());
|
||||
test(S(), 1, 'a', S(1, 'a'));
|
||||
@@ -42,9 +41,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
|
||||
test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
|
||||
test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
|
||||
}
|
||||
}
|
||||
#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'));
|
||||
@@ -58,7 +57,17 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
|
||||
test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
|
||||
test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+18
-9
@@ -18,7 +18,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, S str, S expected)
|
||||
{
|
||||
s.append(str);
|
||||
@@ -26,9 +26,8 @@ test(S s, S str, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), S(), S());
|
||||
test(S(), S("12345"), S("12345"));
|
||||
@@ -50,9 +49,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), S("12345678901234567890"),
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#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"));
|
||||
@@ -74,16 +73,26 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), S("12345678901234567890"),
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 3
|
||||
{ // LWG 2946
|
||||
{ // LWG 2946
|
||||
std::string s;
|
||||
s.append({"abc", 1});
|
||||
assert(s.size() == 1);
|
||||
assert(s == "a");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
+19
-10
@@ -20,7 +20,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
|
||||
{
|
||||
if (pos <= str.size())
|
||||
@@ -46,7 +46,7 @@ test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test_npos(S s, S str, typename S::size_type pos, S expected)
|
||||
{
|
||||
if (pos <= str.size())
|
||||
@@ -71,9 +71,8 @@ test_npos(S s, S str, typename S::size_type pos, S expected)
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), S(), 0, 0, S());
|
||||
test(S(), S(), 1, 0, S());
|
||||
@@ -96,9 +95,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
|
||||
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
|
||||
S("123456789012345678906789012345"));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), S(), 0, 0, S());
|
||||
test(S(), S(), 1, 0, S());
|
||||
@@ -121,9 +120,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
|
||||
test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
|
||||
S("123456789012345678906789012345"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
test_npos(S(), S(), 0, S());
|
||||
test_npos(S(), S(), 1, S());
|
||||
@@ -132,7 +131,17 @@ int main(int, char**)
|
||||
test_npos(S(), S("12345"), 3, S("45"));
|
||||
test_npos(S(), S("12345"), 5, S(""));
|
||||
test_npos(S(), S("12345"), 6, S("not happening"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
+16
-7
@@ -19,7 +19,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s, SV sv, S expected)
|
||||
{
|
||||
s.append(sv);
|
||||
@@ -27,9 +27,8 @@ test(S s, SV sv, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
test(S(), SV(), S());
|
||||
@@ -52,9 +51,9 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), SV("12345678901234567890"),
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#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());
|
||||
@@ -77,7 +76,17 @@ int main(int, char**)
|
||||
test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890"));
|
||||
test(S("12345678901234567890"), SV("12345678901234567890"),
|
||||
S("1234567890123456789012345678901234567890"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user