[libc++] Prepare string.{access, capacity, cons} tests for constexpr
Reviewed By: ldionne, #libc Spies: libcxx-commits, arphaman Differential Revision: https://reviews.llvm.org/D119123
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(SV sv, std::size_t pos, std::size_t n)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
@@ -59,7 +59,7 @@ test(SV sv, std::size_t pos, std::size_t n)
|
||||
}
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& a)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
@@ -91,10 +91,8 @@ test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& a)
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
typedef std::basic_string <char, std::char_traits<char>, A> S;
|
||||
@@ -122,10 +120,10 @@ int main(int, char**)
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, A(8));
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, A(8));
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, A(8));
|
||||
}
|
||||
}
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
typedef std::basic_string <char, std::char_traits<char>, A> S;
|
||||
@@ -153,9 +151,9 @@ int main(int, char**)
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, A());
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, A());
|
||||
test<S,SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, A());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
S s = "ABCD";
|
||||
@@ -182,7 +180,17 @@ int main(int, char**)
|
||||
|
||||
S s7(s.data(), 2); // calls ctor(const char *, len)
|
||||
assert(s7 == "AB");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test()
|
||||
{
|
||||
{
|
||||
@@ -52,7 +52,7 @@ test()
|
||||
#if TEST_STD_VER >= 11
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test2()
|
||||
{
|
||||
{
|
||||
@@ -85,12 +85,21 @@ test2()
|
||||
|
||||
#endif
|
||||
|
||||
bool test() {
|
||||
test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
|
||||
#if TEST_STD_VER >= 11
|
||||
test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
|
||||
test2<std::basic_string<char, std::char_traits<char>, explicit_allocator<char> > >();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
|
||||
#if TEST_STD_VER >= 11
|
||||
test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
|
||||
test2<std::basic_string<char, std::char_traits<char>, explicit_allocator<char> > >();
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
bool test() {
|
||||
// Test that assignment from {} and {ptr, len} are allowed and are not
|
||||
// ambiguous.
|
||||
{
|
||||
@@ -33,5 +32,15 @@ int main(int, char**)
|
||||
assert(s == "ab");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,23 +28,32 @@ test(S s1, typename S::value_type s2)
|
||||
assert(s1.capacity() >= s1.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), 'a');
|
||||
test(S("1"), 'a');
|
||||
test(S("123456789"), 'a');
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), 'a');
|
||||
test(S("1"), 'a');
|
||||
test(S("123456789"), 'a');
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -28,23 +28,32 @@ test(S s1)
|
||||
assert(s2.get_allocator() == s1.get_allocator());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
test(S(A(3)));
|
||||
test(S("1", A(5)));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
test(S(A{}));
|
||||
test(S("1", A()));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -88,26 +88,25 @@ test(S s1, const typename S::allocator_type& a)
|
||||
assert(s2.get_allocator() == a);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
test(S(), A(3));
|
||||
test(S("1"), A(5));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
test(S(), A());
|
||||
test(S("1"), A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
{
|
||||
{
|
||||
typedef poca_alloc<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
const char * p1 = "This is my first string";
|
||||
@@ -125,9 +124,19 @@ int main(int, char**)
|
||||
test_assign(s1, s2);
|
||||
assert(s1 == p1);
|
||||
assert(s2 == p2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s1, const S& s2)
|
||||
{
|
||||
s1 = s2;
|
||||
@@ -27,9 +27,8 @@ test(S s1, const S& s2)
|
||||
assert(s1.capacity() >= s1.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), S());
|
||||
test(S("1"), S());
|
||||
@@ -46,9 +45,9 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), S());
|
||||
test(S("1"), S());
|
||||
@@ -65,16 +64,26 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 3
|
||||
{ // LWG 2946
|
||||
{ // LWG 2946
|
||||
std::string s;
|
||||
s = {"abc", 1};
|
||||
assert(s.size() == 1);
|
||||
assert(s == "a");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -45,8 +45,8 @@ using BStr = std::basic_string<T, std::char_traits<T>, Alloc>;
|
||||
// (13) basic_string(initializer_list<CharT>, A const& = A())
|
||||
// (14) basic_string(BSV, A const& = A())
|
||||
// (15) basic_string(const T&, size_type, size_type, A const& = A())
|
||||
int main(int, char**)
|
||||
{
|
||||
bool test() {
|
||||
|
||||
using TestSizeT = test_allocator<char>::size_type;
|
||||
{ // Testing (1)
|
||||
// Nothing to do. Cannot deduce without any arguments.
|
||||
@@ -365,5 +365,15 @@ int main(int, char**)
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -19,31 +19,40 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
bool test() {
|
||||
{
|
||||
std::string s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
{
|
||||
std::wstring s;
|
||||
s = {L'a', L'b', L'c'};
|
||||
assert(s == L"abc");
|
||||
}
|
||||
#endif
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s = {'a', 'b', 'c'};
|
||||
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;
|
||||
s = {L'a', L'b', L'c'};
|
||||
assert(s == L"abc");
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
std::string s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
{
|
||||
std::wstring s;
|
||||
s = {L'a', L'b', L'c'};
|
||||
assert(s == L"abc");
|
||||
}
|
||||
#endif
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s = {'a', 'b', 'c'};
|
||||
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;
|
||||
s = {L'a', L'b', L'c'};
|
||||
assert(s == L"abc");
|
||||
}
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -18,19 +18,28 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
bool test() {
|
||||
{
|
||||
std::string s;
|
||||
s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s;
|
||||
s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
std::string s;
|
||||
s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s;
|
||||
s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class It>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(It first, It last)
|
||||
{
|
||||
typedef typename std::iterator_traits<It>::value_type charT;
|
||||
@@ -41,7 +41,7 @@ test(It first, It last)
|
||||
}
|
||||
|
||||
template <class It, class A>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(It first, It last, const A& a)
|
||||
{
|
||||
typedef typename std::iterator_traits<It>::value_type charT;
|
||||
@@ -56,9 +56,8 @@ test(It first, It last, const A& a)
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
const char* s = "12345678901234567890123456789012345678901234567890";
|
||||
|
||||
@@ -85,9 +84,9 @@ int main(int, char**)
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+50));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+50), A(2));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
const char* s = "12345678901234567890123456789012345678901234567890";
|
||||
|
||||
@@ -114,9 +113,9 @@ int main(int, char**)
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+50));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s+50), A());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
{
|
||||
static_assert((!std::is_constructible<std::string, std::string,
|
||||
std::string>::value),
|
||||
"");
|
||||
@@ -124,7 +123,17 @@ int main(int, char**)
|
||||
(!std::is_constructible<std::string, std::string, std::string,
|
||||
std::allocator<char> >::value),
|
||||
"");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,8 @@
|
||||
#include "../cpp17_input_iterator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
const char* s = "12345678901234";
|
||||
std::basic_string s1(s, s+10); // Can't use {} here
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -45,9 +44,8 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, std::allocator<char>>, "");
|
||||
assert(s1.size() == 10);
|
||||
assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
}
|
||||
{
|
||||
const char* s = "12345678901234";
|
||||
std::basic_string s1{s, s+10, std::allocator<char>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -56,8 +54,8 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, std::allocator<char>>, "");
|
||||
assert(s1.size() == 10);
|
||||
assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
|
||||
}
|
||||
{
|
||||
}
|
||||
{
|
||||
const wchar_t* s = L"12345678901234";
|
||||
std::basic_string s1{s, s+10, test_allocator<wchar_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -66,8 +64,8 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, test_allocator<wchar_t>>, "");
|
||||
assert(s1.size() == 10);
|
||||
assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
|
||||
}
|
||||
{
|
||||
}
|
||||
{
|
||||
const char16_t* s = u"12345678901234";
|
||||
std::basic_string s1{s, s+10, min_allocator<char16_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -76,8 +74,8 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, min_allocator<char16_t>>, "");
|
||||
assert(s1.size() == 10);
|
||||
assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
|
||||
}
|
||||
{
|
||||
}
|
||||
{
|
||||
const char32_t* s = U"12345678901234";
|
||||
std::basic_string s1{s, s+10, explicit_allocator<char32_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -86,7 +84,13 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, explicit_allocator<char32_t>>, "");
|
||||
assert(s1.size() == 10);
|
||||
assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s0)
|
||||
{
|
||||
S s1 = s0;
|
||||
@@ -32,22 +32,31 @@ test(S s0)
|
||||
assert(s2.get_allocator() == s1.get_allocator());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
test(S(A(3)));
|
||||
test(S("1", A(5)));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
|
||||
}
|
||||
{
|
||||
}
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
test(S(A{}));
|
||||
test(S("1", A()));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s0, const typename S::allocator_type& a)
|
||||
{
|
||||
S s1 = s0;
|
||||
@@ -32,10 +32,9 @@ test(S s0, const typename S::allocator_type& a)
|
||||
assert(s2.get_allocator() == a);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test_allocator_statistics alloc_stats;
|
||||
{
|
||||
bool test() {
|
||||
test_allocator_statistics alloc_stats;
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
#if TEST_STD_VER > 14
|
||||
@@ -46,10 +45,10 @@ int main(int, char**)
|
||||
test(S(), A(3, &alloc_stats));
|
||||
test(S("1"), A(5, &alloc_stats));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7, &alloc_stats));
|
||||
}
|
||||
}
|
||||
|
||||
int alloc_count = alloc_stats.alloc_count;
|
||||
{
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
#if TEST_STD_VER > 14
|
||||
@@ -59,9 +58,9 @@ int main(int, char**)
|
||||
#endif
|
||||
S s1 ( "Twas brillig, and the slivy toves did gyre and gymbal in the wabe", A(&alloc_stats));
|
||||
S s2 (std::move(s1), A(1, &alloc_stats));
|
||||
}
|
||||
}
|
||||
assert ( alloc_stats.alloc_count == alloc_count );
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
#if TEST_STD_VER > 14
|
||||
@@ -72,7 +71,17 @@ int main(int, char**)
|
||||
test(S(), A());
|
||||
test(S("1"), A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -62,36 +62,45 @@ struct some_alloc3
|
||||
typedef std::false_type is_always_equal;
|
||||
};
|
||||
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string C;
|
||||
static_assert(std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
|
||||
#if TEST_STD_VER > 14
|
||||
// if the allocators are always equal, then the move assignment can be noexcept
|
||||
static_assert( std::is_nothrow_move_assignable<C>::value, "");
|
||||
#else
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
#endif
|
||||
}
|
||||
#if TEST_STD_VER > 14
|
||||
{
|
||||
// POCMA is false, always equal
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc2<char>> C;
|
||||
static_assert( std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
// POCMA is false, not always equal
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc3<char>> C;
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
typedef std::string C;
|
||||
static_assert(std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
|
||||
#if TEST_STD_VER > 14
|
||||
// if the allocators are always equal, then the move assignment can be noexcept
|
||||
static_assert( std::is_nothrow_move_assignable<C>::value, "");
|
||||
#else
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
#endif
|
||||
}
|
||||
#if TEST_STD_VER > 14
|
||||
{
|
||||
// POCMA is false, always equal
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc2<char>> C;
|
||||
static_assert( std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
{
|
||||
// POCMA is false, not always equal
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc3<char>> C;
|
||||
static_assert(!std::is_nothrow_move_assignable<C>::value, "");
|
||||
}
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s1, S s2)
|
||||
{
|
||||
S s0 = s2;
|
||||
@@ -32,9 +32,8 @@ test(S s1, S s2)
|
||||
assert(s1.capacity() >= s1.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), S());
|
||||
test(S("1"), S());
|
||||
@@ -51,8 +50,8 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
{
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), S());
|
||||
test(S("1"), S());
|
||||
@@ -69,7 +68,17 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class charT>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(const charT* s)
|
||||
{
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
@@ -37,7 +37,7 @@ test(const charT* s)
|
||||
}
|
||||
|
||||
template <class charT, class A>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(const charT* s, const A& a)
|
||||
{
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
@@ -51,8 +51,7 @@ test(const charT* s, const A& a)
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
|
||||
@@ -86,5 +85,15 @@ int main(int, char**)
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s1, const typename S::value_type* s2)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
@@ -29,9 +29,8 @@ test(S s1, const typename S::value_type* s2)
|
||||
assert(s1.capacity() >= s1.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), "");
|
||||
test(S("1"), "");
|
||||
@@ -48,9 +47,9 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), "");
|
||||
test(S("1"), "");
|
||||
@@ -67,7 +66,17 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class charT>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(const charT* s, unsigned n)
|
||||
{
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
@@ -35,7 +35,7 @@ test(const charT* s, unsigned n)
|
||||
}
|
||||
|
||||
template <class charT, class A>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(const charT* s, unsigned n, const A& a)
|
||||
{
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
@@ -48,9 +48,8 @@ test(const charT* s, unsigned n, const A& a)
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
|
||||
test("", 0);
|
||||
@@ -64,9 +63,9 @@ int main(int, char**)
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
|
||||
test("", 0);
|
||||
@@ -80,15 +79,25 @@ int main(int, char**)
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60, A());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 3
|
||||
{ // LWG 2946
|
||||
{ // LWG 2946
|
||||
std::string s({"abc", 1});
|
||||
assert(s.size() == 1);
|
||||
assert(s == "a");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class charT>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(unsigned n, charT c)
|
||||
{
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
@@ -36,7 +36,7 @@ test(unsigned n, charT c)
|
||||
}
|
||||
|
||||
template <class charT, class A>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(unsigned n, charT c, const A& a)
|
||||
{
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
@@ -66,7 +66,7 @@ test(Tp n, Tp c)
|
||||
}
|
||||
|
||||
template <class Tp, class A>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(Tp n, Tp c, const A& a)
|
||||
{
|
||||
typedef char charT;
|
||||
@@ -80,9 +80,8 @@ test(Tp n, Tp c, const A& a)
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
|
||||
test(0, 'a');
|
||||
@@ -99,9 +98,9 @@ int main(int, char**)
|
||||
|
||||
test(static_cast<char>(100), static_cast<char>(65));
|
||||
test(static_cast<char>(100), static_cast<char>(65), A(3));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
|
||||
test(0, 'a');
|
||||
@@ -118,7 +117,17 @@ int main(int, char**)
|
||||
|
||||
test(static_cast<char>(100), static_cast<char>(65));
|
||||
test(static_cast<char>(100), static_cast<char>(65), A());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -71,9 +71,8 @@ test(std::basic_string_view<charT> sv, const A& a)
|
||||
}
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
|
||||
@@ -88,9 +87,9 @@ int main(int, char**)
|
||||
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"));
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"), A(2));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
|
||||
@@ -105,7 +104,17 @@ int main(int, char**)
|
||||
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"));
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"), A());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S, class SV>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S s1, SV sv)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
@@ -28,9 +28,8 @@ test(S s1, SV sv)
|
||||
assert(s1.capacity() >= s1.size());
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
test(S(), SV(""));
|
||||
@@ -48,9 +47,9 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
typedef std::string_view SV;
|
||||
test(S(), SV(""));
|
||||
@@ -68,7 +67,17 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
SV("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -36,9 +36,8 @@
|
||||
#include "../cpp17_input_iterator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
std::string_view sv = "12345678901234";
|
||||
std::basic_string s1(sv);
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -47,9 +46,9 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, std::allocator<char>>, "");
|
||||
assert(s1.size() == sv.size());
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
std::string_view sv = "12345678901234";
|
||||
std::basic_string s1{sv, std::allocator<char>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -58,9 +57,9 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, std::allocator<char>>, "");
|
||||
assert(s1.size() == sv.size());
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
{
|
||||
{
|
||||
std::wstring_view sv = L"12345678901234";
|
||||
std::basic_string s1{sv, test_allocator<wchar_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -69,10 +68,10 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, test_allocator<wchar_t>>, "");
|
||||
assert(s1.size() == sv.size());
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
|
||||
{
|
||||
{
|
||||
std::u8string_view sv = u8"12345678901234";
|
||||
std::basic_string s1{sv, min_allocator<char8_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -81,9 +80,9 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, min_allocator<char8_t>>, "");
|
||||
assert(s1.size() == sv.size());
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
{
|
||||
std::u16string_view sv = u"12345678901234";
|
||||
std::basic_string s1{sv, min_allocator<char16_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -92,8 +91,8 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, min_allocator<char16_t>>, "");
|
||||
assert(s1.size() == sv.size());
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
{
|
||||
}
|
||||
{
|
||||
std::u32string_view sv = U"12345678901234";
|
||||
std::basic_string s1{sv, explicit_allocator<char32_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -102,7 +101,17 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, explicit_allocator<char32_t>>, "");
|
||||
assert(s1.size() == sv.size());
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,8 @@
|
||||
#include "../cpp17_input_iterator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
std::string_view sv = "12345678901234";
|
||||
std::basic_string s1{sv, 0, 4};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -51,9 +50,9 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, std::allocator<char>>, "");
|
||||
assert(s1.size() == 4);
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
std::string_view sv = "12345678901234";
|
||||
std::basic_string s1{sv, 0, 4, std::allocator<char>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -62,9 +61,9 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, std::allocator<char>>, "");
|
||||
assert(s1.size() == 4);
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
{
|
||||
{
|
||||
std::wstring_view sv = L"12345678901234";
|
||||
std::basic_string s1{sv, 0, 4, test_allocator<wchar_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -73,10 +72,10 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, test_allocator<wchar_t>>, "");
|
||||
assert(s1.size() == 4);
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
|
||||
{
|
||||
{
|
||||
std::u8string_view sv = u8"12345678901234";
|
||||
std::basic_string s1{sv, 0, 4, min_allocator<char8_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -85,9 +84,9 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, min_allocator<char8_t>>, "");
|
||||
assert(s1.size() == 4);
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
{
|
||||
std::u16string_view sv = u"12345678901234";
|
||||
std::basic_string s1{sv, 0, 4, min_allocator<char16_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -96,8 +95,8 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, min_allocator<char16_t>>, "");
|
||||
assert(s1.size() == 4);
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
{
|
||||
}
|
||||
{
|
||||
std::u32string_view sv = U"12345678901234";
|
||||
std::basic_string s1{sv, 0, 4, explicit_allocator<char32_t>{}};
|
||||
using S = decltype(s1); // what type did we get?
|
||||
@@ -106,7 +105,17 @@ int main(int, char**)
|
||||
static_assert(std::is_same_v<S::allocator_type, explicit_allocator<char32_t>>, "");
|
||||
assert(s1.size() == 4);
|
||||
assert(s1.compare(0, s1.size(), sv.data(), s1.size()) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S str, unsigned pos)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
@@ -61,7 +61,7 @@ test(S str, unsigned pos)
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S str, unsigned pos, unsigned n)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
@@ -93,7 +93,7 @@ test(S str, unsigned pos, unsigned n)
|
||||
}
|
||||
|
||||
template <class S>
|
||||
void
|
||||
TEST_CONSTEXPR_CXX20 void
|
||||
test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
@@ -140,9 +140,8 @@ void test2583()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
{
|
||||
bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -179,9 +178,9 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1, A(8));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));
|
||||
}
|
||||
}
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -218,12 +217,22 @@ int main(int, char**)
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1, A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
test2583();
|
||||
test2583();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
test();
|
||||
#if TEST_STD_VER > 17
|
||||
// static_assert(test());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user