From e85018b7dd3a89dda6b22319b03b5906f8a85aed Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Mon, 7 Feb 2022 21:54:49 +0100 Subject: [libc++] Prepare string.{access, capacity, cons} tests for constexpr Reviewed By: ldionne, #libc Spies: libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D119123 --- .../string.cons/pointer_assignment.pass.cpp | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp') diff --git a/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp index 4a885485bea5..972ba0b079b5 100644 --- a/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.cons/pointer_assignment.pass.cpp @@ -18,7 +18,7 @@ #include "min_allocator.h" template -void +TEST_CONSTEXPR_CXX20 void test(S s1, const typename S::value_type* s2) { typedef typename S::traits_type T; @@ -29,9 +29,8 @@ test(S s1, const typename S::value_type* s2) assert(s1.capacity() >= s1.size()); } -int main(int, char**) -{ - { +bool test() { + { typedef std::string S; test(S(), ""); test(S("1"), ""); @@ -48,9 +47,9 @@ int main(int, char**) test(S("1234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890"), "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - } + } #if TEST_STD_VER >= 11 - { + { typedef std::basic_string, min_allocator> S; test(S(), ""); test(S("1"), ""); @@ -67,7 +66,17 @@ int main(int, char**) test(S("1234567890123456789012345678901234567890123456789012345678901234567890" "1234567890123456789012345678901234567890123456789012345678901234567890"), "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); - } + } +#endif + + return true; +} + +int main(int, char**) +{ + test(); +#if TEST_STD_VER > 17 + // static_assert(test()); #endif return 0; -- cgit v1.2.3