Initial commit

This commit is contained in:
Yervant7
2024-01-16 19:28:29 -03:00
commit 8c0524dc0f
9054 changed files with 1081727 additions and 0 deletions
@@ -0,0 +1,170 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_istream<charT,traits>&
// getline(basic_istream<charT,traits>& is,
// basic_string<charT,traits,Allocator>& str);
#include <string>
#include <sstream>
#include <cassert>
#include "min_allocator.h"
#include "test_macros.h"
int main(int, char**)
{
{
std::istringstream in(" abc\n def\n ghij");
std::string s("initial text");
std::getline(in, s);
assert(in.good());
assert(s == " abc");
std::getline(in, s);
assert(in.good());
assert(s == " def");
std::getline(in, s);
assert(in.eof());
assert(s == " ghij");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::wistringstream in(L" abc\n def\n ghij");
std::wstring s(L"initial text");
std::getline(in, s);
assert(in.good());
assert(s == L" abc");
std::getline(in, s);
assert(in.good());
assert(s == L" def");
std::getline(in, s);
assert(in.eof());
assert(s == L" ghij");
}
#endif
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in(" abc\n def\n ghij");
S s("initial text");
std::getline(in, s);
assert(in.good());
assert(s == " abc");
std::getline(in, s);
assert(in.good());
assert(s == " def");
std::getline(in, s);
assert(in.eof());
assert(s == " ghij");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L" abc\n def\n ghij");
S s(L"initial text");
std::getline(in, s);
assert(in.good());
assert(s == L" abc");
std::getline(in, s);
assert(in.good());
assert(s == L" def");
std::getline(in, s);
assert(in.eof());
assert(s == L" ghij");
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS
#endif // TEST_STD_VER >= 11
#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::basic_stringbuf<char> sb("hello");
std::basic_istream<char> is(&sb);
is.exceptions(std::ios_base::eofbit);
std::basic_string<char> s;
bool threw = false;
try {
std::getline(is, s);
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert(!is.fail());
assert( is.eof());
assert(threw);
assert(s == "hello");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_stringbuf<wchar_t> sb(L"hello");
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios_base::eofbit);
std::basic_string<wchar_t> s;
bool threw = false;
try {
std::getline(is, s);
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert(!is.fail());
assert( is.eof());
assert(threw);
assert(s == L"hello");
}
#endif
{
std::basic_stringbuf<char> sb;
std::basic_istream<char> is(&sb);
is.exceptions(std::ios_base::failbit);
std::basic_string<char> s;
bool threw = false;
try {
std::getline(is, s);
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert( is.fail());
assert( is.eof());
assert(threw);
assert(s == "");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_stringbuf<wchar_t> sb;
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios_base::failbit);
std::basic_string<wchar_t> s;
bool threw = false;
try {
std::getline(is, s);
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert( is.fail());
assert( is.eof());
assert(threw);
assert(s == L"");
}
#endif
#endif // TEST_HAS_NO_EXCEPTIONS
return 0;
}
@@ -0,0 +1,181 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_istream<charT,traits>&
// getline(basic_istream<charT,traits>& is,
// basic_string<charT,traits,Allocator>& str, charT delim);
#include <string>
#include <sstream>
#include <cassert>
#include "min_allocator.h"
#include "test_macros.h"
int main(int, char**)
{
{
std::istringstream in(" abc* def** ghij");
std::string s("initial text");
std::getline(in, s, '*');
assert(in.good());
assert(s == " abc");
std::getline(in, s, '*');
assert(in.good());
assert(s == " def");
std::getline(in, s, '*');
assert(in.good());
assert(s == "");
std::getline(in, s, '*');
assert(in.eof());
assert(s == " ghij");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::wistringstream in(L" abc* def** ghij");
std::wstring s(L"initial text");
std::getline(in, s, L'*');
assert(in.good());
assert(s == L" abc");
std::getline(in, s, L'*');
assert(in.good());
assert(s == L" def");
std::getline(in, s, L'*');
assert(in.good());
assert(s == L"");
std::getline(in, s, L'*');
assert(in.eof());
assert(s == L" ghij");
}
#endif
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in(" abc* def** ghij");
S s("initial text");
std::getline(in, s, '*');
assert(in.good());
assert(s == " abc");
std::getline(in, s, '*');
assert(in.good());
assert(s == " def");
std::getline(in, s, '*');
assert(in.good());
assert(s == "");
std::getline(in, s, '*');
assert(in.eof());
assert(s == " ghij");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L" abc* def** ghij");
S s(L"initial text");
std::getline(in, s, L'*');
assert(in.good());
assert(s == L" abc");
std::getline(in, s, L'*');
assert(in.good());
assert(s == L" def");
std::getline(in, s, L'*');
assert(in.good());
assert(s == L"");
std::getline(in, s, L'*');
assert(in.eof());
assert(s == L" ghij");
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS
#endif // TEST_STD_VER >= 11
#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::basic_stringbuf<char> sb("hello");
std::basic_istream<char> is(&sb);
is.exceptions(std::ios::eofbit);
std::basic_string<char> s;
bool threw = false;
try {
std::getline(is, s, '\n');
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert(!is.fail());
assert( is.eof());
assert(threw);
assert(s == "hello");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_stringbuf<wchar_t> sb(L"hello");
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios::eofbit);
std::basic_string<wchar_t> s;
bool threw = false;
try {
std::getline(is, s, L'\n');
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert(!is.fail());
assert( is.eof());
assert(threw);
assert(s == L"hello");
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_stringbuf<char> sb;
std::basic_istream<char> is(&sb);
is.exceptions(std::ios::failbit);
std::basic_string<char> s;
bool threw = false;
try {
std::getline(is, s, '\n');
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert( is.fail());
assert( is.eof());
assert(threw);
assert(s == "");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_stringbuf<wchar_t> sb;
std::basic_istream<wchar_t> is(&sb);
is.exceptions(std::ios::failbit);
std::basic_string<wchar_t> s;
bool threw = false;
try {
std::getline(is, s, L'\n');
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert( is.fail());
assert( is.eof());
assert(threw);
assert(s == L"");
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS
#endif // TEST_HAS_NO_EXCEPTIONS
return 0;
}
@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_istream<charT,traits>&
// getline(basic_istream<charT,traits>&& is,
// basic_string<charT,traits,Allocator>& str, charT delim);
#include <string>
#include <sstream>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
{
{
std::string s("initial text");
std::getline(std::istringstream(" abc* def* ghij"), s, '*');
assert(s == " abc");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::wstring s(L"initial text");
std::getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
assert(s == L" abc");
}
#endif
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s("initial text");
std::getline(std::istringstream(" abc* def* ghij"), s, '*');
assert(s == " abc");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t> > S;
S s(L"initial text");
std::getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
assert(s == L" abc");
}
#endif
return 0;
}
@@ -0,0 +1,53 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_istream<charT,traits>&
// getline(basic_istream<charT,traits>&& is,
// basic_string<charT,traits,Allocator>& str);
#include <string>
#include <sstream>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
{
{
std::string s("initial text");
std::getline(std::istringstream(" abc\n def\n ghij"), s);
assert(s == " abc");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::wstring s(L"initial text");
std::getline(std::wistringstream(L" abc\n def\n ghij"), s);
assert(s == L" abc");
}
#endif
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char> > S;
S s("initial text");
std::getline(std::istringstream(" abc\n def\n ghij"), s);
assert(s == " abc");
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t> > S;
S s(L"initial text");
std::getline(std::wistringstream(L" abc\n def\n ghij"), s);
assert(s == L" abc");
}
#endif
return 0;
}
@@ -0,0 +1,3 @@
# These std::string functions require iostreams, which requires localization
if 'no-localization' in config.available_features:
config.unsupported = True
@@ -0,0 +1,161 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_istream<charT,traits>&
// operator>>(basic_istream<charT,traits>& is,
// basic_string<charT,traits,Allocator>& str);
#include <string>
#include <sstream>
#include <cassert>
#include "min_allocator.h"
#include "test_macros.h"
int main(int, char**)
{
{
std::istringstream in("a bc defghij");
std::string s("initial text");
in >> s;
assert(in.good());
assert(s == "a");
assert(in.peek() == ' ');
in >> s;
assert(in.good());
assert(s == "bc");
assert(in.peek() == ' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == "def");
assert(in.peek() == 'g');
in >> s;
assert(in.eof());
assert(s == "ghij");
in >> s;
assert(in.fail());
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::wistringstream in(L"a bc defghij");
std::wstring s(L"initial text");
in >> s;
assert(in.good());
assert(s == L"a");
assert(in.peek() == L' ');
in >> s;
assert(in.good());
assert(s == L"bc");
assert(in.peek() == L' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == L"def");
assert(in.peek() == L'g');
in >> s;
assert(in.eof());
assert(s == L"ghij");
in >> s;
assert(in.fail());
}
#endif
#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::stringbuf sb;
std::istream is(&sb);
is.exceptions(std::ios::failbit);
bool threw = false;
try {
std::string s;
is >> s;
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert(is.fail());
assert(is.eof());
assert(threw);
}
{
std::stringbuf sb;
std::istream is(&sb);
is.exceptions(std::ios::eofbit);
bool threw = false;
try {
std::string s;
is >> s;
} catch (std::ios::failure const&) {
threw = true;
}
assert(!is.bad());
assert(is.fail());
assert(is.eof());
assert(threw);
}
#endif // TEST_HAS_NO_EXCEPTIONS
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::istringstream in("a bc defghij");
S s("initial text");
in >> s;
assert(in.good());
assert(s == "a");
assert(in.peek() == ' ');
in >> s;
assert(in.good());
assert(s == "bc");
assert(in.peek() == ' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == "def");
assert(in.peek() == 'g');
in >> s;
assert(in.eof());
assert(s == "ghij");
in >> s;
assert(in.fail());
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::wistringstream in(L"a bc defghij");
S s(L"initial text");
in >> s;
assert(in.good());
assert(s == L"a");
assert(in.peek() == L' ');
in >> s;
assert(in.good());
assert(s == L"bc");
assert(in.peek() == L' ');
in.width(3);
in >> s;
assert(in.good());
assert(s == L"def");
assert(in.peek() == L'g');
in >> s;
assert(in.eof());
assert(s == L"ghij");
in >> s;
assert(in.fail());
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS
#endif // TEST_STD_VER >= 11
return 0;
}
@@ -0,0 +1,97 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_ostream<charT, traits>&
// operator<<(basic_ostream<charT, traits>& os,
// const basic_string<charT,traits,Allocator>& str);
#include <string>
#include <sstream>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
int main(int, char**)
{
{
std::ostringstream out;
std::string s("some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
std::ostringstream out;
std::string s("some text");
out.width(12);
out << s;
assert(out.good());
assert(" " + s == out.str());
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::wostringstream out;
std::wstring s(L"some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
std::wostringstream out;
std::wstring s(L"some text");
out.width(12);
out << s;
assert(out.good());
assert(L" " + s == out.str());
}
#endif
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s("some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s("some text");
out.width(12);
out << s;
assert(out.good());
assert(" " + s == out.str());
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s(L"some text");
out << s;
assert(out.good());
assert(s == out.str());
}
{
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
S s(L"some text");
out.width(12);
out << s;
assert(out.good());
assert(L" " + s == out.str());
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS
#endif // TEST_STD_VER >= 11
return 0;
}
@@ -0,0 +1,89 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// void swap(basic_string<charT,traits,Allocator>& lhs,
// basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(S s1, S s2)
{
S s1_ = s1;
S s2_ = s2;
swap(s1, s2);
LIBCPP_ASSERT(s1.__invariants());
LIBCPP_ASSERT(s2.__invariants());
assert(s1 == s2_);
assert(s2 == s1_);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), S(""));
test(S(""), S("12345"));
test(S(""), S("1234567890"));
test(S(""), S("12345678901234567890"));
test(S("abcde"), S(""));
test(S("abcde"), S("12345"));
test(S("abcde"), S("1234567890"));
test(S("abcde"), S("12345678901234567890"));
test(S("abcdefghij"), S(""));
test(S("abcdefghij"), S("12345"));
test(S("abcdefghij"), S("1234567890"));
test(S("abcdefghij"), S("12345678901234567890"));
test(S("abcdefghijklmnopqrst"), S(""));
test(S("abcdefghijklmnopqrst"), S("12345"));
test(S("abcdefghijklmnopqrst"), S("1234567890"));
test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""));
test(S(""), S("12345"));
test(S(""), S("1234567890"));
test(S(""), S("12345678901234567890"));
test(S("abcde"), S(""));
test(S("abcde"), S("12345"));
test(S("abcde"), S("1234567890"));
test(S("abcde"), S("12345678901234567890"));
test(S("abcdefghij"), S(""));
test(S("abcdefghij"), S("12345"));
test(S("abcdefghij"), S("1234567890"));
test(S("abcdefghij"), S("12345678901234567890"));
test(S("abcdefghijklmnopqrst"), S(""));
test(S("abcdefghijklmnopqrst"), S("12345"));
test(S("abcdefghijklmnopqrst"), S("1234567890"));
test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,86 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03
// <string>
// void swap(basic_string& c)
// noexcept(!allocator_type::propagate_on_container_swap::value ||
// __is_nothrow_swappable<allocator_type>::value); // constexpr since C++20
//
// In C++17, the standard says that swap shall have:
// noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
// allocator_traits<Allocator>::is_always_equal::value); // constexpr since C++20
// This tests a conforming extension
#include <string>
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "test_allocator.h"
template <class T>
struct some_alloc
{
typedef T value_type;
some_alloc() {}
some_alloc(const some_alloc&);
T *allocate(size_t);
void deallocate(void*, unsigned) {}
typedef std::true_type propagate_on_container_swap;
};
template <class T>
struct some_alloc2
{
typedef T value_type;
some_alloc2() {}
some_alloc2(const some_alloc2&);
T *allocate(size_t);
void deallocate(void*, unsigned) {}
typedef std::false_type propagate_on_container_swap;
typedef std::true_type is_always_equal;
};
int main(int, char**)
{
{
typedef std::string C;
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#if defined(_LIBCPP_VERSION)
{
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif // _LIBCPP_VERSION
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
#if TEST_STD_VER >= 14
// In C++14, if POCS is set, swapping the allocator is required not to throw
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
#else
static_assert(!noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
#endif
}
#if TEST_STD_VER >= 14
{
typedef std::basic_string<char, std::char_traits<char>, some_alloc2<char>> C;
// if the allocators are always equal, then the swap can be noexcept
static_assert( noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
}
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const typename S::value_type* lhs, const S& rhs, bool x)
{
assert((lhs != rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test("", S(""), false);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), true);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test("", S(""), false);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), true);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator!=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs != rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), "", false);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", false);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const S& rhs, bool x)
{
assert((lhs != rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), S(""), false);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""), false);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, SV rhs, bool x)
{
assert((lhs != rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string SV;
test(S(""), SV(""), false);
test(S(""), SV("abcde"), true);
test(S(""), SV("abcdefghij"), true);
test(S(""), SV("abcdefghijklmnopqrst"), true);
test(S("abcde"), SV(""), true);
test(S("abcde"), SV("abcde"), false);
test(S("abcde"), SV("abcdefghij"), true);
test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), SV(""), true);
test(S("abcdefghij"), SV("abcde"), true);
test(S("abcdefghij"), SV("abcdefghij"), false);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), SV(""), true);
test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(S(""), SV(""), false);
test(S(""), SV("abcde"), true);
test(S(""), SV("abcdefghij"), true);
test(S(""), SV("abcdefghijklmnopqrst"), true);
test(S("abcde"), SV(""), true);
test(S("abcde"), SV("abcde"), false);
test(S("abcde"), SV("abcdefghij"), true);
test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), SV(""), true);
test(S("abcdefghij"), SV("abcde"), true);
test(S("abcdefghij"), SV("abcdefghij"), false);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), SV(""), true);
test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(SV lhs, const S& rhs, bool x)
{
assert((lhs != rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(SV(""), S(""), false);
test(SV(""), S("abcde"), true);
test(SV(""), S("abcdefghij"), true);
test(SV(""), S("abcdefghijklmnopqrst"), true);
test(SV("abcde"), S(""), true);
test(SV("abcde"), S("abcde"), false);
test(SV("abcde"), S("abcdefghij"), true);
test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghij"), S(""), true);
test(SV("abcdefghij"), S("abcde"), true);
test(SV("abcdefghij"), S("abcdefghij"), false);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghijklmnopqrst"), S(""), true);
test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(SV(""), S(""), false);
test(SV(""), S("abcde"), true);
test(SV(""), S("abcdefghij"), true);
test(SV(""), S("abcdefghijklmnopqrst"), true);
test(SV("abcde"), S(""), true);
test(SV("abcde"), S("abcde"), false);
test(SV("abcde"), S("abcdefghij"), true);
test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghij"), S(""), true);
test(SV("abcdefghij"), S("abcde"), true);
test(SV("abcdefghij"), S("abcdefghij"), false);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghijklmnopqrst"), S(""), true);
test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,200 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// This test ensures that we properly propagate allocators, per https://wg21.link/p1165r1
#include <cassert>
#include <string>
#include "test_macros.h"
template <class T>
class soccc_allocator {
int* soccc_count;
int self_soccc_count;
public:
using value_type = T;
constexpr explicit soccc_allocator(int* soccc_count_, int self_coccc_count_ = 0)
: soccc_count(soccc_count_), self_soccc_count(self_coccc_count_) {}
template <class U>
constexpr soccc_allocator(const soccc_allocator<U>& a) : soccc_count(a.soccc_count) {}
constexpr T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
constexpr void deallocate(T* p, std::size_t s) { std::allocator<T>().deallocate(p, s); }
constexpr soccc_allocator select_on_container_copy_construction() const {
*soccc_count += 1;
return soccc_allocator(soccc_count, self_soccc_count + 1);
}
constexpr auto get_soccc() { return soccc_count; }
constexpr auto get_self_soccc() { return self_soccc_count; }
typedef std::true_type propagate_on_container_copy_assignment;
typedef std::true_type propagate_on_container_move_assignment;
typedef std::true_type propagate_on_container_swap;
};
template <class CharT>
TEST_CONSTEXPR_CXX20 bool test() {
using S = std::basic_string<CharT, std::char_traits<CharT>, soccc_allocator<CharT>>;
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs + rhs;
assert(r.get_allocator().get_soccc() == &soccc_lhs);
assert(r.get_allocator().get_self_soccc() == 1);
assert(soccc_lhs == 1);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs + std::move(rhs);
assert(r.get_allocator().get_soccc() == &soccc_rhs);
assert(r.get_allocator().get_self_soccc() == 0);
assert(soccc_lhs == 0);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = std::move(lhs) + rhs;
assert(r.get_allocator().get_soccc() == &soccc_lhs);
assert(r.get_allocator().get_self_soccc() == 0);
assert(soccc_lhs == 0);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = std::move(lhs) + std::move(rhs);
assert(r.get_allocator().get_soccc() == &soccc_lhs);
assert(r.get_allocator().get_self_soccc() == 0);
assert(soccc_lhs == 0);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs + rhs.data();
assert(r.get_allocator().get_soccc() == &soccc_lhs);
assert(r.get_allocator().get_self_soccc() == 1);
assert(soccc_lhs == 1);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs + rhs[0];
assert(r.get_allocator().get_soccc() == &soccc_lhs);
assert(r.get_allocator().get_self_soccc() == 1);
assert(soccc_lhs == 1);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = std::move(lhs) + rhs.data();
assert(r.get_allocator().get_soccc() == &soccc_lhs);
assert(r.get_allocator().get_self_soccc() == 0);
assert(soccc_lhs == 0);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = std::move(lhs) + rhs[0];
assert(r.get_allocator().get_soccc() == &soccc_lhs);
assert(r.get_allocator().get_self_soccc() == 0);
assert(soccc_lhs == 0);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs.data() + rhs;
assert(r.get_allocator().get_soccc() == &soccc_rhs);
assert(r.get_allocator().get_self_soccc() == 1);
assert(soccc_lhs == 0);
assert(soccc_rhs == 1);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs[0] + rhs;
assert(r.get_allocator().get_soccc() == &soccc_rhs);
assert(r.get_allocator().get_self_soccc() == 1);
assert(soccc_lhs == 0);
assert(soccc_rhs == 1);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs.data() + std::move(rhs);
assert(r.get_allocator().get_soccc() == &soccc_rhs);
assert(r.get_allocator().get_self_soccc() == 0);
assert(soccc_lhs == 0);
assert(soccc_rhs == 0);
}
{
int soccc_lhs = 0;
int soccc_rhs = 0;
S lhs(soccc_allocator<CharT>{&soccc_lhs});
S rhs(soccc_allocator<CharT>{&soccc_rhs});
auto r = lhs[0] + std::move(rhs);
assert(r.get_allocator().get_soccc() == &soccc_rhs);
assert(r.get_allocator().get_self_soccc() == 0);
assert(soccc_lhs == 0);
assert(soccc_rhs == 0);
}
return true;
}
int main(int, char**) {
test<char>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test<wchar_t>();
#endif
#if TEST_STD_VER > 17
static_assert(test<char>());
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
static_assert(test<wchar_t>());
#endif
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>
// operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>&&
// operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs); // constexpr since C++20
#include <string>
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void test0(typename S::value_type lhs, const S& rhs, const S& x) {
assert(lhs + rhs == x);
}
#if TEST_STD_VER >= 11
template <class S>
TEST_CONSTEXPR_CXX20 void test1(typename S::value_type lhs, S&& rhs, const S& x) {
assert(lhs + std::move(rhs) == x);
}
#endif
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test0('a', S(""), S("a"));
test0('a', S("12345"), S("a12345"));
test0('a', S("1234567890"), S("a1234567890"));
test0('a', S("12345678901234567890"), S("a12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1('a', S(""), S("a"));
test1('a', S("12345"), S("a12345"));
test1('a', S("1234567890"), S("a1234567890"));
test1('a', S("12345678901234567890"), S("a12345678901234567890"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0('a', S(""), S("a"));
test0('a', S("12345"), S("a12345"));
test0('a', S("1234567890"), S("a1234567890"));
test0('a', S("12345678901234567890"), S("a12345678901234567890"));
test1('a', S(""), S("a"));
test1('a', S("12345"), S("a12345"));
test1('a', S("1234567890"), S("a1234567890"));
test1('a', S("12345678901234567890"), S("a12345678901234567890"));
}
#endif
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,141 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>
// operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>&&
// operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs); // constexpr since C++20
#include <string>
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void test0(const typename S::value_type* lhs, const S& rhs, const S& x) {
assert(lhs + rhs == x);
}
#if TEST_STD_VER >= 11
template <class S>
TEST_CONSTEXPR_CXX20 void test1(const typename S::value_type* lhs, S&& rhs, const S& x) {
assert(lhs + std::move(rhs) == x);
}
#endif
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test0("", S(""), S(""));
test0("", S("12345"), S("12345"));
test0("", S("1234567890"), S("1234567890"));
test0("", S("12345678901234567890"), S("12345678901234567890"));
test0("abcde", S(""), S("abcde"));
test0("abcde", S("12345"), S("abcde12345"));
test0("abcde", S("1234567890"), S("abcde1234567890"));
test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
test0("abcdefghij", S(""), S("abcdefghij"));
test0("abcdefghij", S("12345"), S("abcdefghij12345"));
test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test0("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test0("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1("", S(""), S(""));
test1("", S("12345"), S("12345"));
test1("", S("1234567890"), S("1234567890"));
test1("", S("12345678901234567890"), S("12345678901234567890"));
test1("abcde", S(""), S("abcde"));
test1("abcde", S("12345"), S("abcde12345"));
test1("abcde", S("1234567890"), S("abcde1234567890"));
test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
test1("abcdefghij", S(""), S("abcdefghij"));
test1("abcdefghij", S("12345"), S("abcdefghij12345"));
test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test1("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test1("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0("", S(""), S(""));
test0("", S("12345"), S("12345"));
test0("", S("1234567890"), S("1234567890"));
test0("", S("12345678901234567890"), S("12345678901234567890"));
test0("abcde", S(""), S("abcde"));
test0("abcde", S("12345"), S("abcde12345"));
test0("abcde", S("1234567890"), S("abcde1234567890"));
test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
test0("abcdefghij", S(""), S("abcdefghij"));
test0("abcdefghij", S("12345"), S("abcdefghij12345"));
test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test0("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test0("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test1("", S(""), S(""));
test1("", S("12345"), S("12345"));
test1("", S("1234567890"), S("1234567890"));
test1("", S("12345678901234567890"), S("12345678901234567890"));
test1("abcde", S(""), S("abcde"));
test1("abcde", S("12345"), S("abcde12345"));
test1("abcde", S("1234567890"), S("abcde1234567890"));
test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
test1("abcdefghij", S(""), S("abcdefghij"));
test1("abcdefghij", S("12345"), S("abcdefghij12345"));
test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test1("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test1("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#endif
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>
// operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs); // constexpr since C++20
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>&&
// operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs); // constexpr since C++20
#include <string>
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void test0(const S& lhs, typename S::value_type rhs, const S& x) {
assert(lhs + rhs == x);
}
#if TEST_STD_VER >= 11
template <class S>
TEST_CONSTEXPR_CXX20 void test1(S&& lhs, typename S::value_type rhs, const S& x) {
assert(std::move(lhs) + rhs == x);
}
#endif
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test0(S(""), '1', S("1"));
test0(S("abcde"), '1', S("abcde1"));
test0(S("abcdefghij"), '1', S("abcdefghij1"));
test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1(S(""), '1', S("1"));
test1(S("abcde"), '1', S("abcde1"));
test1(S("abcdefghij"), '1', S("abcdefghij1"));
test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0(S(""), '1', S("1"));
test0(S("abcde"), '1', S("abcde1"));
test0(S("abcdefghij"), '1', S("abcdefghij1"));
test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
test1(S(""), '1', S("1"));
test1(S("abcde"), '1', S("abcde1"));
test1(S("abcdefghij"), '1', S("abcdefghij1"));
test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
}
#endif
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,140 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>
// operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>&&
// operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs); // constexpr since C++20
#include <string>
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void test0(const S& lhs, const typename S::value_type* rhs, const S& x) {
assert(lhs + rhs == x);
}
#if TEST_STD_VER >= 11
template <class S>
TEST_CONSTEXPR_CXX20 void test1(S&& lhs, const typename S::value_type* rhs, const S& x) {
assert(std::move(lhs) + rhs == x);
}
#endif
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test0(S(""), "", S(""));
test0(S(""), "12345", S("12345"));
test0(S(""), "1234567890", S("1234567890"));
test0(S(""), "12345678901234567890", S("12345678901234567890"));
test0(S("abcde"), "", S("abcde"));
test0(S("abcde"), "12345", S("abcde12345"));
test0(S("abcde"), "1234567890", S("abcde1234567890"));
test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
test0(S("abcdefghij"), "", S("abcdefghij"));
test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test0(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1(S(""), "", S(""));
test1(S(""), "12345", S("12345"));
test1(S(""), "1234567890", S("1234567890"));
test1(S(""), "12345678901234567890", S("12345678901234567890"));
test1(S("abcde"), "", S("abcde"));
test1(S("abcde"), "12345", S("abcde12345"));
test1(S("abcde"), "1234567890", S("abcde1234567890"));
test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
test1(S("abcdefghij"), "", S("abcdefghij"));
test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test1(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0(S(""), "", S(""));
test0(S(""), "12345", S("12345"));
test0(S(""), "1234567890", S("1234567890"));
test0(S(""), "12345678901234567890", S("12345678901234567890"));
test0(S("abcde"), "", S("abcde"));
test0(S("abcde"), "12345", S("abcde12345"));
test0(S("abcde"), "1234567890", S("abcde1234567890"));
test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
test0(S("abcdefghij"), "", S("abcdefghij"));
test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test0(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
test1(S(""), "", S(""));
test1(S(""), "12345", S("12345"));
test1(S(""), "1234567890", S("1234567890"));
test1(S(""), "12345678901234567890", S("12345678901234567890"));
test1(S("abcde"), "", S("abcde"));
test1(S("abcde"), "12345", S("abcde12345"));
test1(S("abcde"), "1234567890", S("abcde1234567890"));
test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
test1(S("abcdefghij"), "", S("abcdefghij"));
test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test1(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
}
#endif
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,258 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>
// operator+(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>&&
// operator+(const basic_string<charT,traits,Allocator>&& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>&&
// operator+(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>&& rhs); // constexpr since C++20
// template<class charT, class traits, class Allocator>
// basic_string<charT,traits,Allocator>&&
// operator+(const basic_string<charT,traits,Allocator>&& lhs,
// const basic_string<charT,traits,Allocator>&& rhs); // constexpr since C++20
#include <string>
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void test0(const S& lhs, const S& rhs, const S& x) {
assert(lhs + rhs == x);
}
#if TEST_STD_VER >= 11
template <class S>
TEST_CONSTEXPR_CXX20 void test1(S&& lhs, const S& rhs, const S& x) {
assert(std::move(lhs) + rhs == x);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test2(const S& lhs, S&& rhs, const S& x) {
assert(lhs + std::move(rhs) == x);
}
template <class S>
TEST_CONSTEXPR_CXX20 void test3(S&& lhs, S&& rhs, const S& x) {
assert(std::move(lhs) + std::move(rhs) == x);
}
#endif
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test0(S(""), S(""), S(""));
test0(S(""), S("12345"), S("12345"));
test0(S(""), S("1234567890"), S("1234567890"));
test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
test0(S("abcde"), S(""), S("abcde"));
test0(S("abcde"), S("12345"), S("abcde12345"));
test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
test0(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test0(S("abcdefghij"), S(""), S("abcdefghij"));
test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test0(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1(S(""), S(""), S(""));
test1(S(""), S("12345"), S("12345"));
test1(S(""), S("1234567890"), S("1234567890"));
test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
test1(S("abcde"), S(""), S("abcde"));
test1(S("abcde"), S("12345"), S("abcde12345"));
test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
test1(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test1(S("abcdefghij"), S(""), S("abcdefghij"));
test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test1(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test2(S(""), S(""), S(""));
test2(S(""), S("12345"), S("12345"));
test2(S(""), S("1234567890"), S("1234567890"));
test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
test2(S("abcde"), S(""), S("abcde"));
test2(S("abcde"), S("12345"), S("abcde12345"));
test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
test2(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test2(S("abcdefghij"), S(""), S("abcdefghij"));
test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test2(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test2(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test2(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test3(S(""), S(""), S(""));
test3(S(""), S("12345"), S("12345"));
test3(S(""), S("1234567890"), S("1234567890"));
test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
test3(S("abcde"), S(""), S("abcde"));
test3(S("abcde"), S("12345"), S("abcde12345"));
test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
test3(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test3(S("abcdefghij"), S(""), S("abcdefghij"));
test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test3(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test3(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test3(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0(S(""), S(""), S(""));
test0(S(""), S("12345"), S("12345"));
test0(S(""), S("1234567890"), S("1234567890"));
test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
test0(S("abcde"), S(""), S("abcde"));
test0(S("abcde"), S("12345"), S("abcde12345"));
test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
test0(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test0(S("abcdefghij"), S(""), S("abcdefghij"));
test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test0(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test1(S(""), S(""), S(""));
test1(S(""), S("12345"), S("12345"));
test1(S(""), S("1234567890"), S("1234567890"));
test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
test1(S("abcde"), S(""), S("abcde"));
test1(S("abcde"), S("12345"), S("abcde12345"));
test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
test1(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test1(S("abcdefghij"), S(""), S("abcdefghij"));
test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test1(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test2(S(""), S(""), S(""));
test2(S(""), S("12345"), S("12345"));
test2(S(""), S("1234567890"), S("1234567890"));
test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
test2(S("abcde"), S(""), S("abcde"));
test2(S("abcde"), S("12345"), S("abcde12345"));
test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
test2(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test2(S("abcdefghij"), S(""), S("abcdefghij"));
test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test2(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test2(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test2(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test3(S(""), S(""), S(""));
test3(S(""), S("12345"), S("12345"));
test3(S(""), S("1234567890"), S("1234567890"));
test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
test3(S("abcde"), S(""), S("abcde"));
test3(S("abcde"), S("12345"), S("abcde12345"));
test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
test3(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test3(S("abcdefghij"), S(""), S("abcdefghij"));
test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test3(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test3(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test3(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#endif // TEST_STD_VER >= 11
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const typename S::value_type* lhs, const S& rhs, bool x)
{
assert((lhs == rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test("", S(""), true);
test("", S("abcde"), false);
test("", S("abcdefghij"), false);
test("", S("abcdefghijklmnopqrst"), false);
test("abcde", S(""), false);
test("abcde", S("abcde"), true);
test("abcde", S("abcdefghij"), false);
test("abcde", S("abcdefghijklmnopqrst"), false);
test("abcdefghij", S(""), false);
test("abcdefghij", S("abcde"), false);
test("abcdefghij", S("abcdefghij"), true);
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
test("abcdefghijklmnopqrst", S(""), false);
test("abcdefghijklmnopqrst", S("abcde"), false);
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test("", S(""), true);
test("", S("abcde"), false);
test("", S("abcdefghij"), false);
test("", S("abcdefghijklmnopqrst"), false);
test("abcde", S(""), false);
test("abcde", S("abcde"), true);
test("abcde", S("abcdefghij"), false);
test("abcde", S("abcdefghijklmnopqrst"), false);
test("abcdefghij", S(""), false);
test("abcdefghij", S("abcde"), false);
test("abcdefghij", S("abcdefghij"), true);
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
test("abcdefghijklmnopqrst", S(""), false);
test("abcdefghijklmnopqrst", S("abcde"), false);
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs == rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), "", true);
test(S(""), "abcde", false);
test(S(""), "abcdefghij", false);
test(S(""), "abcdefghijklmnopqrst", false);
test(S("abcde"), "", false);
test(S("abcde"), "abcde", true);
test(S("abcde"), "abcdefghij", false);
test(S("abcde"), "abcdefghijklmnopqrst", false);
test(S("abcdefghij"), "", false);
test(S("abcdefghij"), "abcde", false);
test(S("abcdefghij"), "abcdefghij", true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
test(S("abcdefghijklmnopqrst"), "", false);
test(S("abcdefghijklmnopqrst"), "abcde", false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", true);
test(S(""), "abcde", false);
test(S(""), "abcdefghij", false);
test(S(""), "abcdefghijklmnopqrst", false);
test(S("abcde"), "", false);
test(S("abcde"), "abcde", true);
test(S("abcde"), "abcdefghij", false);
test(S("abcde"), "abcdefghijklmnopqrst", false);
test(S("abcdefghij"), "", false);
test(S("abcdefghij"), "abcde", false);
test(S("abcdefghij"), "abcdefghij", true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
test(S("abcdefghijklmnopqrst"), "", false);
test(S("abcdefghijklmnopqrst"), "abcde", false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator==(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const S& rhs, bool x)
{
assert((lhs == rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), S(""), true);
test(S(""), S("abcde"), false);
test(S(""), S("abcdefghij"), false);
test(S(""), S("abcdefghijklmnopqrst"), false);
test(S("abcde"), S(""), false);
test(S("abcde"), S("abcde"), true);
test(S("abcde"), S("abcdefghij"), false);
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), S(""), false);
test(S("abcdefghij"), S("abcde"), false);
test(S("abcdefghij"), S("abcdefghij"), true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), S(""), false);
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""), true);
test(S(""), S("abcde"), false);
test(S(""), S("abcdefghij"), false);
test(S(""), S("abcdefghijklmnopqrst"), false);
test(S("abcde"), S(""), false);
test(S("abcde"), S("abcde"), true);
test(S("abcde"), S("abcdefghij"), false);
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), S(""), false);
test(S("abcdefghij"), S("abcde"), false);
test(S("abcdefghij"), S("abcdefghij"), true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), S(""), false);
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, SV rhs, bool x)
{
assert((lhs == rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(""), SV(""), true);
test(S(""), SV("abcde"), false);
test(S(""), SV("abcdefghij"), false);
test(S(""), SV("abcdefghijklmnopqrst"), false);
test(S("abcde"), SV(""), false);
test(S("abcde"), SV("abcde"), true);
test(S("abcde"), SV("abcdefghij"), false);
test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), SV(""), false);
test(S("abcdefghij"), SV("abcde"), false);
test(S("abcdefghij"), SV("abcdefghij"), true);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), SV(""), false);
test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string <char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(S(""), SV(""), true);
test(S(""), SV("abcde"), false);
test(S(""), SV("abcdefghij"), false);
test(S(""), SV("abcdefghijklmnopqrst"), false);
test(S("abcde"), SV(""), false);
test(S("abcde"), SV("abcde"), true);
test(S("abcde"), SV("abcdefghij"), false);
test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), SV(""), false);
test(S("abcdefghij"), SV("abcde"), false);
test(S("abcdefghij"), SV("abcdefghij"), true);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), SV(""), false);
test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(SV lhs, const S& rhs, bool x)
{
assert((lhs == rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(SV(""), S(""), true);
test(SV(""), S("abcde"), false);
test(SV(""), S("abcdefghij"), false);
test(SV(""), S("abcdefghijklmnopqrst"), false);
test(SV("abcde"), S(""), false);
test(SV("abcde"), S("abcde"), true);
test(SV("abcde"), S("abcdefghij"), false);
test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghij"), S(""), false);
test(SV("abcdefghij"), S("abcde"), false);
test(SV("abcdefghij"), S("abcdefghij"), true);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghijklmnopqrst"), S(""), false);
test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(SV(""), S(""), true);
test(SV(""), S("abcde"), false);
test(SV(""), S("abcdefghij"), false);
test(SV(""), S("abcdefghijklmnopqrst"), false);
test(SV("abcde"), S(""), false);
test(SV("abcde"), S("abcde"), true);
test(SV("abcde"), S("abcdefghij"), false);
test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghij"), S(""), false);
test(SV("abcdefghij"), S("abcde"), false);
test(SV("abcdefghij"), S("abcdefghij"), true);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghijklmnopqrst"), S(""), false);
test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator>(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const typename S::value_type* lhs, const S& rhs, bool x)
{
assert((lhs > rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test("", S(""), false);
test("", S("abcde"), false);
test("", S("abcdefghij"), false);
test("", S("abcdefghijklmnopqrst"), false);
test("abcde", S(""), true);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), false);
test("abcde", S("abcdefghijklmnopqrst"), false);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test("", S(""), false);
test("", S("abcde"), false);
test("", S("abcdefghij"), false);
test("", S("abcdefghijklmnopqrst"), false);
test("abcde", S(""), true);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), false);
test("abcde", S("abcdefghijklmnopqrst"), false);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator>(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs > rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), "", false);
test(S(""), "abcde", false);
test(S(""), "abcdefghij", false);
test(S(""), "abcdefghijklmnopqrst", false);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", false);
test(S("abcde"), "abcdefghijklmnopqrst", false);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", false);
test(S(""), "abcde", false);
test(S(""), "abcdefghij", false);
test(S(""), "abcdefghijklmnopqrst", false);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", false);
test(S("abcde"), "abcdefghijklmnopqrst", false);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator>(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const S& rhs, bool x)
{
assert((lhs > rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), S(""), false);
test(S(""), S("abcde"), false);
test(S(""), S("abcdefghij"), false);
test(S(""), S("abcdefghijklmnopqrst"), false);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), false);
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""), false);
test(S(""), S("abcde"), false);
test(S(""), S("abcdefghij"), false);
test(S(""), S("abcdefghijklmnopqrst"), false);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), false);
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, SV rhs, bool x)
{
assert((lhs > rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(""), SV(""), false);
test(S(""), SV("abcde"), false);
test(S(""), SV("abcdefghij"), false);
test(S(""), SV("abcdefghijklmnopqrst"), false);
test(S("abcde"), SV(""), true);
test(S("abcde"), SV("abcde"), false);
test(S("abcde"), SV("abcdefghij"), false);
test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), SV(""), true);
test(S("abcdefghij"), SV("abcde"), true);
test(S("abcdefghij"), SV("abcdefghij"), false);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), SV(""), true);
test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string <char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(S(""), SV(""), false);
test(S(""), SV("abcde"), false);
test(S(""), SV("abcdefghij"), false);
test(S(""), SV("abcdefghijklmnopqrst"), false);
test(S("abcde"), SV(""), true);
test(S("abcde"), SV("abcde"), false);
test(S("abcde"), SV("abcdefghij"), false);
test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), SV(""), true);
test(S("abcdefghij"), SV("abcde"), true);
test(S("abcdefghij"), SV("abcdefghij"), false);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), SV(""), true);
test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(SV lhs, const S& rhs, bool x)
{
assert((lhs > rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(SV(""), S(""), false);
test(SV(""), S("abcde"), false);
test(SV(""), S("abcdefghij"), false);
test(SV(""), S("abcdefghijklmnopqrst"), false);
test(SV("abcde"), S(""), true);
test(SV("abcde"), S("abcde"), false);
test(SV("abcde"), S("abcdefghij"), false);
test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghij"), S(""), true);
test(SV("abcdefghij"), S("abcde"), true);
test(SV("abcdefghij"), S("abcdefghij"), false);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghijklmnopqrst"), S(""), true);
test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string <char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(SV(""), S(""), false);
test(SV(""), S("abcde"), false);
test(SV(""), S("abcdefghij"), false);
test(SV(""), S("abcdefghijklmnopqrst"), false);
test(SV("abcde"), S(""), true);
test(SV("abcde"), S("abcde"), false);
test(SV("abcde"), S("abcdefghij"), false);
test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghij"), S(""), true);
test(SV("abcdefghij"), S("abcde"), true);
test(SV("abcdefghij"), S("abcdefghij"), false);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghijklmnopqrst"), S(""), true);
test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator>=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const typename S::value_type* lhs, const S& rhs, bool x)
{
assert((lhs >= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test("", S(""), true);
test("", S("abcde"), false);
test("", S("abcdefghij"), false);
test("", S("abcdefghijklmnopqrst"), false);
test("abcde", S(""), true);
test("abcde", S("abcde"), true);
test("abcde", S("abcdefghij"), false);
test("abcde", S("abcdefghijklmnopqrst"), false);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), true);
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test("", S(""), true);
test("", S("abcde"), false);
test("", S("abcdefghij"), false);
test("", S("abcdefghijklmnopqrst"), false);
test("abcde", S(""), true);
test("abcde", S("abcde"), true);
test("abcde", S("abcdefghij"), false);
test("abcde", S("abcdefghijklmnopqrst"), false);
test("abcdefghij", S(""), true);
test("abcdefghij", S("abcde"), true);
test("abcdefghij", S("abcdefghij"), true);
test("abcdefghij", S("abcdefghijklmnopqrst"), false);
test("abcdefghijklmnopqrst", S(""), true);
test("abcdefghijklmnopqrst", S("abcde"), true);
test("abcdefghijklmnopqrst", S("abcdefghij"), true);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs >= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), "", true);
test(S(""), "abcde", false);
test(S(""), "abcdefghij", false);
test(S(""), "abcdefghijklmnopqrst", false);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", true);
test(S("abcde"), "abcdefghij", false);
test(S("abcde"), "abcdefghijklmnopqrst", false);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", true);
test(S(""), "abcde", false);
test(S(""), "abcdefghij", false);
test(S(""), "abcdefghijklmnopqrst", false);
test(S("abcde"), "", true);
test(S("abcde"), "abcde", true);
test(S("abcde"), "abcdefghij", false);
test(S("abcde"), "abcdefghijklmnopqrst", false);
test(S("abcdefghij"), "", true);
test(S("abcdefghij"), "abcde", true);
test(S("abcdefghij"), "abcdefghij", true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
test(S("abcdefghijklmnopqrst"), "", true);
test(S("abcdefghijklmnopqrst"), "abcde", true);
test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const S& rhs, bool x)
{
assert((lhs >= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), S(""), true);
test(S(""), S("abcde"), false);
test(S(""), S("abcdefghij"), false);
test(S(""), S("abcdefghijklmnopqrst"), false);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), true);
test(S("abcde"), S("abcdefghij"), false);
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""), true);
test(S(""), S("abcde"), false);
test(S(""), S("abcdefghij"), false);
test(S(""), S("abcdefghijklmnopqrst"), false);
test(S("abcde"), S(""), true);
test(S("abcde"), S("abcde"), true);
test(S("abcde"), S("abcdefghij"), false);
test(S("abcde"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), S(""), true);
test(S("abcdefghij"), S("abcde"), true);
test(S("abcdefghij"), S("abcdefghij"), true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), S(""), true);
test(S("abcdefghijklmnopqrst"), S("abcde"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, SV rhs, bool x)
{
assert((lhs >= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(""), SV(""), true);
test(S(""), SV("abcde"), false);
test(S(""), SV("abcdefghij"), false);
test(S(""), SV("abcdefghijklmnopqrst"), false);
test(S("abcde"), SV(""), true);
test(S("abcde"), SV("abcde"), true);
test(S("abcde"), SV("abcdefghij"), false);
test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), SV(""), true);
test(S("abcdefghij"), SV("abcde"), true);
test(S("abcdefghij"), SV("abcdefghij"), true);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), SV(""), true);
test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(S(""), SV(""), true);
test(S(""), SV("abcde"), false);
test(S(""), SV("abcdefghij"), false);
test(S(""), SV("abcdefghijklmnopqrst"), false);
test(S("abcde"), SV(""), true);
test(S("abcde"), SV("abcde"), true);
test(S("abcde"), SV("abcdefghij"), false);
test(S("abcde"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghij"), SV(""), true);
test(S("abcdefghij"), SV("abcde"), true);
test(S("abcdefghij"), SV("abcdefghij"), true);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), false);
test(S("abcdefghijklmnopqrst"), SV(""), true);
test(S("abcdefghijklmnopqrst"), SV("abcde"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), true);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(SV lhs, const S& rhs, bool x)
{
assert((lhs >= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(SV(""), S(""), true);
test(SV(""), S("abcde"), false);
test(SV(""), S("abcdefghij"), false);
test(SV(""), S("abcdefghijklmnopqrst"), false);
test(SV("abcde"), S(""), true);
test(SV("abcde"), S("abcde"), true);
test(SV("abcde"), S("abcdefghij"), false);
test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghij"), S(""), true);
test(SV("abcdefghij"), S("abcde"), true);
test(SV("abcdefghij"), S("abcdefghij"), true);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghijklmnopqrst"), S(""), true);
test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(SV(""), S(""), true);
test(SV(""), S("abcde"), false);
test(SV(""), S("abcdefghij"), false);
test(SV(""), S("abcdefghijklmnopqrst"), false);
test(SV("abcde"), S(""), true);
test(SV("abcde"), S("abcde"), true);
test(SV("abcde"), S("abcdefghij"), false);
test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghij"), S(""), true);
test(SV("abcdefghij"), S("abcde"), true);
test(SV("abcdefghij"), S("abcdefghij"), true);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
test(SV("abcdefghijklmnopqrst"), S(""), true);
test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator<(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const typename S::value_type* lhs, const S& rhs, bool x)
{
assert((lhs < rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test("", S(""), false);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), false);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), false);
test("abcdefghij", S("abcde"), false);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), false);
test("abcdefghijklmnopqrst", S("abcde"), false);
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test("", S(""), false);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), false);
test("abcde", S("abcde"), false);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), false);
test("abcdefghij", S("abcde"), false);
test("abcdefghij", S("abcdefghij"), false);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), false);
test("abcdefghijklmnopqrst", S("abcde"), false);
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator<(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs < rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), "", false);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", false);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", false);
test(S("abcdefghij"), "abcde", false);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", false);
test(S("abcdefghijklmnopqrst"), "abcde", false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", false);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", false);
test(S("abcde"), "abcde", false);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", false);
test(S("abcdefghij"), "abcde", false);
test(S("abcdefghij"), "abcdefghij", false);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", false);
test(S("abcdefghijklmnopqrst"), "abcde", false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator<(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const S& rhs, bool x)
{
assert((lhs < rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), S(""), false);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), false);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), false);
test(S("abcdefghij"), S("abcde"), false);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), false);
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""), false);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), false);
test(S("abcde"), S("abcde"), false);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), false);
test(S("abcdefghij"), S("abcde"), false);
test(S("abcdefghij"), S("abcdefghij"), false);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), false);
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, SV rhs, bool x)
{
assert((lhs < rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(""), SV(""), false);
test(S(""), SV("abcde"), true);
test(S(""), SV("abcdefghij"), true);
test(S(""), SV("abcdefghijklmnopqrst"), true);
test(S("abcde"), SV(""), false);
test(S("abcde"), SV("abcde"), false);
test(S("abcde"), SV("abcdefghij"), true);
test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), SV(""), false);
test(S("abcdefghij"), SV("abcde"), false);
test(S("abcdefghij"), SV("abcdefghij"), false);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), SV(""), false);
test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(S(""), SV(""), false);
test(S(""), SV("abcde"), true);
test(S(""), SV("abcdefghij"), true);
test(S(""), SV("abcdefghijklmnopqrst"), true);
test(S("abcde"), SV(""), false);
test(S("abcde"), SV("abcde"), false);
test(S("abcde"), SV("abcdefghij"), true);
test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), SV(""), false);
test(S("abcdefghij"), SV("abcde"), false);
test(S("abcdefghij"), SV("abcdefghij"), false);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), SV(""), false);
test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(SV lhs, const S& rhs, bool x)
{
assert((lhs < rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(SV(""), S(""), false);
test(SV(""), S("abcde"), true);
test(SV(""), S("abcdefghij"), true);
test(SV(""), S("abcdefghijklmnopqrst"), true);
test(SV("abcde"), S(""), false);
test(SV("abcde"), S("abcde"), false);
test(SV("abcde"), S("abcdefghij"), true);
test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghij"), S(""), false);
test(SV("abcdefghij"), S("abcde"), false);
test(SV("abcdefghij"), S("abcdefghij"), false);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghijklmnopqrst"), S(""), false);
test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(SV(""), S(""), false);
test(SV(""), S("abcde"), true);
test(SV(""), S("abcdefghij"), true);
test(SV(""), S("abcdefghijklmnopqrst"), true);
test(SV("abcde"), S(""), false);
test(SV("abcde"), S("abcde"), false);
test(SV("abcde"), S("abcdefghij"), true);
test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghij"), S(""), false);
test(SV("abcdefghij"), S("abcde"), false);
test(SV("abcdefghij"), S("abcdefghij"), false);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghijklmnopqrst"), S(""), false);
test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator<=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const typename S::value_type* lhs, const S& rhs, bool x)
{
assert((lhs <= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test("", S(""), true);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), false);
test("abcde", S("abcde"), true);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), false);
test("abcdefghij", S("abcde"), false);
test("abcdefghij", S("abcdefghij"), true);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), false);
test("abcdefghijklmnopqrst", S("abcde"), false);
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test("", S(""), true);
test("", S("abcde"), true);
test("", S("abcdefghij"), true);
test("", S("abcdefghijklmnopqrst"), true);
test("abcde", S(""), false);
test("abcde", S("abcde"), true);
test("abcde", S("abcdefghij"), true);
test("abcde", S("abcdefghijklmnopqrst"), true);
test("abcdefghij", S(""), false);
test("abcdefghij", S("abcde"), false);
test("abcdefghij", S("abcdefghij"), true);
test("abcdefghij", S("abcdefghijklmnopqrst"), true);
test("abcdefghijklmnopqrst", S(""), false);
test("abcdefghijklmnopqrst", S("abcde"), false);
test("abcdefghijklmnopqrst", S("abcdefghij"), false);
test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const typename S::value_type* rhs, bool x)
{
assert((lhs <= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), "", true);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", false);
test(S("abcde"), "abcde", true);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", false);
test(S("abcdefghij"), "abcde", false);
test(S("abcdefghij"), "abcdefghij", true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", false);
test(S("abcdefghijklmnopqrst"), "abcde", false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), "", true);
test(S(""), "abcde", true);
test(S(""), "abcdefghij", true);
test(S(""), "abcdefghijklmnopqrst", true);
test(S("abcde"), "", false);
test(S("abcde"), "abcde", true);
test(S("abcde"), "abcdefghij", true);
test(S("abcde"), "abcdefghijklmnopqrst", true);
test(S("abcdefghij"), "", false);
test(S("abcdefghij"), "abcde", false);
test(S("abcdefghij"), "abcdefghij", true);
test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
test(S("abcdefghijklmnopqrst"), "", false);
test(S("abcdefghijklmnopqrst"), "abcde", false);
test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// template<class charT, class traits, class Allocator>
// bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
// const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, const S& rhs, bool x)
{
assert((lhs <= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
test(S(""), S(""), true);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), false);
test(S("abcde"), S("abcde"), true);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), false);
test(S("abcdefghij"), S("abcde"), false);
test(S("abcdefghij"), S("abcdefghij"), true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), false);
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test(S(""), S(""), true);
test(S(""), S("abcde"), true);
test(S(""), S("abcdefghij"), true);
test(S(""), S("abcdefghijklmnopqrst"), true);
test(S("abcde"), S(""), false);
test(S("abcde"), S("abcde"), true);
test(S("abcde"), S("abcdefghij"), true);
test(S("abcde"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), S(""), false);
test(S("abcdefghij"), S("abcde"), false);
test(S("abcdefghij"), S("abcdefghij"), true);
test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), S(""), false);
test(S("abcdefghijklmnopqrst"), S("abcde"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(const S& lhs, SV rhs, bool x)
{
assert((lhs <= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(S(""), SV(""), true);
test(S(""), SV("abcde"), true);
test(S(""), SV("abcdefghij"), true);
test(S(""), SV("abcdefghijklmnopqrst"), true);
test(S("abcde"), SV(""), false);
test(S("abcde"), SV("abcde"), true);
test(S("abcde"), SV("abcdefghij"), true);
test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), SV(""), false);
test(S("abcdefghij"), SV("abcde"), false);
test(S("abcdefghij"), SV("abcdefghij"), true);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), SV(""), false);
test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(S(""), SV(""), true);
test(S(""), SV("abcde"), true);
test(S(""), SV("abcdefghij"), true);
test(S(""), SV("abcdefghijklmnopqrst"), true);
test(S("abcde"), SV(""), false);
test(S("abcde"), SV("abcde"), true);
test(S("abcde"), SV("abcdefghij"), true);
test(S("abcde"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghij"), SV(""), false);
test(S("abcdefghij"), SV("abcde"), false);
test(S("abcdefghij"), SV("abcdefghij"), true);
test(S("abcdefghij"), SV("abcdefghijklmnopqrst"), true);
test(S("abcdefghijklmnopqrst"), SV(""), false);
test(S("abcdefghijklmnopqrst"), SV("abcde"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghij"), false);
test(S("abcdefghijklmnopqrst"), SV("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// we get this comparison "for free" because the string implicitly converts to the string_view
#include <string>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S, class SV>
TEST_CONSTEXPR_CXX20 void
test(SV lhs, const S& rhs, bool x)
{
assert((lhs <= rhs) == x);
}
TEST_CONSTEXPR_CXX20 bool test() {
{
typedef std::string S;
typedef std::string_view SV;
test(SV(""), S(""), true);
test(SV(""), S("abcde"), true);
test(SV(""), S("abcdefghij"), true);
test(SV(""), S("abcdefghijklmnopqrst"), true);
test(SV("abcde"), S(""), false);
test(SV("abcde"), S("abcde"), true);
test(SV("abcde"), S("abcdefghij"), true);
test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghij"), S(""), false);
test(SV("abcdefghij"), S("abcde"), false);
test(SV("abcdefghij"), S("abcdefghij"), true);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghijklmnopqrst"), S(""), false);
test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
typedef std::basic_string_view<char, std::char_traits<char>> SV;
test(SV(""), S(""), true);
test(SV(""), S("abcde"), true);
test(SV(""), S("abcdefghij"), true);
test(SV(""), S("abcdefghijklmnopqrst"), true);
test(SV("abcde"), S(""), false);
test(SV("abcde"), S("abcde"), true);
test(SV("abcde"), S("abcdefghij"), true);
test(SV("abcde"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghij"), S(""), false);
test(SV("abcdefghij"), S("abcde"), false);
test(SV("abcdefghij"), S("abcdefghij"), true);
test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), true);
test(SV("abcdefghijklmnopqrst"), S(""), false);
test(SV("abcdefghijklmnopqrst"), S("abcde"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), false);
test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
}
#endif
return true;
}
int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}