[libc++] Prepare string.{access, capacity, cons} tests for constexpr

Reviewed By: ldionne, #libc

Spies: libcxx-commits, arphaman

Differential Revision: https://reviews.llvm.org/D119123
This commit is contained in:
Nikolas Klauser committed 2022-02-08 23:39:44 +01:00
1 parent ca9f0ec1a3
commit e85018b7dd
42 files changed
+734 -361

No files matched your search

@@ -18,7 +18,7 @@
#include "min_allocator.h"
template <class S>
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<char, std::char_traits<char>, min_allocator<char>> 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;