[libc++] Prepare string tests for constexpr

These are the last™ changes to the tests for constexpr preparation.

Reviewed By: Quuxplusone, #libc, Mordante

Spies: Mordante, EricWF, libcxx-commits

Differential Revision: https://reviews.llvm.org/D120951
This commit is contained in:
Nikolas Klauser
2022-03-10 20:15:23 +01:00
parent 1bcc28b884
commit 85e9b2687a
22 changed files with 61 additions and 57 deletions

View File

@@ -23,7 +23,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(typename S::size_type min_cap, typename S::size_type erased_index, typename S::size_type res_arg)
{
S s(min_cap, 'a');
@@ -47,7 +47,7 @@ test(typename S::size_type min_cap, typename S::size_type erased_index, typename
#endif
}
#ifndef TEST_HAS_NO_EXCEPTIONS
else
else if (!TEST_IS_CONSTANT_EVALUATED)
{
try
{

View File

@@ -28,7 +28,7 @@ test(S s, typename S::size_type n, S expected)
assert(s == expected);
}
#ifndef TEST_HAS_NO_EXCEPTIONS
else
else if (!TEST_IS_CONSTANT_EVALUATED)
{
try
{

View File

@@ -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)
{
if (n <= s.max_size())
@@ -28,7 +28,7 @@ test(S s, typename S::size_type n, typename S::value_type c, S expected)
assert(s == expected);
}
#ifndef TEST_HAS_NO_EXCEPTIONS
else
else if (!TEST_IS_CONSTANT_EVALUATED)
{
try
{

View File

@@ -17,7 +17,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(S s)
{
typename S::size_type old_cap = s.capacity();
@@ -30,7 +30,7 @@ test(S s)
}
bool test() {
{
{
typedef std::string S;
S s;
test(s);
@@ -42,9 +42,9 @@ bool test() {
s.assign(100, 'a');
s.erase(50);
test(s);
}
}
#if TEST_STD_VER >= 11
{
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s;
test(s);
@@ -56,7 +56,7 @@ bool test() {
s.assign(100, 'a');
s.erase(50);
test(s);
}
}
#endif
return true;