Revert "Revert "Update aosp/master libcxx rebase to r263688""
This reverts commit 1d4a1edbc7.
Change-Id: I2909937fe582f2c5552bc86e7f4d2d5cff0de0aa
This commit is contained in:
@@ -29,7 +29,7 @@ test()
|
||||
static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
|
||||
#endif
|
||||
S s;
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(s.data());
|
||||
assert(s.size() == 0);
|
||||
assert(s.capacity() >= s.size());
|
||||
@@ -42,7 +42,7 @@ test()
|
||||
static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
|
||||
#endif
|
||||
S s(typename S::allocator_type(5));
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(s.data());
|
||||
assert(s.size() == 0);
|
||||
assert(s.capacity() >= s.size());
|
||||
@@ -63,7 +63,7 @@ test2()
|
||||
static_assert((noexcept(S()) == noexcept(typename S::allocator_type())), "" );
|
||||
#endif
|
||||
S s;
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(s.data());
|
||||
assert(s.size() == 0);
|
||||
assert(s.capacity() >= s.size());
|
||||
@@ -76,7 +76,7 @@ test2()
|
||||
static_assert((noexcept(S(typename S::allocator_type())) == std::is_nothrow_copy_constructible<typename S::allocator_type>::value), "" );
|
||||
#endif
|
||||
S s(typename S::allocator_type{});
|
||||
assert(s.__invariants());
|
||||
LIBCPP_ASSERT(s.__invariants());
|
||||
assert(s.data());
|
||||
assert(s.size() == 0);
|
||||
assert(s.capacity() >= s.size());
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -22,7 +23,7 @@ test(S s1, typename S::value_type s2)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
s1 = s2;
|
||||
assert(s1.__invariants());
|
||||
LIBCPP_ASSERT(s1.__invariants());
|
||||
assert(s1.size() == 1);
|
||||
assert(T::eq(s1[0], s2));
|
||||
assert(s1.capacity() >= s1.size());
|
||||
@@ -37,7 +38,7 @@ int main()
|
||||
test(S("123456789"), 'a');
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), 'a');
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -22,7 +23,7 @@ void
|
||||
test(S s1)
|
||||
{
|
||||
S s2 = s1;
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2 == s1);
|
||||
assert(s2.capacity() >= s2.size());
|
||||
assert(s2.get_allocator() == s1.get_allocator());
|
||||
@@ -37,7 +38,7 @@ int main()
|
||||
test(S("1", A(5)));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -22,7 +23,7 @@ void
|
||||
test(S s1, const typename S::allocator_type& a)
|
||||
{
|
||||
S s2(s1, a);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2 == s1);
|
||||
assert(s2.capacity() >= s2.size());
|
||||
assert(s2.get_allocator() == a);
|
||||
@@ -37,7 +38,7 @@ int main()
|
||||
test(S("1"), A(5));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -22,7 +23,7 @@ void
|
||||
test(S s1, const S& s2)
|
||||
{
|
||||
s1 = s2;
|
||||
assert(s1.__invariants());
|
||||
LIBCPP_ASSERT(s1.__invariants());
|
||||
assert(s1 == s2);
|
||||
assert(s1.capacity() >= s1.size());
|
||||
}
|
||||
@@ -47,7 +48,7 @@ int main()
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), S());
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string()
|
||||
@@ -29,7 +31,6 @@ struct some_alloc
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::string C;
|
||||
static_assert(std::is_nothrow_default_constructible<C>::value, "");
|
||||
@@ -42,5 +43,4 @@ int main()
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
|
||||
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// ~basic_string() // implied noexcept;
|
||||
@@ -16,8 +18,6 @@
|
||||
|
||||
#include "test_allocator.h"
|
||||
|
||||
#if __has_feature(cxx_noexcept)
|
||||
|
||||
template <class T>
|
||||
struct some_alloc
|
||||
{
|
||||
@@ -26,11 +26,8 @@ struct some_alloc
|
||||
~some_alloc() noexcept(false);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::string C;
|
||||
static_assert(std::is_nothrow_destructible<C>::value, "");
|
||||
@@ -43,5 +40,4 @@ int main()
|
||||
typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
|
||||
static_assert(!std::is_nothrow_destructible<C>::value, "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
|
||||
@@ -19,7 +21,6 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::string s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
@@ -29,7 +30,6 @@ int main()
|
||||
s = {L'a', L'b', L'c'};
|
||||
assert(s == L"abc");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s = {'a', 'b', 'c'};
|
||||
@@ -41,6 +41,4 @@ int main()
|
||||
s = {L'a', L'b', L'c'};
|
||||
assert(s == L"abc");
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string& operator=(initializer_list<charT> il);
|
||||
@@ -18,19 +20,15 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::string s;
|
||||
s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
S s;
|
||||
s = {'a', 'b', 'c'};
|
||||
assert(s == "abc");
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "../input_iterator.h"
|
||||
#include "min_allocator.h"
|
||||
@@ -30,7 +31,7 @@ test(It first, It last)
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
S s2(first, last);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == std::distance(first, last));
|
||||
unsigned i = 0;
|
||||
for (It it = first; it != last; ++it, ++i)
|
||||
@@ -47,7 +48,7 @@ test(It first, It last, const A& a)
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
typedef typename S::traits_type T;
|
||||
S s2(first, last, a);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == std::distance(first, last));
|
||||
unsigned i = 0;
|
||||
for (It it = first; it != last; ++it, ++i)
|
||||
@@ -86,7 +87,7 @@ int main()
|
||||
test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
|
||||
test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A(2));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
const char* s = "12345678901234567890123456789012345678901234567890";
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string(basic_string<charT,traits,Allocator>&& str);
|
||||
@@ -14,8 +16,7 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -25,18 +26,15 @@ test(S s0)
|
||||
{
|
||||
S s1 = s0;
|
||||
S s2 = std::move(s0);
|
||||
assert(s2.__invariants());
|
||||
assert(s0.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
LIBCPP_ASSERT(s0.__invariants());
|
||||
assert(s2 == s1);
|
||||
assert(s2.capacity() >= s2.size());
|
||||
assert(s2.get_allocator() == s1.get_allocator());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
@@ -44,7 +42,6 @@ int main()
|
||||
test(S("1", A(5)));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
@@ -52,6 +49,4 @@ int main()
|
||||
test(S("1", A()));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string(basic_string&& str, const Allocator& alloc);
|
||||
@@ -14,8 +16,6 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
@@ -27,23 +27,16 @@ test(S s0, const typename S::allocator_type& a)
|
||||
{
|
||||
S s1 = s0;
|
||||
S s2(std::move(s0), a);
|
||||
assert(s2.__invariants());
|
||||
assert(s0.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
LIBCPP_ASSERT(s0.__invariants());
|
||||
assert(s2 == s1);
|
||||
assert(s2.capacity() >= s2.size());
|
||||
assert(s2.get_allocator() == a);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
// #if _LIBCPP_STD_VER <= 14
|
||||
// _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
|
||||
// #else
|
||||
// _NOEXCEPT;
|
||||
// #endif
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef test_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
@@ -70,8 +63,6 @@ int main()
|
||||
S s2 (std::move(s1), A(1));
|
||||
}
|
||||
assert ( test_alloc_base::alloc_count == alloc_count );
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
@@ -84,6 +75,4 @@ int main()
|
||||
test(S("1"), A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
||||
@@ -7,18 +7,24 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string& operator=(basic_string&& c)
|
||||
// noexcept(
|
||||
// allocator_type::propagate_on_container_move_assignment::value &&
|
||||
// is_nothrow_move_assignable<allocator_type>::value);
|
||||
|
||||
// This tests a conforming extension
|
||||
// allocator_traits<allocator_type>::propagate_on_container_move_assignment::value ||
|
||||
// allocator_traits<allocator_type>::is_always_equal::value); // C++17
|
||||
//
|
||||
// before C++17, we use the conforming extension
|
||||
// noexcept(
|
||||
// allocator_type::propagate_on_container_move_assignment::value &&
|
||||
// is_nothrow_move_assignable<allocator_type>::value);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
|
||||
template <class T>
|
||||
@@ -28,9 +34,34 @@ struct some_alloc
|
||||
some_alloc(const some_alloc&);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct some_alloc2
|
||||
{
|
||||
typedef T value_type;
|
||||
|
||||
some_alloc2() {}
|
||||
some_alloc2(const some_alloc2&);
|
||||
void deallocate(void*, unsigned) {}
|
||||
|
||||
typedef std::false_type propagate_on_container_move_assignment;
|
||||
typedef std::true_type is_always_equal;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct some_alloc3
|
||||
{
|
||||
typedef T value_type;
|
||||
|
||||
some_alloc3() {}
|
||||
some_alloc3(const some_alloc3&);
|
||||
void deallocate(void*, unsigned) {}
|
||||
|
||||
typedef std::false_type propagate_on_container_move_assignment;
|
||||
typedef std::false_type is_always_equal;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::string C;
|
||||
static_assert(std::is_nothrow_move_assignable<C>::value, "");
|
||||
@@ -41,6 +72,22 @@ int main()
|
||||
}
|
||||
{
|
||||
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
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string<charT,traits,Allocator>&
|
||||
@@ -15,8 +17,7 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -26,17 +27,14 @@ test(S s1, S s2)
|
||||
{
|
||||
S s0 = s2;
|
||||
s1 = std::move(s2);
|
||||
assert(s1.__invariants());
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s1.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s1 == s0);
|
||||
assert(s1.capacity() >= s1.size());
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
{
|
||||
typedef std::string S;
|
||||
test(S(), S());
|
||||
@@ -55,7 +53,6 @@ int main()
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), S());
|
||||
@@ -74,6 +71,4 @@ int main()
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
|
||||
// <string>
|
||||
|
||||
// basic_string(basic_string&&)
|
||||
@@ -29,7 +31,6 @@ struct some_alloc
|
||||
|
||||
int main()
|
||||
{
|
||||
#if __has_feature(cxx_noexcept)
|
||||
{
|
||||
typedef std::string C;
|
||||
static_assert(std::is_nothrow_move_constructible<C>::value, "");
|
||||
@@ -46,5 +47,4 @@ int main()
|
||||
static_assert( std::is_nothrow_move_constructible<C>::value, "");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -28,7 +29,7 @@ test(const charT* s)
|
||||
typedef typename S::allocator_type A;
|
||||
unsigned n = T::length(s);
|
||||
S s2(s);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
assert(T::compare(s2.data(), s, n) == 0);
|
||||
assert(s2.get_allocator() == A());
|
||||
@@ -43,7 +44,7 @@ test(const charT* s, const A& a)
|
||||
typedef typename S::traits_type T;
|
||||
unsigned n = T::length(s);
|
||||
S s2(s, a);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
assert(T::compare(s2.data(), s, n) == 0);
|
||||
assert(s2.get_allocator() == a);
|
||||
@@ -68,7 +69,7 @@ int main()
|
||||
test("123456798012345679801234567980123456798012345679801234567980");
|
||||
test("123456798012345679801234567980123456798012345679801234567980", A(2));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
template <class S>
|
||||
@@ -23,7 +24,7 @@ test(S s1, const typename S::value_type* s2)
|
||||
{
|
||||
typedef typename S::traits_type T;
|
||||
s1 = s2;
|
||||
assert(s1.__invariants());
|
||||
LIBCPP_ASSERT(s1.__invariants());
|
||||
assert(s1.size() == T::length(s2));
|
||||
assert(T::compare(s1.data(), s2, s1.size()) == 0);
|
||||
assert(s1.capacity() >= s1.size());
|
||||
@@ -49,7 +50,7 @@ int main()
|
||||
"1234567890123456789012345678901234567890123456789012345678901234567890"),
|
||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
|
||||
test(S(), "");
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -27,7 +28,7 @@ test(const charT* s, unsigned n)
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
S s2(s, n);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
assert(T::compare(s2.data(), s, n) == 0);
|
||||
assert(s2.get_allocator() == A());
|
||||
@@ -41,7 +42,7 @@ test(const charT* s, unsigned n, const A& a)
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
typedef typename S::traits_type T;
|
||||
S s2(s, n, a);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
assert(T::compare(s2.data(), s, n) == 0);
|
||||
assert(s2.get_allocator() == a);
|
||||
@@ -66,7 +67,7 @@ int main()
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60);
|
||||
test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -27,7 +28,7 @@ test(unsigned n, charT c)
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
S s2(n, c);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
assert(s2[i] == c);
|
||||
@@ -42,7 +43,7 @@ test(unsigned n, charT c, const A& a)
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
typedef typename S::traits_type T;
|
||||
S s2(n, c, a);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
assert(s2[i] == c);
|
||||
@@ -59,7 +60,7 @@ test(Tp n, Tp c)
|
||||
typedef typename S::traits_type T;
|
||||
typedef typename S::allocator_type A;
|
||||
S s2(n, c);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
assert(s2[i] == c);
|
||||
@@ -75,7 +76,7 @@ test(Tp n, Tp c, const A& a)
|
||||
typedef std::basic_string<charT, std::char_traits<charT>, A> S;
|
||||
typedef typename S::traits_type T;
|
||||
S s2(n, c, a);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(s2.size() == n);
|
||||
for (unsigned i = 0; i < n; ++i)
|
||||
assert(s2[i] == c);
|
||||
@@ -104,7 +105,7 @@ int main()
|
||||
test(100, 65);
|
||||
test(100, 65, A(3));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
|
||||
@@ -7,17 +7,25 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL: libcpp-no-exceptions
|
||||
// <string>
|
||||
|
||||
// basic_string(const basic_string<charT,traits,Allocator>& str,
|
||||
// size_type pos, size_type n = npos,
|
||||
// size_type pos, size_type n,
|
||||
// const Allocator& a = Allocator());
|
||||
//
|
||||
// basic_string(const basic_string<charT,traits,Allocator>& str,
|
||||
// size_type pos,
|
||||
// const Allocator& a = Allocator());
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <scoped_allocator>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_macros.h"
|
||||
#include "test_allocator.h"
|
||||
#include "min_allocator.h"
|
||||
|
||||
@@ -30,7 +38,7 @@ test(S str, unsigned pos)
|
||||
try
|
||||
{
|
||||
S s2(str, pos);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(pos <= str.size());
|
||||
unsigned rlen = str.size() - pos;
|
||||
assert(s2.size() == rlen);
|
||||
@@ -53,7 +61,7 @@ test(S str, unsigned pos, unsigned n)
|
||||
try
|
||||
{
|
||||
S s2(str, pos, n);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(pos <= str.size());
|
||||
unsigned rlen = std::min<unsigned>(str.size() - pos, n);
|
||||
assert(s2.size() == rlen);
|
||||
@@ -76,7 +84,7 @@ test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
|
||||
try
|
||||
{
|
||||
S s2(str, pos, n, a);
|
||||
assert(s2.__invariants());
|
||||
LIBCPP_ASSERT(s2.__invariants());
|
||||
assert(pos <= str.size());
|
||||
unsigned rlen = std::min<unsigned>(str.size() - pos, n);
|
||||
assert(s2.size() == rlen);
|
||||
@@ -90,6 +98,20 @@ test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
|
||||
}
|
||||
}
|
||||
|
||||
#if TEST_STD_VER >= 11
|
||||
void test2583()
|
||||
{ // LWG #2583
|
||||
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);
|
||||
|
||||
try { vs.emplace_back(s, 5); }
|
||||
catch (const std::out_of_range&) { return; }
|
||||
assert(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -130,7 +152,7 @@ int main()
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
#if TEST_STD_VER >= 11
|
||||
{
|
||||
typedef min_allocator<char> A;
|
||||
typedef std::basic_string<char, std::char_traits<char>, A> S;
|
||||
@@ -169,5 +191,7 @@ int main()
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());
|
||||
test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
|
||||
}
|
||||
|
||||
test2583();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user