Revert "Revert "Merge to upstream r304942.""

This reverts commit 38a0d5af7e.

Test: make checkbuild
Test: ./run_tests.py
Test: ./run_tests.py --bitness 64
This commit is contained in:
Dan Albert
2018-01-17 14:21:02 -08:00
parent 38a0d5af7e
commit c79549b70e
1102 changed files with 19092 additions and 14798 deletions

View File

@@ -8,6 +8,12 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcpp-no-exceptions
// XFAIL: with_system_cxx_lib=macosx10.11
// XFAIL: with_system_cxx_lib=macosx10.10
// XFAIL: with_system_cxx_lib=macosx10.9
// XFAIL: with_system_cxx_lib=macosx10.8
// XFAIL: with_system_cxx_lib=macosx10.7
// <string>
// size_type max_size() const;

View File

@@ -27,16 +27,17 @@
template <class S, class SV>
void
test(SV sv, unsigned pos, unsigned n)
test(SV sv, std::size_t pos, std::size_t n)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
typedef typename S::size_type Size;
if (pos <= sv.size())
{
S s2(sv, pos, n);
S s2(sv, static_cast<Size>(pos), static_cast<Size>(n));
LIBCPP_ASSERT(s2.__invariants());
assert(pos <= sv.size());
unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
std::size_t rlen = std::min(sv.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
assert(s2.get_allocator() == A());
@@ -47,7 +48,7 @@ test(SV sv, unsigned pos, unsigned n)
{
try
{
S s2(sv, pos, n);
S s2(sv, static_cast<Size>(pos), static_cast<Size>(n));
assert(false);
}
catch (std::out_of_range&)
@@ -60,16 +61,16 @@ test(SV sv, unsigned pos, unsigned n)
template <class S, class SV>
void
test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
test(SV sv, std::size_t pos, std::size_t n, const typename S::allocator_type& a)
{
typedef typename S::traits_type T;
typedef typename S::allocator_type A;
typedef typename S::size_type Size;
if (pos <= sv.size())
{
S s2(sv, pos, n, a);
S s2(sv, static_cast<Size>(pos), static_cast<Size>(n), a);
LIBCPP_ASSERT(s2.__invariants());
assert(pos <= sv.size());
unsigned rlen = std::min<unsigned>(sv.size() - pos, n);
std::size_t rlen = std::min(sv.size() - pos, n);
assert(s2.size() == rlen);
assert(T::compare(s2.data(), sv.data() + pos, rlen) == 0);
assert(s2.get_allocator() == a);
@@ -80,7 +81,7 @@ test(SV sv, unsigned pos, unsigned n, const typename S::allocator_type& a)
{
try
{
S s2(sv, pos, n, a);
S s2(sv, static_cast<Size>(pos), static_cast<Size>(n), a);
assert(false);
}
catch (std::out_of_range&)

View File

@@ -204,4 +204,20 @@ int main()
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef forward_iterator<const char*> It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef const char* It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.append(MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
}

View File

@@ -24,6 +24,7 @@ test(S s, typename S::difference_type pos, S expected)
typename S::const_iterator p = s.begin() + pos;
typename S::iterator i = s.erase(p);
LIBCPP_ASSERT(s.__invariants());
assert(s[s.size()] == typename S::value_type());
assert(s == expected);
assert(i - s.begin() == pos);
}

View File

@@ -25,6 +25,7 @@ test(S s, typename S::difference_type pos, typename S::difference_type n, S expe
typename S::const_iterator last = s.cbegin() + pos + n;
typename S::iterator i = s.erase(first, last);
LIBCPP_ASSERT(s.__invariants());
assert(s[s.size()] == typename S::value_type());
assert(s == expected);
assert(i - s.begin() == pos);
}

View File

@@ -23,6 +23,7 @@ test(S s, S expected)
{
s.pop_back();
LIBCPP_ASSERT(s.__invariants());
assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}

View File

@@ -29,6 +29,7 @@ test(S s, typename S::size_type pos, typename S::size_type n, S expected)
{
s.erase(pos, n);
LIBCPP_ASSERT(s.__invariants());
assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -58,6 +59,7 @@ test(S s, typename S::size_type pos, S expected)
{
s.erase(pos);
LIBCPP_ASSERT(s.__invariants());
assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -83,6 +85,7 @@ test(S s, S expected)
{
s.erase();
LIBCPP_ASSERT(s.__invariants());
assert(s[s.size()] == typename S::value_type());
assert(s == expected);
}

View File

@@ -7,13 +7,12 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <string>
// iterator insert(const_iterator p, initializer_list<charT> il);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <string>
#include <cassert>
@@ -22,14 +21,12 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s("123456");
std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
assert(i - s.begin() == 3);
assert(s == "123abc456");
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("123456");
@@ -37,14 +34,4 @@ int main()
assert(i - s.begin() == 3);
assert(s == "123abc456");
}
#endif
#if _LIBCPP_DEBUG >= 1
{
std::string s;
std::string s2;
s.insert(s2.begin(), {'a', 'b', 'c'});
assert(false);
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -188,10 +188,35 @@ int main()
{ // test assigning a different type
typedef std::string S;
const uint8_t p[] = "ABCD";
const uint8_t p[] = "ABCD";
S s;
s.insert(s.begin(), p, p + 4);
assert(s == "ABCD");
S s;
s.insert(s.begin(), p, p + 4);
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef input_iterator<const char*> It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef forward_iterator<const char*> It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
{ // test with a move iterator that returns char&&
typedef const char* It;
typedef std::move_iterator<It> MoveIt;
const char p[] = "ABCD";
std::string s;
s.insert(s.begin(), MoveIt(It(std::begin(p))), MoveIt(It(std::end(p) - 1)));
assert(s == "ABCD");
}
}

View File

@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <string>
// basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il);
@@ -18,19 +20,15 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
{
std::string s("123def456");
s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
assert(s == "123abc456");
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("123def456");
s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
assert(s == "123abc456");
}
#endif
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
}

View File

@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <string>
// template<class charT, class traits, class Allocator>
@@ -22,7 +24,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::string s("initial text");
getline(std::istringstream(" abc* def* ghij"), s, '*');
@@ -33,7 +34,6 @@ int main()
getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
assert(s == L" abc");
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("initial text");
@@ -46,6 +46,4 @@ int main()
getline(std::wistringstream(L" abc* def* ghij"), s, L'*');
assert(s == L" abc");
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <string>
// template<class charT, class traits, class Allocator>
@@ -22,7 +24,6 @@
int main()
{
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::string s("initial text");
getline(std::istringstream(" abc\n def\n ghij"), s);
@@ -33,7 +34,6 @@ int main()
getline(std::wistringstream(L" abc\n def\n ghij"), s);
assert(s == L" abc");
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S s("initial text");
@@ -46,6 +46,4 @@ int main()
getline(std::wistringstream(L" abc\n def\n ghij"), s);
assert(s == L" abc");
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}

View File

@@ -21,60 +21,50 @@
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
void
test0(typename S::value_type lhs, const S& rhs, const S& x)
{
assert(lhs + rhs == x);
void test0(typename S::value_type lhs, const S& rhs, const S& x) {
assert(lhs + rhs == x);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if TEST_STD_VER >= 11
template <class S>
void
test1(typename S::value_type lhs, S&& rhs, const S& x)
{
assert(lhs + move(rhs) == x);
void test1(typename S::value_type lhs, S&& rhs, const S& x) {
assert(lhs + move(rhs) == x);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
{
int main() {
{
typedef std::string S;
test0('a', S(""), S("a"));
test0('a', S("12345"), S("a12345"));
test0('a', S("1234567890"), S("a1234567890"));
test0('a', S("12345678901234567890"), S("a12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1('a', S(""), S("a"));
test1('a', S("12345"), S("a12345"));
test1('a', S("1234567890"), S("a1234567890"));
test1('a', S("12345678901234567890"), S("a12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0('a', S(""), S("a"));
test0('a', S("12345"), S("a12345"));
test0('a', S("1234567890"), S("a1234567890"));
test0('a', S("12345678901234567890"), S("a12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1('a', S(""), S("a"));
test1('a', S("12345"), S("a12345"));
test1('a', S("1234567890"), S("a1234567890"));
test1('a', S("12345678901234567890"), S("a12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
}
#endif
}

View File

@@ -21,29 +21,23 @@
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
void
test0(const typename S::value_type* lhs, const S& rhs, const S& x)
{
assert(lhs + rhs == x);
void test0(const typename S::value_type* lhs, const S& rhs, const S& x) {
assert(lhs + rhs == x);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if TEST_STD_VER >= 11
template <class S>
void
test1(const typename S::value_type* lhs, S&& rhs, const S& x)
{
assert(lhs + move(rhs) == x);
void test1(const typename S::value_type* lhs, S&& rhs, const S& x) {
assert(lhs + move(rhs) == x);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
{
int main() {
{
typedef std::string S;
test0("", S(""), S(""));
test0("", S("12345"), S("12345"));
@@ -56,14 +50,19 @@ int main()
test0("abcdefghij", S(""), S("abcdefghij"));
test0("abcdefghij", S("12345"), S("abcdefghij12345"));
test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test0("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test0("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1("", S(""), S(""));
test1("", S("12345"), S("12345"));
test1("", S("1234567890"), S("1234567890"));
@@ -75,17 +74,19 @@ int main()
test1("abcdefghij", S(""), S("abcdefghij"));
test1("abcdefghij", S("12345"), S("abcdefghij12345"));
test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test1("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test1("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0("", S(""), S(""));
test0("", S("12345"), S("12345"));
test0("", S("1234567890"), S("1234567890"));
@@ -97,13 +98,14 @@ int main()
test0("abcdefghij", S(""), S("abcdefghij"));
test0("abcdefghij", S("12345"), S("abcdefghij12345"));
test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test0("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test0("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test1("", S(""), S(""));
test1("", S("12345"), S("12345"));
@@ -116,13 +118,14 @@ int main()
test1("abcdefghij", S(""), S("abcdefghij"));
test1("abcdefghij", S("12345"), S("abcdefghij12345"));
test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test1("abcdefghij", S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
test1("abcdefghijklmnopqrst", S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1("abcdefghijklmnopqrst", S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#endif
}

View File

@@ -21,60 +21,50 @@
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
void
test0(const S& lhs, typename S::value_type rhs, const S& x)
{
assert(lhs + rhs == x);
void test0(const S& lhs, typename S::value_type rhs, const S& x) {
assert(lhs + rhs == x);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if TEST_STD_VER >= 11
template <class S>
void
test1(S&& lhs, typename S::value_type rhs, const S& x)
{
assert(move(lhs) + rhs == x);
void test1(S&& lhs, typename S::value_type rhs, const S& x) {
assert(move(lhs) + rhs == x);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
{
int main() {
{
typedef std::string S;
test0(S(""), '1', S("1"));
test0(S("abcde"), '1', S("abcde1"));
test0(S("abcdefghij"), '1', S("abcdefghij1"));
test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1(S(""), '1', S("1"));
test1(S("abcde"), '1', S("abcde1"));
test1(S("abcdefghij"), '1', S("abcdefghij1"));
test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0(S(""), '1', S("1"));
test0(S("abcde"), '1', S("abcde1"));
test0(S("abcdefghij"), '1', S("abcdefghij1"));
test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test1(S(""), '1', S("1"));
test1(S("abcde"), '1', S("abcde1"));
test1(S("abcdefghij"), '1', S("abcdefghij1"));
test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
}
#endif
}

View File

@@ -21,29 +21,23 @@
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
void
test0(const S& lhs, const typename S::value_type* rhs, const S& x)
{
assert(lhs + rhs == x);
void test0(const S& lhs, const typename S::value_type* rhs, const S& x) {
assert(lhs + rhs == x);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if TEST_STD_VER >= 11
template <class S>
void
test1(S&& lhs, const typename S::value_type* rhs, const S& x)
{
assert(move(lhs) + rhs == x);
void test1(S&& lhs, const typename S::value_type* rhs, const S& x) {
assert(move(lhs) + rhs == x);
}
#endif
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
int main()
{
{
int main() {
{
typedef std::string S;
test0(S(""), "", S(""));
test0(S(""), "12345", S("12345"));
@@ -56,14 +50,18 @@ int main()
test0(S("abcdefghij"), "", S("abcdefghij"));
test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
test0(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test0(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1(S(""), "", S(""));
test1(S(""), "12345", S("12345"));
test1(S(""), "1234567890", S("1234567890"));
@@ -75,17 +73,19 @@ int main()
test1(S("abcdefghij"), "", S("abcdefghij"));
test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
test1(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test1(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0(S(""), "", S(""));
test0(S(""), "12345", S("12345"));
test0(S(""), "1234567890", S("1234567890"));
@@ -97,13 +97,14 @@ int main()
test0(S("abcdefghij"), "", S("abcdefghij"));
test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
test0(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test0(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
test1(S(""), "", S(""));
test1(S(""), "12345", S("12345"));
@@ -116,13 +117,14 @@ int main()
test1(S("abcdefghij"), "", S("abcdefghij"));
test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
test1(S("abcdefghij"), "12345678901234567890",
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
test1(S("abcdefghijklmnopqrst"), "1234567890",
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), "12345678901234567890",
S("abcdefghijklmnopqrst12345678901234567890"));
}
#endif
}

View File

@@ -33,43 +33,34 @@
#include <utility>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
template <class S>
void
test0(const S& lhs, const S& rhs, const S& x)
{
assert(lhs + rhs == x);
void test0(const S& lhs, const S& rhs, const S& x) {
assert(lhs + rhs == x);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if TEST_STD_VER >= 11
template <class S>
void
test1(S&& lhs, const S& rhs, const S& x)
{
assert(move(lhs) + rhs == x);
void test1(S&& lhs, const S& rhs, const S& x) {
assert(move(lhs) + rhs == x);
}
template <class S>
void
test2(const S& lhs, S&& rhs, const S& x)
{
assert(lhs + move(rhs) == x);
void test2(const S& lhs, S&& rhs, const S& x) {
assert(lhs + move(rhs) == x);
}
template <class S>
void
test3(S&& lhs, S&& rhs, const S& x)
{
assert(move(lhs) + move(rhs) == x);
void test3(S&& lhs, S&& rhs, const S& x) {
assert(move(lhs) + move(rhs) == x);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif
int main()
{
{
int main() {
{
typedef std::string S;
test0(S(""), S(""), S(""));
test0(S(""), S("12345"), S("12345"));
@@ -78,18 +69,24 @@ int main()
test0(S("abcde"), S(""), S("abcde"));
test0(S("abcde"), S("12345"), S("abcde12345"));
test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test0(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test0(S("abcdefghij"), S(""), S("abcdefghij"));
test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test0(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test0(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#if TEST_STD_VER >= 11
{
typedef std::string S;
test1(S(""), S(""), S(""));
test1(S(""), S("12345"), S("12345"));
test1(S(""), S("1234567890"), S("1234567890"));
@@ -97,15 +94,20 @@ int main()
test1(S("abcde"), S(""), S("abcde"));
test1(S("abcde"), S("12345"), S("abcde12345"));
test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test1(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test1(S("abcdefghij"), S(""), S("abcdefghij"));
test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test1(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test2(S(""), S(""), S(""));
test2(S(""), S("12345"), S("12345"));
@@ -114,15 +116,20 @@ int main()
test2(S("abcde"), S(""), S("abcde"));
test2(S("abcde"), S("12345"), S("abcde12345"));
test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test2(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test2(S("abcdefghij"), S(""), S("abcdefghij"));
test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test2(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test2(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test3(S(""), S(""), S(""));
test3(S(""), S("12345"), S("12345"));
@@ -131,21 +138,25 @@ int main()
test3(S("abcde"), S(""), S("abcde"));
test3(S("abcde"), S("12345"), S("abcde12345"));
test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test3(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test3(S("abcdefghij"), S(""), S("abcdefghij"));
test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test3(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#if TEST_STD_VER >= 11
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
test3(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test3(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
{
typedef std::basic_string<char, std::char_traits<char>,
min_allocator<char> >
S;
test0(S(""), S(""), S(""));
test0(S(""), S("12345"), S("12345"));
test0(S(""), S("1234567890"), S("1234567890"));
@@ -153,17 +164,20 @@ int main()
test0(S("abcde"), S(""), S("abcde"));
test0(S("abcde"), S("12345"), S("abcde12345"));
test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test0(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test0(S("abcdefghij"), S(""), S("abcdefghij"));
test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test0(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
test0(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test0(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test1(S(""), S(""), S(""));
test1(S(""), S("12345"), S("12345"));
@@ -172,15 +186,20 @@ int main()
test1(S("abcde"), S(""), S("abcde"));
test1(S("abcde"), S("12345"), S("abcde12345"));
test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test1(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test1(S("abcdefghij"), S(""), S("abcdefghij"));
test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test1(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test1(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test2(S(""), S(""), S(""));
test2(S(""), S("12345"), S("12345"));
@@ -189,15 +208,20 @@ int main()
test2(S("abcde"), S(""), S("abcde"));
test2(S("abcde"), S("12345"), S("abcde12345"));
test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test2(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test2(S("abcdefghij"), S(""), S("abcdefghij"));
test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test2(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test2(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
test3(S(""), S(""), S(""));
test3(S(""), S("12345"), S("12345"));
@@ -206,17 +230,20 @@ int main()
test3(S("abcde"), S(""), S("abcde"));
test3(S("abcde"), S("12345"), S("abcde12345"));
test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
test3(S("abcde"), S("12345678901234567890"),
S("abcde12345678901234567890"));
test3(S("abcdefghij"), S(""), S("abcdefghij"));
test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
test3(S("abcdefghij"), S("12345678901234567890"),
S("abcdefghij12345678901234567890"));
test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
#endif
test3(S("abcdefghijklmnopqrst"), S("12345"),
S("abcdefghijklmnopqrst12345"));
test3(S("abcdefghijklmnopqrst"), S("1234567890"),
S("abcdefghijklmnopqrst1234567890"));
test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"),
S("abcdefghijklmnopqrst12345678901234567890"));
}
#endif // TEST_STD_VER >= 11
}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// The strings's value type must be the same as the traits's char_type
#include <string>
int main()
{
std::basic_string<char, std::char_traits<wchar_t>> s;
}