[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:
parent
f97795121f
commit
c515b652a0
|
@ -36,6 +36,9 @@ void test()
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
test();
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,9 @@ void test()
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
test();
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,9 @@ void test()
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
test();
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
S s1 {};
|
S s1 {};
|
||||||
|
@ -31,5 +30,15 @@ int main(int, char**)
|
||||||
assert (!s2.ends_with('x'));
|
assert (!s2.ends_with('x'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
const char *s = "abcde";
|
const char *s = "abcde";
|
||||||
|
@ -60,5 +59,14 @@ int main(int, char**)
|
||||||
assert ( sNot.ends_with("def"));
|
assert ( sNot.ends_with("def"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**) {
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
typedef std::string_view SV;
|
typedef std::string_view SV;
|
||||||
|
@ -69,5 +68,14 @@ int main(int, char**)
|
||||||
assert ( sNot.ends_with(svNot));
|
assert ( sNot.ends_with(svNot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**) {
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
void
|
TEST_CONSTEXPR_CXX20 void
|
||||||
test(S s)
|
test(S s)
|
||||||
{
|
{
|
||||||
const S& cs = s;
|
const S& cs = s;
|
||||||
|
@ -31,8 +31,7 @@ test(S s)
|
||||||
assert(b == cb);
|
assert(b == cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -46,5 +45,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
void
|
TEST_CONSTEXPR_CXX20 void
|
||||||
test(const S& s)
|
test(const S& s)
|
||||||
{
|
{
|
||||||
typename S::const_iterator cb = s.cbegin();
|
typename S::const_iterator cb = s.cbegin();
|
||||||
|
@ -28,8 +28,7 @@ test(const S& s)
|
||||||
assert(cb == s.begin());
|
assert(cb == s.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -43,5 +42,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,7 @@ test(const S& s)
|
||||||
assert(ce == s.end());
|
assert(ce == s.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -39,5 +38,14 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
void
|
TEST_CONSTEXPR_CXX20 void
|
||||||
test(const S& s)
|
test(const S& s)
|
||||||
{
|
{
|
||||||
typename S::const_reverse_iterator cb = s.crbegin();
|
typename S::const_reverse_iterator cb = s.crbegin();
|
||||||
|
@ -28,8 +28,7 @@ test(const S& s)
|
||||||
assert(cb == s.rbegin());
|
assert(cb == s.rbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -43,5 +42,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,14 @@
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
void
|
TEST_CONSTEXPR_CXX20 void
|
||||||
test(const S& s)
|
test(const S& s)
|
||||||
{
|
{
|
||||||
typename S::const_reverse_iterator ce = s.crend();
|
typename S::const_reverse_iterator ce = s.crend();
|
||||||
assert(ce == s.rend());
|
assert(ce == s.rend());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -39,5 +38,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
void
|
TEST_CONSTEXPR_CXX20 void
|
||||||
test(S s)
|
test(S s)
|
||||||
{
|
{
|
||||||
const S& cs = s;
|
const S& cs = s;
|
||||||
|
@ -34,8 +34,7 @@ test(S s)
|
||||||
assert(static_cast<std::size_t>(ce - cs.begin()) == cs.size());
|
assert(static_cast<std::size_t>(ce - cs.begin()) == cs.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -49,5 +48,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
void
|
TEST_CONSTEXPR_CXX20 void
|
||||||
test(S s)
|
test(S s)
|
||||||
{
|
{
|
||||||
const S& cs = s;
|
const S& cs = s;
|
||||||
|
@ -31,8 +31,7 @@ test(S s)
|
||||||
assert(b == cb);
|
assert(b == cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -46,5 +45,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,7 @@ test(S s)
|
||||||
assert(static_cast<std::size_t>(ce - cs.rbegin()) == cs.size());
|
assert(static_cast<std::size_t>(ce - cs.rbegin()) == cs.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
test(S());
|
test(S());
|
||||||
|
@ -49,5 +48,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
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;
|
typedef std::string S;
|
||||||
test_contiguous(S());
|
test_contiguous(S());
|
||||||
|
@ -51,5 +50,15 @@ int main(int, char**)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
S s1 {};
|
S s1 {};
|
||||||
|
@ -31,5 +30,15 @@ int main(int, char**)
|
||||||
assert (!s2.starts_with('x'));
|
assert (!s2.starts_with('x'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
const char *s = "abcde";
|
const char *s = "abcde";
|
||||||
|
@ -59,5 +58,15 @@ int main(int, char**)
|
||||||
assert ( sNot.starts_with("def"));
|
assert ( sNot.starts_with("def"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,7 @@
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
|
|
||||||
int main(int, char**)
|
bool test() {
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef std::string S;
|
typedef std::string S;
|
||||||
typedef std::string_view SV;
|
typedef std::string_view SV;
|
||||||
const char *s = "abcde";
|
const char *s = "abcde";
|
||||||
|
@ -67,7 +65,16 @@ int main(int, char**)
|
||||||
assert (!sNot.starts_with(sv4));
|
assert (!sNot.starts_with(sv4));
|
||||||
assert (!sNot.starts_with(sv5));
|
assert (!sNot.starts_with(sv5));
|
||||||
assert ( sNot.starts_with(svNot));
|
assert ( sNot.starts_with(svNot));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
test();
|
||||||
|
#if TEST_STD_VER > 17
|
||||||
|
// static_assert(test());
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue