diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:01 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 18:01:01 +0000 |
| commit | b7332b04df5d50c92640c74cfeb138ecb7e3f7ae (patch) | |
| tree | b1b49faa0cab1482905e0cda6f0ee5d97e3fe08f /test/std/strings/basic.string/string.modifiers/string_assign | |
| parent | 6012fe9abb1f01b1b5b4ca908464804c21ff8602 (diff) | |
Notes
Diffstat (limited to 'test/std/strings/basic.string/string.modifiers/string_assign')
10 files changed, 0 insertions, 1109 deletions
diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp deleted file mode 100644 index bf51d816e86e..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp +++ /dev/null @@ -1,195 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template <class T> -// basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17 - -#include <string> -#include <stdexcept> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S, class SV> -void -test(S s, SV sv, typename S::size_type pos, typename S::size_type n, S expected) -{ - if (pos <= sv.size()) - { - s.assign(sv, pos, n); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.assign(sv, pos, n); - assert(false); - } - catch (std::out_of_range&) - { - assert(pos > sv.size()); - } - } -#endif -} - -template <class S, class SV> -void -test_npos(S s, SV sv, typename S::size_type pos, S expected) -{ - if (pos <= sv.size()) - { - s.assign(sv, pos); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.assign(sv, pos); - assert(false); - } - catch (std::out_of_range&) - { - assert(pos > sv.size()); - } - } -#endif -} - -int main() -{ - { - typedef std::string S; - typedef std::string_view SV; - test(S(), SV(), 0, 0, S()); - test(S(), SV(), 1, 0, S()); - test(S(), SV("12345"), 0, 3, S("123")); - test(S(), SV("12345"), 1, 4, S("2345")); - test(S(), SV("12345"), 3, 15, S("45")); - test(S(), SV("12345"), 5, 15, S("")); - test(S(), SV("12345"), 6, 15, S("not happening")); - test(S(), SV("12345678901234567890"), 0, 0, S()); - test(S(), SV("12345678901234567890"), 1, 1, S("2")); - test(S(), SV("12345678901234567890"), 2, 3, S("345")); - test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); - test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), SV(), 0, 0, S()); - test(S("12345"), SV("12345"), 2, 2, S("34")); - test(S("12345"), SV("1234567890"), 0, 100, S("1234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S()); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("6789012345")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string <char, std::char_traits<char>, min_allocator<char>> S; - typedef std::basic_string_view<char, std::char_traits<char> > SV; - test(S(), SV(), 0, 0, S()); - test(S(), SV(), 1, 0, S()); - test(S(), SV("12345"), 0, 3, S("123")); - test(S(), SV("12345"), 1, 4, S("2345")); - test(S(), SV("12345"), 3, 15, S("45")); - test(S(), SV("12345"), 5, 15, S("")); - test(S(), SV("12345"), 6, 15, S("not happening")); - test(S(), SV("12345678901234567890"), 0, 0, S()); - test(S(), SV("12345678901234567890"), 1, 1, S("2")); - test(S(), SV("12345678901234567890"), 2, 3, S("345")); - test(S(), SV("12345678901234567890"), 12, 13, S("34567890")); - test(S(), SV("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), SV(), 0, 0, S()); - test(S("12345"), SV("12345"), 2, 2, S("34")); - test(S("12345"), SV("1234567890"), 0, 100, S("1234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S()); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("6789012345")); - } -#endif - { - typedef std::string S; - typedef std::string_view SV; - test_npos(S(), SV(), 0, S()); - test_npos(S(), SV(), 1, S()); - test_npos(S(), SV("12345"), 0, S("12345")); - test_npos(S(), SV("12345"), 1, S("2345")); - test_npos(S(), SV("12345"), 3, S("45")); - test_npos(S(), SV("12345"), 5, S("")); - test_npos(S(), SV("12345"), 6, S("not happening")); - } - - { - std::string s = "ABCD"; - std::string_view sv = "EFGH"; - char arr[] = "IJKL"; - - s.assign("CDEF", 0); // calls assign(const char *, len) - assert(s == ""); - s.clear(); - - s.assign("QRST", 0, std::string::npos); // calls assign(string("QRST", pos, len) - assert(s == "QRST"); - s.clear(); - - s.assign(sv, 0); // calls assign(T, pos, npos) - assert(s == sv); - s.clear(); - - s.assign(sv, 0, std::string::npos); // calls assign(T, pos, npos) - assert(s == sv); - s.clear(); - - s.assign(arr, 0); // calls assign(const char *, len) - assert(s == ""); - s.clear(); - - s.assign(arr, 0, std::string::npos); // calls assign(string("IJKL"), pos, npos) - assert(s == "IJKL"); - s.clear(); - - s.assign(arr, 0); // calls assign(const char *, len) - assert(s == ""); - s.clear(); - } - - { - std::string s = "ABCD"; - std::string_view sv = s; - s.assign(sv); - assert(s == "ABCD"); - - sv = s; - s.assign(sv, 0, std::string::npos); - assert(s == "ABCD"); - } - - { - std::string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - std::string_view sv = s; - s.assign(sv); - assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - - sv = s; - s.assign(sv, 0, std::string::npos); - assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp deleted file mode 100644 index a2114cf5a83b..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03 - -// <string> - -// basic_string& assign(initializer_list<charT> il); - -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -int main() -{ - { - std::string s("123"); - s.assign({'a', 'b', 'c'}); - assert(s == "abc"); - } - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - S s("123"); - s.assign({'a', 'b', 'c'}); - assert(s == "abc"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp deleted file mode 100644 index cb83f25d7117..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp +++ /dev/null @@ -1,208 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<class InputIterator> -// basic_string& assign(InputIterator first, InputIterator last); - -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "test_iterators.h" -#include "min_allocator.h" - -template <class S, class It> -void -test(S s, It first, It last, S expected) -{ - s.assign(first, last); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -#ifndef TEST_HAS_NO_EXCEPTIONS -template <class S, class It> -void -test_exceptions(S s, It first, It last) -{ - S aCopy = s; - try { - s.assign(first, last); - assert(false); - } - catch (...) {} - LIBCPP_ASSERT(s.__invariants()); - assert(s == aCopy); -} -#endif - -int main() -{ - { - typedef std::string S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), s, s, S()); - test(S(), s, s+1, S("A")); - test(S(), s, s+10, S("ABCDEFGHIJ")); - test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), s, s, S()); - test(S("12345"), s, s+1, S("A")); - test(S("12345"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S()); - test(S("1234567890"), s, s+1, S("A")); - test(S("1234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S()); - test(S("12345678901234567890"), s, s+1, S("A")); - test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S()); - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A")); - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S()); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("A")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S()); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("A")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S()); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("A")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test(S(), s, s, S()); - test(S(), s, s+1, S("A")); - test(S(), s, s+10, S("ABCDEFGHIJ")); - test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), s, s, S()); - test(S("12345"), s, s+1, S("A")); - test(S("12345"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S()); - test(S("1234567890"), s, s+1, S("A")); - test(S("1234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S()); - test(S("12345678901234567890"), s, s+1, S("A")); - test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S()); - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A")); - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S()); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("A")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S()); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("A")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S()); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("A")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("ABCDEFGHIJ")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - } -#endif -#ifndef TEST_HAS_NO_EXCEPTIONS - { // test iterator operations that throw - typedef std::string S; - typedef ThrowingIterator<char> TIter; - typedef input_iterator<TIter> IIter; - const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - test_exceptions(S(), IIter(TIter(s, s+10, 4, TIter::TAIncrement)), IIter()); - test_exceptions(S(), IIter(TIter(s, s+10, 5, TIter::TADereference)), IIter()); - test_exceptions(S(), IIter(TIter(s, s+10, 6, TIter::TAComparison)), IIter()); - - test_exceptions(S(), TIter(s, s+10, 4, TIter::TAIncrement), TIter()); - test_exceptions(S(), TIter(s, s+10, 5, TIter::TADereference), TIter()); - test_exceptions(S(), TIter(s, s+10, 6, TIter::TAComparison), TIter()); - } -#endif - - { // test assigning to self - typedef std::string S; - S s_short = "123/"; - S s_long = "Lorem ipsum dolor sit amet, consectetur/"; - - s_short.assign(s_short.begin(), s_short.end()); - assert(s_short == "123/"); - s_short.assign(s_short.begin() + 2, s_short.end()); - assert(s_short == "3/"); - - s_long.assign(s_long.begin(), s_long.end()); - assert(s_long == "Lorem ipsum dolor sit amet, consectetur/"); - - s_long.assign(s_long.begin() + 30, s_long.end()); - assert(s_long == "nsectetur/"); - } - - { // test assigning a different type - typedef std::string S; - const uint8_t p[] = "ABCD"; - - S s; - s.assign(p, p + 4); - assert(s == "ABCD"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp deleted file mode 100644 index b592455a350e..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// basic_string<charT,traits,Allocator>& assign(const charT* s); - -#include <string> -#include <stdexcept> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S> -void -test(S s, const typename S::value_type* str, S expected) -{ - s.assign(str); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -int main() -{ - { - typedef std::string S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "12345678901234567890", S("12345678901234567890")); - - test(S("12345"), "", S()); - test(S("12345"), "12345", S("12345")); - test(S("12345"), "1234567890", S("1234567890")); - - test(S("12345678901234567890"), "", S()); - test(S("12345678901234567890"), "12345", S("12345")); - test(S("12345678901234567890"), "12345678901234567890", - S("12345678901234567890")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - test(S(), "", S()); - test(S(), "12345", S("12345")); - test(S(), "12345678901234567890", S("12345678901234567890")); - - test(S("12345"), "", S()); - test(S("12345"), "12345", S("12345")); - test(S("12345"), "1234567890", S("1234567890")); - - test(S("12345678901234567890"), "", S()); - test(S("12345678901234567890"), "12345", S("12345")); - test(S("12345678901234567890"), "12345678901234567890", - S("12345678901234567890")); - } -#endif - - { // test assignment to self - typedef std::string S; - S s_short = "123/"; - S s_long = "Lorem ipsum dolor sit amet, consectetur/"; - - s_short.assign(s_short.c_str()); - assert(s_short == "123/"); - s_short.assign(s_short.c_str() + 2); - assert(s_short == "3/"); - - s_long.assign(s_long.c_str() + 30); - assert(s_long == "nsectetur/"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp deleted file mode 100644 index 70b00619a913..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// basic_string<charT,traits,Allocator>& -// assign(const charT* s, size_type n); - -#include <string> -#include <stdexcept> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S> -void -test(S s, const typename S::value_type* str, typename S::size_type n, S expected) -{ - s.assign(str, n); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -int main() -{ - { - typedef std::string S; - test(S(), "", 0, S()); - test(S(), "12345", 3, S("123")); - test(S(), "12345", 4, S("1234")); - test(S(), "12345678901234567890", 0, S()); - test(S(), "12345678901234567890", 1, S("1")); - test(S(), "12345678901234567890", 3, S("123")); - test(S(), "12345678901234567890", 20, S("12345678901234567890")); - - test(S("12345"), "", 0, S()); - test(S("12345"), "12345", 5, S("12345")); - test(S("12345"), "1234567890", 10, S("1234567890")); - - test(S("12345678901234567890"), "", 0, S()); - test(S("12345678901234567890"), "12345", 5, S("12345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("12345678901234567890")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - test(S(), "", 0, S()); - test(S(), "12345", 3, S("123")); - test(S(), "12345", 4, S("1234")); - test(S(), "12345678901234567890", 0, S()); - test(S(), "12345678901234567890", 1, S("1")); - test(S(), "12345678901234567890", 3, S("123")); - test(S(), "12345678901234567890", 20, S("12345678901234567890")); - - test(S("12345"), "", 0, S()); - test(S("12345"), "12345", 5, S("12345")); - test(S("12345"), "1234567890", 10, S("1234567890")); - - test(S("12345678901234567890"), "", 0, S()); - test(S("12345678901234567890"), "12345", 5, S("12345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("12345678901234567890")); - } -#endif - { // test assign to self - typedef std::string S; - S s_short = "123/"; - S s_long = "Lorem ipsum dolor sit amet, consectetur/"; - - s_short.assign(s_short.data(), s_short.size()); - assert(s_short == "123/"); - s_short.assign(s_short.data() + 2, s_short.size() - 2); - assert(s_short == "3/"); - - s_long.assign(s_long.data(), s_long.size()); - assert(s_long == "Lorem ipsum dolor sit amet, consectetur/"); - - s_long.assign(s_long.data() + 2, 8 ); - assert(s_long == "rem ipsu"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp deleted file mode 100644 index 6b89df98de72..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp +++ /dev/null @@ -1,81 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// basic_string<charT,traits,Allocator>& -// assign(basic_string<charT,traits>&& str); - -#include <string> -#include <utility> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S> -void -test(S s, S str, S expected) -{ - s.assign(std::move(str)); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -int main() -{ - { - typedef std::string S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S()); - test(S("12345"), S("12345"), S("12345")); - test(S("12345"), S("1234567890"), S("1234567890")); - test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), S(), S()); - test(S("1234567890"), S("12345"), S("12345")); - test(S("1234567890"), S("1234567890"), S("1234567890")); - test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), S(), S()); - test(S("12345678901234567890"), S("12345"), S("12345")); - test(S("12345678901234567890"), S("1234567890"), S("1234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("12345678901234567890")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S()); - test(S("12345"), S("12345"), S("12345")); - test(S("12345"), S("1234567890"), S("1234567890")); - test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), S(), S()); - test(S("1234567890"), S("12345"), S("12345")); - test(S("1234567890"), S("1234567890"), S("1234567890")); - test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), S(), S()); - test(S("12345678901234567890"), S("12345"), S("12345")); - test(S("12345678901234567890"), S("1234567890"), S("1234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("12345678901234567890")); - } -#endif -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp deleted file mode 100644 index a899e0dbe7b5..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp +++ /dev/null @@ -1,64 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// basic_string<charT,traits,Allocator>& -// assign(size_type n, charT c); - -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S> -void -test(S s, typename S::size_type n, typename S::value_type c, S expected) -{ - s.assign(n, c); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -int main() -{ - { - typedef std::string S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S(1, 'a')); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - - test(S("12345"), 0, 'a', S()); - test(S("12345"), 1, 'a', S(1, 'a')); - test(S("12345"), 10, 'a', S(10, 'a')); - - test(S("12345678901234567890"), 0, 'a', S()); - test(S("12345678901234567890"), 1, 'a', S(1, 'a')); - test(S("12345678901234567890"), 10, 'a', S(10, 'a')); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - test(S(), 0, 'a', S()); - test(S(), 1, 'a', S(1, 'a')); - test(S(), 10, 'a', S(10, 'a')); - test(S(), 100, 'a', S(100, 'a')); - - test(S("12345"), 0, 'a', S()); - test(S("12345"), 1, 'a', S(1, 'a')); - test(S("12345"), 10, 'a', S(10, 'a')); - - test(S("12345678901234567890"), 0, 'a', S()); - test(S("12345678901234567890"), 1, 'a', S(1, 'a')); - test(S("12345678901234567890"), 10, 'a', S(10, 'a')); - } -#endif -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp deleted file mode 100644 index 788512ba3d3e..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp +++ /dev/null @@ -1,117 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// basic_string<charT,traits,Allocator>& -// assign(const basic_string<charT,traits>& str); - -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" -#include "test_allocator.h" - -template <class S> -void -test(S s, S str, S expected) -{ - s.assign(str); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -template <class S> -void -testAlloc(S s, S str, const typename S::allocator_type& a) -{ - s.assign(str); - LIBCPP_ASSERT(s.__invariants()); - assert(s == str); - assert(s.get_allocator() == a); -} - -int main() -{ - { - typedef std::string S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S()); - test(S("12345"), S("12345"), S("12345")); - test(S("12345"), S("1234567890"), S("1234567890")); - test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), S(), S()); - test(S("1234567890"), S("12345"), S("12345")); - test(S("1234567890"), S("1234567890"), S("1234567890")); - test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), S(), S()); - test(S("12345678901234567890"), S("12345"), S("12345")); - test(S("12345678901234567890"), S("1234567890"), S("1234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("12345678901234567890")); - - testAlloc(S(), S(), std::allocator<char>()); - testAlloc(S(), S("12345"), std::allocator<char>()); - testAlloc(S(), S("1234567890"), std::allocator<char>()); - testAlloc(S(), S("12345678901234567890"), std::allocator<char>()); - } - - { // LWG#5579 make sure assign takes the allocators where appropriate - typedef other_allocator<char> A; // has POCCA --> true - typedef std::basic_string<char, std::char_traits<char>, A> S; - testAlloc(S(A(5)), S(A(3)), A(3)); - testAlloc(S(A(5)), S("1"), A()); - testAlloc(S(A(5)), S("1", A(7)), A(7)); - testAlloc(S(A(5)), S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), A(7)); - } - -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - test(S(), S(), S()); - test(S(), S("12345"), S("12345")); - test(S(), S("1234567890"), S("1234567890")); - test(S(), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), S(), S()); - test(S("12345"), S("12345"), S("12345")); - test(S("12345"), S("1234567890"), S("1234567890")); - test(S("12345"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), S(), S()); - test(S("1234567890"), S("12345"), S("12345")); - test(S("1234567890"), S("1234567890"), S("1234567890")); - test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), S(), S()); - test(S("12345678901234567890"), S("12345"), S("12345")); - test(S("12345678901234567890"), S("1234567890"), S("1234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("12345678901234567890")); - - testAlloc(S(), S(), min_allocator<char>()); - testAlloc(S(), S("12345"), min_allocator<char>()); - testAlloc(S(), S("1234567890"), min_allocator<char>()); - testAlloc(S(), S("12345678901234567890"), min_allocator<char>()); - } -#endif -#if TEST_STD_VER > 14 - { - typedef std::string S; - static_assert(noexcept(S().assign(S())), ""); // LWG#2063 - } -#endif -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp deleted file mode 100644 index 2ad37f311de5..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp +++ /dev/null @@ -1,137 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// basic_string<charT,traits,Allocator>& -// assign(const basic_string<charT,traits>& str, size_type pos, size_type n=npos); -// the =npos was added for C++14 - -#include <string> -#include <stdexcept> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S> -void -test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected) -{ - if (pos <= str.size()) - { - s.assign(str, pos, n); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.assign(str, pos, n); - assert(false); - } - catch (std::out_of_range&) - { - assert(pos > str.size()); - } - } -#endif -} - -template <class S> -void -test_npos(S s, S str, typename S::size_type pos, S expected) -{ - if (pos <= str.size()) - { - s.assign(str, pos); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.assign(str, pos); - assert(false); - } - catch (std::out_of_range&) - { - assert(pos > str.size()); - } - } -#endif -} - -int main() -{ - { - typedef std::string S; - test(S(), S(), 0, 0, S()); - test(S(), S(), 1, 0, S()); - test(S(), S("12345"), 0, 3, S("123")); - test(S(), S("12345"), 1, 4, S("2345")); - test(S(), S("12345"), 3, 15, S("45")); - test(S(), S("12345"), 5, 15, S("")); - test(S(), S("12345"), 6, 15, S("not happening")); - test(S(), S("12345678901234567890"), 0, 0, S()); - test(S(), S("12345678901234567890"), 1, 1, S("2")); - test(S(), S("12345678901234567890"), 2, 3, S("345")); - test(S(), S("12345678901234567890"), 12, 13, S("34567890")); - test(S(), S("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), S(), 0, 0, S()); - test(S("12345"), S("12345"), 2, 2, S("34")); - test(S("12345"), S("1234567890"), 0, 100, S("1234567890")); - - test(S("12345678901234567890"), S(), 0, 0, S()); - test(S("12345678901234567890"), S("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("6789012345")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - test(S(), S(), 0, 0, S()); - test(S(), S(), 1, 0, S()); - test(S(), S("12345"), 0, 3, S("123")); - test(S(), S("12345"), 1, 4, S("2345")); - test(S(), S("12345"), 3, 15, S("45")); - test(S(), S("12345"), 5, 15, S("")); - test(S(), S("12345"), 6, 15, S("not happening")); - test(S(), S("12345678901234567890"), 0, 0, S()); - test(S(), S("12345678901234567890"), 1, 1, S("2")); - test(S(), S("12345678901234567890"), 2, 3, S("345")); - test(S(), S("12345678901234567890"), 12, 13, S("34567890")); - test(S(), S("12345678901234567890"), 21, 13, S("not happening")); - - test(S("12345"), S(), 0, 0, S()); - test(S("12345"), S("12345"), 2, 2, S("34")); - test(S("12345"), S("1234567890"), 0, 100, S("1234567890")); - - test(S("12345678901234567890"), S(), 0, 0, S()); - test(S("12345678901234567890"), S("12345"), 1, 3, S("234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("6789012345")); - } -#endif - { - typedef std::string S; - test_npos(S(), S(), 0, S()); - test_npos(S(), S(), 1, S()); - test_npos(S(), S("12345"), 0, S("12345")); - test_npos(S(), S("12345"), 1, S("2345")); - test_npos(S(), S("12345"), 3, S("45")); - test_npos(S(), S("12345"), 5, S("")); - test_npos(S(), S("12345"), 6, S("not happening")); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp deleted file mode 100644 index e56b094a36e9..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_assign/string_view.pass.cpp +++ /dev/null @@ -1,105 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// basic_string<charT,traits,Allocator>& -// assign(basic_string_view<charT,traits> sv); - -#include <string> -#include <string_view> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" -#include "test_allocator.h" - -template <class S, class SV> -void -test(S s, SV sv, S expected) -{ - s.assign(sv); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -template <class S, class SV> -void -testAlloc(S s, SV sv, const typename S::allocator_type& a) -{ - s.assign(sv); - LIBCPP_ASSERT(s.__invariants()); - assert(s == sv); - assert(s.get_allocator() == a); -} - -int main() -{ - { - typedef std::string S; - typedef std::string_view SV; - test(S(), SV(), S()); - test(S(), SV("12345"), S("12345")); - test(S(), SV("1234567890"), S("1234567890")); - test(S(), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), SV(), S()); - test(S("12345"), SV("12345"), S("12345")); - test(S("12345"), SV("1234567890"), S("1234567890")); - test(S("12345"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), SV(), S()); - test(S("1234567890"), SV("12345"), S("12345")); - test(S("1234567890"), SV("1234567890"), S("1234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), SV(), S()); - test(S("12345678901234567890"), SV("12345"), S("12345")); - test(S("12345678901234567890"), SV("1234567890"), S("1234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("12345678901234567890")); - - testAlloc(S(), SV(), std::allocator<char>()); - testAlloc(S(), SV("12345"), std::allocator<char>()); - testAlloc(S(), SV("1234567890"), std::allocator<char>()); - testAlloc(S(), SV("12345678901234567890"), std::allocator<char>()); - } - -#if TEST_STD_VER >= 11 - { - typedef std::basic_string <char, std::char_traits<char>, min_allocator<char>> S; - typedef std::basic_string_view<char, std::char_traits<char> > SV; - test(S(), SV(), S()); - test(S(), SV("12345"), S("12345")); - test(S(), SV("1234567890"), S("1234567890")); - test(S(), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345"), SV(), S()); - test(S("12345"), SV("12345"), S("12345")); - test(S("12345"), SV("1234567890"), S("1234567890")); - test(S("12345"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("1234567890"), SV(), S()); - test(S("1234567890"), SV("12345"), S("12345")); - test(S("1234567890"), SV("1234567890"), S("1234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("12345678901234567890")); - - test(S("12345678901234567890"), SV(), S()); - test(S("12345678901234567890"), SV("12345"), S("12345")); - test(S("12345678901234567890"), SV("1234567890"), S("1234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("12345678901234567890")); - - testAlloc(S(), SV(), min_allocator<char>()); - testAlloc(S(), SV("12345"), min_allocator<char>()); - testAlloc(S(), SV("1234567890"), min_allocator<char>()); - testAlloc(S(), SV("12345678901234567890"), min_allocator<char>()); - } -#endif -} |
