[libc++] Refactor string unit tests to ease addition of new allocators
While doing this, I also found a few tests that were either clearly incorrect (e.g. testing the wrong function) or that lacked basic test coverage like testing std::string itself (e.g. the test was only checking std::basic_string with a custom allocator). In these cases, I did a few conservative drive-by changes. Differential Revision: https://reviews.llvm.org/D140550 Co-authored-by: Brendan Emery <brendan.emery@esrlabs.com>
This commit is contained in:
@@ -77,68 +77,44 @@ TEST_CONSTEXPR_CXX20 void test(SV sv, std::size_t pos, std::size_t n, const type
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
typedef std::basic_string<char, std::char_traits<char>, Alloc> S;
|
||||
|
||||
test<S, SV>(SV(), 0, 0);
|
||||
test<S, SV>(SV(), 0, 1);
|
||||
test<S, SV>(SV(), 1, 0);
|
||||
test<S, SV>(SV(), 1, 1);
|
||||
test<S, SV>(SV(), 1, 2);
|
||||
test<S, SV>(SV("1"), 0, 0);
|
||||
test<S, SV>(SV("1"), 0, 1);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
|
||||
|
||||
test<S, SV>(SV(), 0, 0, Alloc(a));
|
||||
test<S, SV>(SV(), 0, 1, Alloc(a));
|
||||
test<S, SV>(SV(), 1, 0, Alloc(a));
|
||||
test<S, SV>(SV(), 1, 1, Alloc(a));
|
||||
test<S, SV>(SV(), 1, 2, Alloc(a));
|
||||
test<S, SV>(SV("1"), 0, 0, Alloc(a));
|
||||
test<S, SV>(SV("1"), 0, 1, Alloc(a));
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, Alloc(a));
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, Alloc(a));
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, Alloc(a));
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, Alloc(a));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 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;
|
||||
|
||||
test<S, SV>(SV(), 0, 0);
|
||||
test<S, SV>(SV(), 0, 1);
|
||||
test<S, SV>(SV(), 1, 0);
|
||||
test<S, SV>(SV(), 1, 1);
|
||||
test<S, SV>(SV(), 1, 2);
|
||||
test<S, SV>(SV("1"), 0, 0);
|
||||
test<S, SV>(SV("1"), 0, 1);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
|
||||
|
||||
test<S, SV>(SV(), 0, 0, A(4));
|
||||
test<S, SV>(SV(), 0, 1, A(4));
|
||||
test<S, SV>(SV(), 1, 0, A(4));
|
||||
test<S, SV>(SV(), 1, 1, A(4));
|
||||
test<S, SV>(SV(), 1, 2, A(4));
|
||||
test<S, SV>(SV("1"), 0, 0, A(6));
|
||||
test<S, SV>(SV("1"), 0, 1, A(6));
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, A(8));
|
||||
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));
|
||||
}
|
||||
|
||||
test_string(std::allocator<char>());
|
||||
test_string(test_allocator<char>());
|
||||
test_string(test_allocator<char>(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;
|
||||
|
||||
test<S, SV>(SV(), 0, 0);
|
||||
test<S, SV>(SV(), 0, 1);
|
||||
test<S, SV>(SV(), 1, 0);
|
||||
test<S, SV>(SV(), 1, 1);
|
||||
test<S, SV>(SV(), 1, 2);
|
||||
test<S, SV>(SV("1"), 0, 0);
|
||||
test<S, SV>(SV("1"), 0, 1);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10);
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100);
|
||||
|
||||
test<S, SV>(SV(), 0, 0, A());
|
||||
test<S, SV>(SV(), 0, 1, A());
|
||||
test<S, SV>(SV(), 1, 0, A());
|
||||
test<S, SV>(SV(), 1, 1, A());
|
||||
test<S, SV>(SV(), 1, 2, A());
|
||||
test<S, SV>(SV("1"), 0, 0, A());
|
||||
test<S, SV>(SV("1"), 0, 1, A());
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 0, A());
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 1, A());
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 10, A());
|
||||
test<S, SV>(SV("1234567890123456789012345678901234567890123456789012345678901234567890"), 50, 100, A());
|
||||
}
|
||||
test_string(min_allocator<char>());
|
||||
#endif
|
||||
|
||||
{
|
||||
typedef std::string S;
|
||||
typedef std::string_view SV;
|
||||
|
||||
@@ -26,22 +26,20 @@ TEST_CONSTEXPR_CXX20 void test(S s1) {
|
||||
assert(s2.get_allocator() == s1.get_allocator());
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
|
||||
typedef std::basic_string<char, std::char_traits<char>, Alloc> S;
|
||||
test(S(Alloc(a)));
|
||||
test(S("1", Alloc(a)));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a)));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 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)));
|
||||
}
|
||||
test_string(std::allocator<char>());
|
||||
test_string(test_allocator<char>());
|
||||
test_string(test_allocator<char>(3));
|
||||
#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()));
|
||||
}
|
||||
test_string(min_allocator<char>());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
@@ -85,23 +85,23 @@ TEST_CONSTEXPR_CXX20 void test(S s1, const typename S::allocator_type& a) {
|
||||
assert(s2.get_allocator() == a);
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 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());
|
||||
}
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
|
||||
typedef std::basic_string<char, std::char_traits<char>, Alloc> S;
|
||||
test(S(), Alloc(a));
|
||||
test(S("1"), Alloc(a));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), Alloc(a));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
test_string(std::allocator<char>());
|
||||
test_string(test_allocator<char>());
|
||||
test_string(test_allocator<char>(3));
|
||||
#if TEST_STD_VER >= 11
|
||||
test_string(min_allocator<char>());
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
# ifndef TEST_HAS_NO_EXCEPTIONS
|
||||
if (!TEST_IS_CONSTANT_EVALUATED) {
|
||||
typedef poca_alloc<char> A;
|
||||
|
||||
@@ -19,31 +19,25 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
// clang-format off
|
||||
template <template <class> class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string() {
|
||||
{
|
||||
std::basic_string<char, std::char_traits<char>, Alloc<char> > s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
{
|
||||
std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t> > s = {L'a', L'b', L'c'};
|
||||
assert(s == L"abc");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
TEST_CONSTEXPR_CXX20 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
|
||||
test_string<std::allocator>();
|
||||
test_string<min_allocator>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -18,18 +18,31 @@
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
// clang-format off
|
||||
template <template <class> class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string() {
|
||||
{
|
||||
std::string s;
|
||||
s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
typedef std::basic_string<char, std::char_traits<char>, Alloc<char>> S;
|
||||
S s;
|
||||
s = {'a', 'b', 'c'};
|
||||
S& result = (s = {'a', 'b', 'c'});
|
||||
assert(s == "abc");
|
||||
assert(&result == &s);
|
||||
}
|
||||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
|
||||
{
|
||||
typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, Alloc<wchar_t>> S;
|
||||
S s;
|
||||
S& result = (s = {L'a', L'b', L'c'});
|
||||
assert(s == L"abc");
|
||||
assert(&result == &s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
test_string<std::allocator>();
|
||||
test_string<min_allocator>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,10 @@
|
||||
#include "test_iterators.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class It>
|
||||
template <class Alloc, class It>
|
||||
TEST_CONSTEXPR_CXX20 void test(It first, It last) {
|
||||
typedef typename std::iterator_traits<It>::value_type charT;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
typedef typename S::allocator_type A;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
S s2(first, last);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
|
||||
@@ -36,14 +35,14 @@ TEST_CONSTEXPR_CXX20 void test(It first, It last) {
|
||||
++it;
|
||||
++i;
|
||||
}
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.get_allocator() == Alloc());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class It, class A>
|
||||
TEST_CONSTEXPR_CXX20 void test(It first, It last, const A& a) {
|
||||
template <class Alloc, class It>
|
||||
TEST_CONSTEXPR_CXX20 void test(It first, It last, const Alloc& a) {
|
||||
typedef typename std::iterator_traits<It>::value_type charT;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
S s2(first, last, a);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == static_cast<std::size_t>(std::distance(first, last)));
|
||||
@@ -57,64 +56,40 @@ TEST_CONSTEXPR_CXX20 void test(It first, It last, const A& a) {
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
|
||||
const char* s = "12345678901234567890123456789012345678901234567890";
|
||||
|
||||
test<Alloc>(s, s);
|
||||
test<Alloc>(s, s, Alloc(a));
|
||||
|
||||
test<Alloc>(s, s + 1);
|
||||
test<Alloc>(s, s + 1, Alloc(a));
|
||||
|
||||
test<Alloc>(s, s + 10);
|
||||
test<Alloc>(s, s + 10, Alloc(a));
|
||||
|
||||
test<Alloc>(s, s + 50);
|
||||
test<Alloc>(s, s + 50, Alloc(a));
|
||||
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s));
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), Alloc(a));
|
||||
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1));
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), Alloc(a));
|
||||
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10));
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), Alloc(a));
|
||||
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50));
|
||||
test<Alloc>(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 50), Alloc(a));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
const char* s = "12345678901234567890123456789012345678901234567890";
|
||||
|
||||
test(s, s);
|
||||
test(s, s, A(2));
|
||||
|
||||
test(s, s + 1);
|
||||
test(s, s + 1, A(2));
|
||||
|
||||
test(s, s + 10);
|
||||
test(s, s + 10, A(2));
|
||||
|
||||
test(s, s + 50);
|
||||
test(s, s + 50, A(2));
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), A(2));
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), A(2));
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), A(2));
|
||||
|
||||
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));
|
||||
}
|
||||
test_string(test_allocator<char>());
|
||||
test_string(test_allocator<char>(2));
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
const char* s = "12345678901234567890123456789012345678901234567890";
|
||||
|
||||
test(s, s);
|
||||
test(s, s, A());
|
||||
|
||||
test(s, s + 1);
|
||||
test(s, s + 1, A());
|
||||
|
||||
test(s, s + 10);
|
||||
test(s, s + 10, A());
|
||||
|
||||
test(s, s + 50);
|
||||
test(s, s + 50, A());
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s), A());
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 1), A());
|
||||
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10));
|
||||
test(cpp17_input_iterator<const char*>(s), cpp17_input_iterator<const char*>(s + 10), A());
|
||||
|
||||
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());
|
||||
}
|
||||
test_string(min_allocator<char>());
|
||||
#endif
|
||||
{
|
||||
static_assert((!std::is_constructible<std::string, std::string, std::string>::value), "");
|
||||
|
||||
@@ -30,21 +30,19 @@ TEST_CONSTEXPR_CXX20 void test(S s0) {
|
||||
assert(s2.get_allocator() == s1.get_allocator());
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(Alloc const& a) {
|
||||
using S = std::basic_string<char, std::char_traits<char>, Alloc>;
|
||||
test(S(Alloc(a)));
|
||||
test(S("1", Alloc(a)));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a)));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 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()));
|
||||
}
|
||||
test_string(std::allocator<char>());
|
||||
test_string(test_allocator<char>());
|
||||
test_string(test_allocator<char>(3));
|
||||
test_string(min_allocator<char>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,23 +20,22 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class charT>
|
||||
template <class Alloc, class charT>
|
||||
TEST_CONSTEXPR_CXX20 void test(const charT* s) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
std::size_t n = T::length(s);
|
||||
S s2(s);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
assert(T::compare(s2.data(), s, n) == 0);
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.get_allocator() == Alloc());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class charT, class A>
|
||||
TEST_CONSTEXPR_CXX20 void test(const charT* s, const A& a) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
template <class Alloc, class charT>
|
||||
TEST_CONSTEXPR_CXX20 void test(const charT* s, const Alloc& a) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
typedef typename S::traits_type T;
|
||||
std::size_t n = T::length(s);
|
||||
S s2(s, a);
|
||||
@@ -47,38 +46,27 @@ TEST_CONSTEXPR_CXX20 void test(const charT* s, const A& a) {
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test(const Alloc& a) {
|
||||
test<Alloc>("");
|
||||
test<Alloc>("", Alloc(a));
|
||||
|
||||
test<Alloc>("1");
|
||||
test<Alloc>("1", Alloc(a));
|
||||
|
||||
test<Alloc>("1234567980");
|
||||
test<Alloc>("1234567980", Alloc(a));
|
||||
|
||||
test<Alloc>("123456798012345679801234567980123456798012345679801234567980");
|
||||
test<Alloc>("123456798012345679801234567980123456798012345679801234567980", Alloc(a));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
|
||||
test("");
|
||||
test("", A(2));
|
||||
|
||||
test("1");
|
||||
test("1", A(2));
|
||||
|
||||
test("1234567980");
|
||||
test("1234567980", A(2));
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980");
|
||||
test("123456798012345679801234567980123456798012345679801234567980", A(2));
|
||||
}
|
||||
test(std::allocator<char>());
|
||||
test(test_allocator<char>());
|
||||
test(test_allocator<char>(2));
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
|
||||
test("");
|
||||
test("", A());
|
||||
|
||||
test("1");
|
||||
test("1", A());
|
||||
|
||||
test("1234567980");
|
||||
test("1234567980", A());
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980");
|
||||
test("123456798012345679801234567980123456798012345679801234567980", A());
|
||||
}
|
||||
test(min_allocator<char>());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
@@ -19,22 +19,21 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class charT>
|
||||
TEST_CONSTEXPR_CXX20 void test(const charT* s, unsigned n) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
template <class Alloc, class CharT>
|
||||
TEST_CONSTEXPR_CXX20 void test(const CharT* s, unsigned n) {
|
||||
typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
S s2(s, n);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
assert(T::compare(s2.data(), s, n) == 0);
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.get_allocator() == Alloc());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class charT, class A>
|
||||
TEST_CONSTEXPR_CXX20 void test(const charT* s, unsigned n, const A& a) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
template <class Alloc, class CharT>
|
||||
TEST_CONSTEXPR_CXX20 void test(const CharT* s, unsigned n, const Alloc& a) {
|
||||
typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
|
||||
typedef typename S::traits_type T;
|
||||
S s2(s, n, a);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
@@ -44,38 +43,27 @@ TEST_CONSTEXPR_CXX20 void test(const charT* s, unsigned n, const A& a) {
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test(const Alloc& a) {
|
||||
test<Alloc>("", 0);
|
||||
test<Alloc>("", 0, Alloc(a));
|
||||
|
||||
test<Alloc>("1", 1);
|
||||
test<Alloc>("1", 1, Alloc(a));
|
||||
|
||||
test<Alloc>("1234567980", 10);
|
||||
test<Alloc>("1234567980", 10, Alloc(a));
|
||||
|
||||
test<Alloc>("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test<Alloc>("123456798012345679801234567980123456798012345679801234567980", 60, Alloc(a));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
|
||||
test("", 0);
|
||||
test("", 0, A(2));
|
||||
|
||||
test("1", 1);
|
||||
test("1", 1, A(2));
|
||||
|
||||
test("1234567980", 10);
|
||||
test("1234567980", 10, A(2));
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
|
||||
}
|
||||
test(std::allocator<char>());
|
||||
test(test_allocator<char>());
|
||||
test(test_allocator<char>(2));
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
|
||||
test("", 0);
|
||||
test("", 0, A());
|
||||
|
||||
test("1", 1);
|
||||
test("1", 1, A());
|
||||
|
||||
test("1234567980", 10);
|
||||
test("1234567980", 10, A());
|
||||
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60, A());
|
||||
}
|
||||
test(min_allocator<char>());
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
|
||||
@@ -20,22 +20,21 @@
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class charT>
|
||||
template <class Alloc, class charT>
|
||||
TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
typedef typename S::allocator_type A;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
S s2(n, c);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
assert(s2[i] == c);
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.get_allocator() == Alloc());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class charT, class A>
|
||||
TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c, const A& a) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
template <class Alloc, class charT>
|
||||
TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c, const Alloc& a) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
S s2(n, c, a);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
@@ -45,24 +44,23 @@ TEST_CONSTEXPR_CXX20 void test(unsigned n, charT c, const A& a) {
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class Tp>
|
||||
template <class Alloc, class Tp>
|
||||
TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c) {
|
||||
typedef char charT;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
typedef typename S::allocator_type A;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
S s2(n, c);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == static_cast<std::size_t>(n));
|
||||
for (int i = 0; i < n; ++i)
|
||||
assert(s2[i] == c);
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.get_allocator() == Alloc());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class Tp, class A>
|
||||
TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c, const A& a) {
|
||||
template <class Alloc, class Tp>
|
||||
TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c, const Alloc& a) {
|
||||
typedef char charT;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, Alloc> S;
|
||||
S s2(n, c, a);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == static_cast<std::size_t>(n));
|
||||
@@ -72,44 +70,30 @@ TEST_CONSTEXPR_CXX20 void test(Tp n, Tp c, const A& a) {
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
|
||||
test<Alloc>(0, 'a');
|
||||
test<Alloc>(0, 'a', Alloc(a));
|
||||
|
||||
test<Alloc>(1, 'a');
|
||||
test<Alloc>(1, 'a', Alloc(a));
|
||||
|
||||
test<Alloc>(10, 'a');
|
||||
test<Alloc>(10, 'a', Alloc(a));
|
||||
|
||||
test<Alloc>(100, 'a');
|
||||
test<Alloc>(100, 'a', Alloc(a));
|
||||
|
||||
test<Alloc>(static_cast<char>(100), static_cast<char>(65));
|
||||
test<Alloc>(static_cast<char>(100), static_cast<char>(65), a);
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
|
||||
test(0, 'a');
|
||||
test(0, 'a', A(2));
|
||||
|
||||
test(1, 'a');
|
||||
test(1, 'a', A(2));
|
||||
|
||||
test(10, 'a');
|
||||
test(10, 'a', A(2));
|
||||
|
||||
test(100, 'a');
|
||||
test(100, 'a', A(2));
|
||||
|
||||
test(static_cast<char>(100), static_cast<char>(65));
|
||||
test(static_cast<char>(100), static_cast<char>(65), A(3));
|
||||
}
|
||||
test_string(std::allocator<char>());
|
||||
test_string(test_allocator<char>());
|
||||
test_string(test_allocator<char>(2));
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
|
||||
test(0, 'a');
|
||||
test(0, 'a', A());
|
||||
|
||||
test(1, 'a');
|
||||
test(1, 'a', A());
|
||||
|
||||
test(10, 'a');
|
||||
test(10, 'a', A());
|
||||
|
||||
test(100, 'a');
|
||||
test(100, 'a', A());
|
||||
|
||||
test(static_cast<char>(100), static_cast<char>(65));
|
||||
test(static_cast<char>(100), static_cast<char>(65), A());
|
||||
}
|
||||
test_string(min_allocator<char>());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
@@ -24,17 +24,16 @@
|
||||
static_assert(!std::is_convertible<std::string_view, std::string const&>::value, "");
|
||||
static_assert(!std::is_convertible<std::string_view, std::string>::value, "");
|
||||
|
||||
template <class charT>
|
||||
TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
|
||||
template <class Alloc, class CharT>
|
||||
TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<CharT> sv) {
|
||||
typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
{
|
||||
S s2(sv);
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == sv.size());
|
||||
assert(T::compare(s2.data(), sv.data(), sv.size()) == 0);
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.get_allocator() == Alloc());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
{
|
||||
@@ -43,14 +42,14 @@ TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv) {
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == sv.size());
|
||||
assert(T::compare(s2.data(), sv.data(), sv.size()) == 0);
|
||||
assert(s2.get_allocator() == A());
|
||||
assert(s2.get_allocator() == Alloc());
|
||||
assert(s2.capacity() >= s2.size());
|
||||
}
|
||||
}
|
||||
|
||||
template <class charT, class A>
|
||||
TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv, const A& a) {
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
template <class Alloc, class CharT>
|
||||
TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<CharT> sv, const Alloc& a) {
|
||||
typedef std::basic_string<CharT, std::char_traits<CharT>, Alloc> S;
|
||||
typedef typename S::traits_type T;
|
||||
{
|
||||
S s2(sv, a);
|
||||
@@ -71,40 +70,29 @@ TEST_CONSTEXPR_CXX20 void test(std::basic_string_view<charT> sv, const A& a) {
|
||||
}
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a) {
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
|
||||
test<Alloc>(SV(""));
|
||||
test<Alloc>(SV(""), Alloc(a));
|
||||
|
||||
test<Alloc>(SV("1"));
|
||||
test<Alloc>(SV("1"), Alloc(a));
|
||||
|
||||
test<Alloc>(SV("1234567980"));
|
||||
test<Alloc>(SV("1234567980"), Alloc(a));
|
||||
|
||||
test<Alloc>(SV("123456798012345679801234567980123456798012345679801234567980"));
|
||||
test<Alloc>(SV("123456798012345679801234567980123456798012345679801234567980"), Alloc(a));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
|
||||
test(SV(""));
|
||||
test(SV(""), A(2));
|
||||
|
||||
test(SV("1"));
|
||||
test(SV("1"), A(2));
|
||||
|
||||
test(SV("1234567980"));
|
||||
test(SV("1234567980"), A(2));
|
||||
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"));
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"), A(2));
|
||||
}
|
||||
test_string(std::allocator<char>());
|
||||
test_string(test_allocator<char>());
|
||||
test_string(test_allocator<char>(2));
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string_view<char, std::char_traits<char> > SV;
|
||||
|
||||
test(SV(""));
|
||||
test(SV(""), A());
|
||||
|
||||
test(SV("1"));
|
||||
test(SV("1"), A());
|
||||
|
||||
test(SV("1234567980"));
|
||||
test(SV("1234567980"), A());
|
||||
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"));
|
||||
test(SV("123456798012345679801234567980123456798012345679801234567980"), A());
|
||||
}
|
||||
test_string(min_allocator<char>());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
@@ -105,8 +105,8 @@ TEST_CONSTEXPR_CXX20 void test(S str, unsigned pos, unsigned n, const typename S
|
||||
|
||||
void test_lwg2583() {
|
||||
#if TEST_STD_VER >= 11 && !defined(TEST_HAS_NO_EXCEPTIONS)
|
||||
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> StringA;
|
||||
std::vector<StringA, std::scoped_allocator_adaptor<test_allocator<StringA>>> vs;
|
||||
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > StringA;
|
||||
std::vector<StringA, std::scoped_allocator_adaptor<test_allocator<StringA> > > vs;
|
||||
StringA s{"1234"};
|
||||
vs.emplace_back(s, 2);
|
||||
|
||||
@@ -119,84 +119,51 @@ void test_lwg2583() {
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class Alloc>
|
||||
TEST_CONSTEXPR_CXX20 void test_string(const Alloc& a1, const Alloc& a2) {
|
||||
using S = std::basic_string<char, std::char_traits<char>, Alloc>;
|
||||
|
||||
test(S(Alloc(a1)), 0);
|
||||
test(S(Alloc(a1)), 1);
|
||||
test(S("1", Alloc(a1)), 0);
|
||||
test(S("1", Alloc(a1)), 1);
|
||||
test(S("1", Alloc(a1)), 2);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 0);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 5);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 500);
|
||||
|
||||
test(S(Alloc(a1)), 0, 0);
|
||||
test(S(Alloc(a1)), 0, 1);
|
||||
test(S(Alloc(a1)), 1, 0);
|
||||
test(S(Alloc(a1)), 1, 1);
|
||||
test(S(Alloc(a1)), 1, 2);
|
||||
test(S("1", Alloc(a1)), 0, 0);
|
||||
test(S("1", Alloc(a1)), 0, 1);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 0);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 1);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 10);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 100);
|
||||
|
||||
test(S(Alloc(a1)), 0, 0, Alloc(a2));
|
||||
test(S(Alloc(a1)), 0, 1, Alloc(a2));
|
||||
test(S(Alloc(a1)), 1, 0, Alloc(a2));
|
||||
test(S(Alloc(a1)), 1, 1, Alloc(a2));
|
||||
test(S(Alloc(a1)), 1, 2, Alloc(a2));
|
||||
test(S("1", Alloc(a1)), 0, 0, Alloc(a2));
|
||||
test(S("1", Alloc(a1)), 0, 1, Alloc(a2));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 0, Alloc(a2));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 1, Alloc(a2));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 10, Alloc(a2));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", Alloc(a1)), 50, 100, Alloc(a2));
|
||||
}
|
||||
|
||||
TEST_CONSTEXPR_CXX20 bool test() {
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
test(S(A(3)), 0);
|
||||
test(S(A(3)), 1);
|
||||
test(S("1", A(5)), 0);
|
||||
test(S("1", A(5)), 1);
|
||||
test(S("1", A(5)), 2);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 0);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 5);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 500);
|
||||
|
||||
test(S(A(3)), 0, 0);
|
||||
test(S(A(3)), 0, 1);
|
||||
test(S(A(3)), 1, 0);
|
||||
test(S(A(3)), 1, 1);
|
||||
test(S(A(3)), 1, 2);
|
||||
test(S("1", A(5)), 0, 0);
|
||||
test(S("1", A(5)), 0, 1);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100);
|
||||
|
||||
test(S(A(3)), 0, 0, A(4));
|
||||
test(S(A(3)), 0, 1, A(4));
|
||||
test(S(A(3)), 1, 0, A(4));
|
||||
test(S(A(3)), 1, 1, A(4));
|
||||
test(S(A(3)), 1, 2, A(4));
|
||||
test(S("1", A(5)), 0, 0, A(6));
|
||||
test(S("1", A(5)), 0, 1, A(6));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0, A(8));
|
||||
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));
|
||||
}
|
||||
test_string(std::allocator<char>(), std::allocator<char>());
|
||||
test_string(test_allocator<char>(), test_allocator<char>());
|
||||
test_string(test_allocator<char>(3), test_allocator<char>(5));
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
test(S(A()), 0);
|
||||
test(S(A()), 1);
|
||||
test(S("1", A()), 0);
|
||||
test(S("1", A()), 1);
|
||||
test(S("1", A()), 2);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 0);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 5);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 500);
|
||||
|
||||
test(S(A()), 0, 0);
|
||||
test(S(A()), 0, 1);
|
||||
test(S(A()), 1, 0);
|
||||
test(S(A()), 1, 1);
|
||||
test(S(A()), 1, 2);
|
||||
test(S("1", A()), 0, 0);
|
||||
test(S("1", A()), 0, 1);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10);
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100);
|
||||
|
||||
test(S(A()), 0, 0, A());
|
||||
test(S(A()), 0, 1, A());
|
||||
test(S(A()), 1, 0, A());
|
||||
test(S(A()), 1, 1, A());
|
||||
test(S(A()), 1, 2, A());
|
||||
test(S("1", A()), 0, 0, A());
|
||||
test(S("1", A()), 0, 1, A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0, A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1, A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
|
||||
}
|
||||
test_string(min_allocator<char>(), min_allocator<char>());
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user