[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:
Nikolas Klauser committed 2022-02-10 21:43:18 +01:00
1 parent e43b1ce4d5
commit dcffa7d3e1
56 files changed
+2065 -1177

No files matched your search

@@ -18,7 +18,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(S s, const typename S::value_type* str, S expected)
{
s.assign(str);
@@ -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("12345"));
test(S("12345678901234567890"), "12345678901234567890",
S("12345678901234567890"));
}
}
#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("12345"));
test(S("12345678901234567890"), "12345678901234567890",
S("12345678901234567890"));
}
}
#endif
{ // test assignment to self
{ // test assignment to self
typedef std::string S;
S s_short = "123/";
S s_long = "Lorem ipsum dolor sit amet, consectetur/";
@@ -73,7 +72,17 @@ int main(int, char**)
s_long.assign(s_long.c_str() + 30);
assert(s_long == "nsectetur/");
}
}
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}