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

@@ -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
}