summaryrefslogtreecommitdiff
path: root/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
diff options
context:
space:
mode:
authorNikolas Klauser <nikolasklauser@berlin.de>2022-02-10 16:51:04 +0100
committerNikolas Klauser <nikolasklauser@berlin.de>2022-02-10 21:43:18 +0100
commitdcffa7d3e140cf2e2a80f93168b40c449bc1d230 (patch)
tree7b579d107fa88554045da5ab2b0ca5370b9c46b0 /libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
parente43b1ce4d52dc9da7b8b6385943d8e91d7bb223f (diff)
[libc++] Prepare string.modifiers tests for constexpr
Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D119329
Diffstat (limited to 'libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp')
-rw-r--r--libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
index fae45c80de0c..8787aba6b120 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
@@ -19,7 +19,7 @@
#include "test_allocator.h"
template <class S>
-void
+TEST_CONSTEXPR_CXX20 void
test(S s, S str, S expected)
{
s.assign(str);
@@ -28,7 +28,7 @@ test(S s, S str, S expected)
}
template <class S>
-void
+TEST_CONSTEXPR_CXX20 void
testAlloc(S s, S str, const typename S::allocator_type& a)
{
s.assign(str);
@@ -37,9 +37,8 @@ testAlloc(S s, S str, const typename S::allocator_type& a)
assert(s.get_allocator() == a);
}
-int main(int, char**)
-{
- {
+bool test() {
+ {
typedef std::string S;
test(S(), S(), S());
test(S(), S("12345"), S("12345"));
@@ -66,19 +65,19 @@ int main(int, char**)
testAlloc(S(), S("12345"), std::allocator<char>());
testAlloc(S(), S("1234567890"), std::allocator<char>());
testAlloc(S(), S("12345678901234567890"), std::allocator<char>());
- }
+ }
- { // LWG#5579 make sure assign takes the allocators where appropriate
+ { // LWG#5579 make sure assign takes the allocators where appropriate
typedef other_allocator<char> A; // has POCCA --> true
typedef std::basic_string<char, std::char_traits<char>, A> S;
testAlloc(S(A(5)), S(A(3)), A(3));
testAlloc(S(A(5)), S("1"), A());
testAlloc(S(A(5)), S("1", A(7)), A(7));
testAlloc(S(A(5)), S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), A(7));
- }
+ }
#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"));
@@ -105,13 +104,23 @@ int main(int, char**)
testAlloc(S(), S("12345"), min_allocator<char>());
testAlloc(S(), S("1234567890"), min_allocator<char>());
testAlloc(S(), S("12345678901234567890"), min_allocator<char>());
- }
+ }
#endif
#if TEST_STD_VER > 14
- {
+ {
typedef std::string S;
static_assert(noexcept(S().assign(S())), ""); // LWG#2063
- }
+ }
+#endif
+
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if TEST_STD_VER > 17
+ // static_assert(test());
#endif
return 0;