mirror of
https://github.com/clang-retro/llvm.git
synced 2026-12-05 00:29:35 -08:00
[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:
1 parent
1bcc28b884
commit
85e9b2687a
22 files changed
+61
-57
No files matched your search
+2
-2
@@ -30,7 +30,7 @@ test(S s, SV sv, typename S::size_type pos, typename S::size_type n, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
else
|
||||
else if (!TEST_IS_CONSTANT_EVALUATED)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -56,7 +56,7 @@ test_npos(S s, SV sv, typename S::size_type pos, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
else
|
||||
else if (!TEST_IS_CONSTANT_EVALUATED)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
+6
-3
@@ -172,7 +172,7 @@ bool test() {
|
||||
}
|
||||
#endif
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{ // test iterator operations that throw
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) { // test iterator operations that throw
|
||||
typedef std::string S;
|
||||
typedef ThrowingIterator<char> TIter;
|
||||
typedef cpp17_input_iterator<TIter> IIter;
|
||||
@@ -219,17 +219,20 @@ bool test() {
|
||||
std::string s_short = "hello";
|
||||
std::string s_long = "Lorem ipsum dolor sit amet, consectetur/";
|
||||
std::string s_othertype = "hello";
|
||||
const unsigned char *first = reinterpret_cast<const unsigned char*>(s_othertype.data());
|
||||
std::string s_sneaky = "hello";
|
||||
|
||||
test(s_short, s_short.data() + s_short.size(), s_short.data() + s_short.size() + 1,
|
||||
std::string("hello\0", 6));
|
||||
test(s_long, s_long.data() + s_long.size(), s_long.data() + s_long.size() + 1,
|
||||
std::string("Lorem ipsum dolor sit amet, consectetur/\0", 41));
|
||||
test(s_othertype, first + 2, first + 5, std::string("hellollo"));
|
||||
|
||||
s_sneaky.reserve(12);
|
||||
test(s_sneaky, s_sneaky.data(), s_sneaky.data() + 6, std::string("hellohello\0", 11));
|
||||
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
const unsigned char *first = reinterpret_cast<const unsigned char*>(s_othertype.data());
|
||||
test(s_othertype, first + 2, first + 5, std::string("hellollo"));
|
||||
}
|
||||
}
|
||||
|
||||
{ // test with a move iterator that returns char&&
|
||||
|
||||
+1
-1
@@ -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.append(str);
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
else
|
||||
else if (!TEST_IS_CONSTANT_EVALUATED)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -56,7 +56,7 @@ test_npos(S s, S str, typename S::size_type pos, S expected)
|
||||
assert(s == expected);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
else
|
||||
else if (!TEST_IS_CONSTANT_EVALUATED)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user