[libc++] Prepare string.{contains, ends_with, iterators, require, starts_with} tests for constexpr

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D119304
This commit is contained in:
Nikolas Klauser 2022-02-09 02:03:27 +01:00
parent f97795121f
commit c515b652a0
18 changed files with 231 additions and 92 deletions

View File

@ -36,6 +36,9 @@ void test()
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -66,6 +66,9 @@ void test()
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -87,6 +87,9 @@ void test()
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -16,8 +16,7 @@
#include "test_macros.h"
int main(int, char**)
{
bool test() {
{
typedef std::string S;
S s1 {};
@ -31,5 +30,15 @@ int main(int, char**)
assert (!s2.ends_with('x'));
}
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -16,8 +16,7 @@
#include "test_macros.h"
int main(int, char**)
{
bool test() {
{
typedef std::string S;
const char *s = "abcde";
@ -60,5 +59,14 @@ int main(int, char**)
assert ( sNot.ends_with("def"));
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -16,8 +16,7 @@
#include "test_macros.h"
int main(int, char**)
{
bool test() {
{
typedef std::string S;
typedef std::string_view SV;
@ -69,5 +68,14 @@ int main(int, char**)
assert ( sNot.ends_with(svNot));
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(S s)
{
const S& cs = s;
@ -31,8 +31,7 @@ test(S s)
assert(b == cb);
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -46,5 +45,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(const S& s)
{
typename S::const_iterator cb = s.cbegin();
@ -28,8 +28,7 @@ test(const S& s)
assert(cb == s.begin());
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -43,5 +42,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -24,8 +24,7 @@ test(const S& s)
assert(ce == s.end());
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -39,5 +38,14 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -17,7 +17,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(const S& s)
{
typename S::const_reverse_iterator cb = s.crbegin();
@ -28,8 +28,7 @@ test(const S& s)
assert(cb == s.rbegin());
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -43,5 +42,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -17,15 +17,14 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(const S& s)
{
typename S::const_reverse_iterator ce = s.crend();
assert(ce == s.rend());
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -39,5 +38,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -19,7 +19,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(S s)
{
const S& cs = s;
@ -34,8 +34,7 @@ test(S s)
assert(static_cast<std::size_t>(ce - cs.begin()) == cs.size());
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -49,5 +48,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -18,7 +18,7 @@
#include "min_allocator.h"
template <class S>
void
TEST_CONSTEXPR_CXX20 void
test(S s)
{
const S& cs = s;
@ -31,8 +31,7 @@ test(S s)
assert(b == cb);
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -46,5 +45,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -34,8 +34,7 @@ test(S s)
assert(static_cast<std::size_t>(ce - cs.rbegin()) == cs.size());
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test(S());
@ -49,5 +48,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -25,8 +25,7 @@ void test_contiguous ( const C &c )
assert ( *(c.begin() + static_cast<typename C::difference_type>(i)) == *(std::addressof(*c.begin()) + i));
}
int main(int, char**)
{
bool test() {
{
typedef std::string S;
test_contiguous(S());
@ -51,5 +50,15 @@ int main(int, char**)
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -16,8 +16,7 @@
#include "test_macros.h"
int main(int, char**)
{
bool test() {
{
typedef std::string S;
S s1 {};
@ -31,5 +30,15 @@ int main(int, char**)
assert (!s2.starts_with('x'));
}
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -16,8 +16,7 @@
#include "test_macros.h"
int main(int, char**)
{
bool test() {
{
typedef std::string S;
const char *s = "abcde";
@ -59,5 +58,15 @@ int main(int, char**)
assert ( sNot.starts_with("def"));
}
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}

View File

@ -16,9 +16,7 @@
#include "test_macros.h"
int main(int, char**)
{
{
bool test() {
typedef std::string S;
typedef std::string_view SV;
const char *s = "abcde";
@ -67,7 +65,16 @@ int main(int, char**)
assert (!sNot.starts_with(sv4));
assert (!sNot.starts_with(sv5));
assert ( sNot.starts_with(svNot));
}
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
// static_assert(test());
#endif
return 0;
}