diff options
Diffstat (limited to 'test/std/strings/basic.string/string.modifiers/string_append')
10 files changed, 0 insertions, 1060 deletions
diff --git a/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp deleted file mode 100644 index fcd18b7f05be..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp +++ /dev/null @@ -1,200 +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& append(const T& t, size_type pos, size_type n=npos); // C++17 - -#include <string> -#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.append(sv, pos, n); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.append(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.append(sv, pos); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.append(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("12345")); - test(S("12345"), SV("12345"), 2, 2, S("1234534")); - test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } -#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("12345")); - test(S("12345"), SV("12345"), 2, 2, S("1234534")); - test(S("12345"), SV("1234567890"), 0, 100, S("123451234567890")); - - test(S("12345678901234567890"), SV(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), SV("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } -#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; - std::string_view sv = "EFGH"; - char arr[] = "IJKL"; - - s.append("CDEF", 0); // calls append(const char *, len) - assert(s == ""); - s.clear(); - - s.append("QRST", 0, std::string::npos); // calls append(string("QRST"), pos, npos) - assert(s == "QRST"); - s.clear(); - - s.append(sv, 0); // calls append(T, pos, npos) - assert(s == sv); - s.clear(); - - s.append(sv, 0, std::string::npos); // calls append(T, pos, npos) - assert(s == sv); - s.clear(); - - s.append(arr, 0); // calls append(const char *, len) - assert(s == ""); - s.clear(); - - s.append(arr, 0, std::string::npos); // calls append(string("IJKL"), pos, npos) - assert(s == "IJKL"); - s.clear(); - - s.append(arr, 0); // calls append(const char *, len) - assert(s == ""); - s.clear(); - } - - { - std::string s = "ABCD"; - std::string_view sv = s; - s.append(sv); - assert(s == "ABCDABCD"); - - sv = s; - s.append(sv, 0, std::string::npos); - assert(s == "ABCDABCDABCDABCD"); - - sv = s; - s.append(sv, sv.size()); - assert(s == "ABCDABCDABCDABCD"); - } - - { - std::string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - std::string_view sv = s; - s.append(sv); - assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); - - sv = s; - s.append(sv, 0, std::string::npos); - assert(s == "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp deleted file mode 100644 index d30ca44695a8..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/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& append(initializer_list<charT> il); - -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -int main() -{ - { - std::string s("123"); - s.append({'a', 'b', 'c'}); - assert(s == "123abc"); - } - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - S s("123"); - s.append({'a', 'b', 'c'}); - assert(s == "123abc"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp deleted file mode 100644 index 7ed55403927e..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp +++ /dev/null @@ -1,223 +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& append(InputIterator first, InputIterator last); - -#include <string> -#include <cassert> - -#include "test_iterators.h" -#include "min_allocator.h" - -template <class S, class It> -void -test(S s, It first, It last, S expected) -{ - s.append(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.append(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("12345")); - test(S("12345"), s, s+1, S("12345A")); - test(S("12345"), s, s+10, S("12345ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S("1234567890")); - test(S("1234567890"), s, s+1, S("1234567890A")); - test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S("12345678901234567890")); - test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A")); - test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("12345678901234567890""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("12345")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("12345A")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("12345ABCDEFGHIJ")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S("1234567890")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("1234567890A")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S("12345678901234567890")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("12345678901234567890""A")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("12345678901234567890""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("12345")); - test(S("12345"), s, s+1, S("12345A")); - test(S("12345"), s, s+10, S("12345ABCDEFGHIJ")); - test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), s, s, S("1234567890")); - test(S("1234567890"), s, s+1, S("1234567890A")); - test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), s, s, S("12345678901234567890")); - test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A")); - test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), s, s+52, - S("12345678901234567890""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("12345")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("12345A")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("12345ABCDEFGHIJ")); - test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S("1234567890")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("1234567890A")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("1234567890ABCDEFGHIJ")); - test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); - - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s), - S("12345678901234567890")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1), - S("12345678901234567890""A")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10), - S("12345678901234567890""ABCDEFGHIJ")); - test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52), - S("12345678901234567890""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 appending to self - typedef std::string S; - S s_short = "123/"; - S s_long = "Lorem ipsum dolor sit amet, consectetur/"; - - s_short.append(s_short.begin(), s_short.end()); - assert(s_short == "123/123/"); - s_short.append(s_short.begin(), s_short.end()); - assert(s_short == "123/123/123/123/"); - s_short.append(s_short.begin(), s_short.end()); - assert(s_short == "123/123/123/123/123/123/123/123/"); - - s_long.append(s_long.begin(), s_long.end()); - assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/"); - } - - { // test appending a different type - typedef std::string S; - const uint8_t p[] = "ABCD"; - - S s; - s.append(p, p + 4); - 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"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp deleted file mode 100644 index 823905df4a14..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp +++ /dev/null @@ -1,80 +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>& append(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.append(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("12345")); - test(S("12345"), "12345", S("1234512345")); - test(S("12345"), "1234567890", S("123451234567890")); - - test(S("12345678901234567890"), "", S("12345678901234567890")); - test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", - S("1234567890123456789012345678901234567890")); - } -#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("12345")); - test(S("12345"), "12345", S("1234512345")); - test(S("12345"), "1234567890", S("123451234567890")); - - test(S("12345678901234567890"), "", S("12345678901234567890")); - test(S("12345678901234567890"), "12345", S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", - S("1234567890123456789012345678901234567890")); - } -#endif - - { // test appending to self - typedef std::string S; - S s_short = "123/"; - S s_long = "Lorem ipsum dolor sit amet, consectetur/"; - - s_short.append(s_short.c_str()); - assert(s_short == "123/123/"); - s_short.append(s_short.c_str()); - assert(s_short == "123/123/123/123/"); - s_short.append(s_short.c_str()); - assert(s_short == "123/123/123/123/123/123/123/123/"); - - s_long.append(s_long.c_str()); - assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp deleted file mode 100644 index f09ec682e9f9..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/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>& -// append(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.append(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("12345")); - test(S("12345"), "12345", 5, S("1234512345")); - test(S("12345"), "1234567890", 10, S("123451234567890")); - - test(S("12345678901234567890"), "", 0, S("12345678901234567890")); - test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("1234567890123456789012345678901234567890")); - } -#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("12345")); - test(S("12345"), "12345", 5, S("1234512345")); - test(S("12345"), "1234567890", 10, S("123451234567890")); - - test(S("12345678901234567890"), "", 0, S("12345678901234567890")); - test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345")); - test(S("12345678901234567890"), "12345678901234567890", 20, - S("1234567890123456789012345678901234567890")); - } -#endif - - { // test appending to self - typedef std::string S; - S s_short = "123/"; - S s_long = "Lorem ipsum dolor sit amet, consectetur/"; - - s_short.append(s_short.data(), s_short.size()); - assert(s_short == "123/123/"); - s_short.append(s_short.data(), s_short.size()); - assert(s_short == "123/123/123/123/"); - s_short.append(s_short.data(), s_short.size()); - assert(s_short == "123/123/123/123/123/123/123/123/"); - - s_long.append(s_long.data(), s_long.size()); - assert(s_long == "Lorem ipsum dolor sit amet, consectetur/Lorem ipsum dolor sit amet, consectetur/"); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp deleted file mode 100644 index 38b68aa69042..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp +++ /dev/null @@ -1,60 +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> - -// void push_back(charT c) - -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -struct veryLarge -{ - long long a; - char b; -}; - -template <class S> -void -test(S s, typename S::value_type c, S expected) -{ - s.push_back(c); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -int main() -{ - { - typedef std::string S; - test(S(), 'a', S(1, 'a')); - test(S("12345"), 'a', S("12345a")); - test(S("12345678901234567890"), 'a', S("12345678901234567890a")); - } -#if TEST_STD_VER >= 11 - { - typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; - test(S(), 'a', S(1, 'a')); - test(S("12345"), 'a', S("12345a")); - test(S("12345678901234567890"), 'a', S("12345678901234567890a")); - } -#endif - - { -// https://bugs.llvm.org/show_bug.cgi?id=31454 - std::basic_string<veryLarge> s; - veryLarge vl = {}; - s.push_back(vl); - s.push_back(vl); - s.push_back(vl); - } -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp deleted file mode 100644 index 1610ab5a17d1..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/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>& -// append(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.append(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("12345")); - test(S("12345"), 1, 'a', S("12345a")); - test(S("12345"), 10, 'a', S("12345aaaaaaaaaa")); - - test(S("12345678901234567890"), 0, 'a', S("12345678901234567890")); - test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a")); - test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa")); - } -#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("12345")); - test(S("12345"), 1, 'a', S("12345a")); - test(S("12345"), 10, 'a', S("12345aaaaaaaaaa")); - - test(S("12345678901234567890"), 0, 'a', S("12345678901234567890")); - test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a")); - test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa")); - } -#endif -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp deleted file mode 100644 index b3704268a4b6..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/string.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>& -// append(const basic_string<charT,traits>& str); - -#include <string> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S> -void -test(S s, S str, S expected) -{ - s.append(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("12345")); - test(S("12345"), S("12345"), S("1234512345")); - test(S("12345"), S("1234567890"), S("123451234567890")); - test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), S(), S("1234567890")); - test(S("1234567890"), S("12345"), S("123456789012345")); - test(S("1234567890"), S("1234567890"), S("12345678901234567890")); - test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); - - test(S("12345678901234567890"), S(), S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } -#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("12345")); - test(S("12345"), S("12345"), S("1234512345")); - test(S("12345"), S("1234567890"), S("123451234567890")); - test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), S(), S("1234567890")); - test(S("1234567890"), S("12345"), S("123456789012345")); - test(S("1234567890"), S("1234567890"), S("12345678901234567890")); - test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890")); - - test(S("12345678901234567890"), S(), S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), S("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } -#endif - -#if TEST_STD_VER > 3 - { // LWG 2946 - std::string s; - s.append({"abc", 1}); - assert(s.size() == 1); - assert(s == "a"); - } -#endif -} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp deleted file mode 100644 index 588c15ab8d6a..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/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>& -// append(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.append(str, pos, n); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.append(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.append(str, pos); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); - } -#ifndef TEST_HAS_NO_EXCEPTIONS - else - { - try - { - s.append(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("12345")); - test(S("12345"), S("12345"), 2, 2, S("1234534")); - test(S("12345"), S("1234567890"), 0, 100, S("123451234567890")); - - test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } -#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("12345")); - test(S("12345"), S("12345"), 2, 2, S("1234534")); - test(S("12345"), S("1234567890"), 0, 100, S("123451234567890")); - - test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890")); - test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234")); - test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, - S("123456789012345678906789012345")); - } -#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_append/string_view.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp deleted file mode 100644 index 2d85b15fa373..000000000000 --- a/test/std/strings/basic.string/string.modifiers/string_append/string_view.pass.cpp +++ /dev/null @@ -1,83 +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>& -// append(basic_string_view<charT,traits> sv); - -#include <string> -#include <string_view> -#include <cassert> - -#include "test_macros.h" -#include "min_allocator.h" - -template <class S, class SV> -void -test(S s, SV sv, S expected) -{ - s.append(sv); - LIBCPP_ASSERT(s.__invariants()); - assert(s == expected); -} - -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("12345")); - test(S("12345"), SV("12345"), S("1234512345")); - test(S("12345"), SV("1234567890"), S("123451234567890")); - test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), SV(), S("1234567890")); - test(S("1234567890"), SV("12345"), S("123456789012345")); - test(S("1234567890"), SV("1234567890"), S("12345678901234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890")); - - test(S("12345678901234567890"), SV(), S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } -#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("12345")); - test(S("12345"), SV("12345"), S("1234512345")); - test(S("12345"), SV("1234567890"), S("123451234567890")); - test(S("12345"), SV("12345678901234567890"), S("1234512345678901234567890")); - - test(S("1234567890"), SV(), S("1234567890")); - test(S("1234567890"), SV("12345"), S("123456789012345")); - test(S("1234567890"), SV("1234567890"), S("12345678901234567890")); - test(S("1234567890"), SV("12345678901234567890"), S("123456789012345678901234567890")); - - test(S("12345678901234567890"), SV(), S("12345678901234567890")); - test(S("12345678901234567890"), SV("12345"), S("1234567890123456789012345")); - test(S("12345678901234567890"), SV("1234567890"), S("123456789012345678901234567890")); - test(S("12345678901234567890"), SV("12345678901234567890"), - S("1234567890123456789012345678901234567890")); - } -#endif -} |
