+2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * testsuite/21_strings/basic_string/append/*: Move inside
+ testsuite/21_strings/basic_string/modifiers/.
+ * testsuite/21_strings/basic_string/assign/*: Likewise.
+ * testsuite/21_strings/basic_string/insert/*: Likewise.
+ * testsuite/21_strings/basic_string/replace/*: Likewise.
+ * testsuite/21_strings/basic_string/modifiers/pop_back/char/
+ pop_back.cc: Rename to 1.cc.
+ * testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/
+ pop_back.cc: Likewise.
+ * testsuite/ext/vstring/assign/*: Move inside
+ testsuite/ext/vstring/modifiers/.
+
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_deque.h (deque<>::insert(iterator,
+++ /dev/null
-// 1999-07-08 bkoz
-
-// Copyright (C) 1999-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.2 basic_string::append
-
-#include <string>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-bool test01(void)
-{
- bool test __attribute__((unused)) = true;
- typedef std::string::size_type csize_type;
- typedef std::string::const_reference cref;
- typedef std::string::reference ref;
- csize_type csz01;
-
- const char str_lit01[] = "point bolivar, texas";
- const std::string str01(str_lit01);
- const std::string str02("corpus, ");
- const std::string str03;
- std::string str05;
-
-
- // string& append(const string&)
- str05 = str02;
- str05.append(str05);
- VERIFY( str05 == "corpus, corpus, " );
- str05.append(str01);
- VERIFY( str05 == "corpus, corpus, point bolivar, texas" );
- str05.append(str03);
- VERIFY( str05 == "corpus, corpus, point bolivar, texas" );
- std::string str06;
- str06.append(str05);
- VERIFY( str06 == str05 );
-
-
- // string& append(const string&, size_type pos, size_type n)
- str05.erase();
- str06.erase();
- csz01 = str03.size();
- try {
- str06.append(str03, csz01 + 1, 0);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- csz01 = str01.size();
- try {
- str06.append(str01, csz01 + 1, 0);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- str05 = str02;
- str05.append(str01, 0, std::string::npos);
- VERIFY( str05 == "corpus, point bolivar, texas" );
- VERIFY( str05 != str02 );
-
- str06 = str02;
- str06.append(str01, 15, std::string::npos);
- VERIFY( str06 == "corpus, texas" );
- VERIFY( str02 != str06 );
-
-
- // string& append(const char* s)
- str05.erase();
- str06.erase();
- str05.append("");
- VERIFY( str05 == str03 );
-
- str05.append(str_lit01);
- VERIFY( str05 == str01 );
-
- str06 = str02;
- str06.append("corpus, ");
- VERIFY( str06 == "corpus, corpus, " );
-
-
- // string& append(const char* s, size_type n)
- str05.erase();
- str06.erase();
- str05.append("", 0);
- VERIFY( str05.size() == 0 );
- VERIFY( str05 == str03 );
-
- str05.append(str_lit01, sizeof(str_lit01) - 1);
- VERIFY( str05 == str01 );
-
- str06 = str02;
- str06.append("corpus, ", 6);
- VERIFY( str06 == "corpus, corpus" );
-
- str06 = str02;
- str06.append("corpus, ", 12);
- VERIFY( str06 != "corpus, corpus, " );
-
-
- // string& append(size_type n, char c)
- str05.erase();
- str06.erase();
- str05.append(0, 'a');
- VERIFY( str05 == str03 );
- str06.append(8, '.');
- VERIFY( str06 == "........" );
-
-
- // template<typename InputIter>
- // string& append(InputIter first, InputIter last)
- str05.erase();
- str06.erase();
- str05.append(str03.begin(), str03.end());
- VERIFY( str05 == str03 );
-
- str06 = str02;
- str06.append(str01.begin(), str01.begin() + str01.find('r'));
- VERIFY( str06 == "corpus, point boliva" );
- VERIFY( str06 != str01 );
- VERIFY( str06 != str02 );
-
- str05 = str01;
- str05.append(str05.begin(), str05.begin() + str05.find('r'));
- VERIFY( str05 == "point bolivar, texaspoint boliva" );
- VERIFY( str05 != str01 );
- return test;
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2004-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// append(const _CharT* __s, size_type __n)
-// append(const _CharT* __s)
-void
-test02()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- string one;
- string two;
- string three;
- const char * source = "Written in your eyes";
-
- one.append(source);
- VERIFY( one == "Written in your eyes" );
-
- two.append(source, 20);
- VERIFY( two == "Written in your eyes" );
-
- three.append(source, 7);
- VERIFY( three == "Written" );
-
- three.clear();
- three.append(source + 8, 2);
- VERIFY( three == "in" );
-
- one.append(one.c_str(), 20);
- VERIFY( one == "Written in your eyesWritten in your eyes" );
-
- two.append(two.c_str() + 16, 4);
- VERIFY( two == "Written in your eyeseyes" );
-
- two.append(two.c_str(), 3);
- VERIFY( two == "Written in your eyeseyesWri" );
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2004-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// Upon reallocation (basic_string::reserve) we were copying from
-// deallocated memory.
-void
-test03()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- const char * source = "Kesto";
-
- for (unsigned i = 0; i < 10; ++i)
- {
- string one(source);
- string two(source);
- for (unsigned j = 0; j < 18; ++j)
- {
- VERIFY( one == two );
- one.append(one);
- one += 'x';
- two.append(two.c_str(), two.size());
- two += 'x';
- }
- }
-}
-
-int main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// 1999-07-08 bkoz
-
-// Copyright (C) 1999-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.2 basic_string::append
-
-#include <string>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-bool test01(void)
-{
- bool test __attribute__((unused)) = true;
- typedef std::wstring::size_type csize_type;
- typedef std::wstring::const_reference cref;
- typedef std::wstring::reference ref;
- csize_type csz01;
-
- const wchar_t str_lit01[] = L"point bolivar, texas";
- const std::wstring str01(str_lit01);
- const std::wstring str02(L"corpus, ");
- const std::wstring str03;
- std::wstring str05;
-
-
- // wstring& append(const wstring&)
- str05 = str02;
- str05.append(str05);
- VERIFY( str05 == L"corpus, corpus, " );
- str05.append(str01);
- VERIFY( str05 == L"corpus, corpus, point bolivar, texas" );
- str05.append(str03);
- VERIFY( str05 == L"corpus, corpus, point bolivar, texas" );
- std::wstring str06;
- str06.append(str05);
- VERIFY( str06 == str05 );
-
-
- // wstring& append(const wstring&, size_type pos, size_type n)
- str05.erase();
- str06.erase();
- csz01 = str03.size();
- try {
- str06.append(str03, csz01 + 1, 0);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- csz01 = str01.size();
- try {
- str06.append(str01, csz01 + 1, 0);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- str05 = str02;
- str05.append(str01, 0, std::wstring::npos);
- VERIFY( str05 == L"corpus, point bolivar, texas" );
- VERIFY( str05 != str02 );
-
- str06 = str02;
- str06.append(str01, 15, std::wstring::npos);
- VERIFY( str06 == L"corpus, texas" );
- VERIFY( str02 != str06 );
-
-
- // wstring& append(const wchar_t* s)
- str05.erase();
- str06.erase();
- str05.append(L"");
- VERIFY( str05 == str03 );
-
- str05.append(str_lit01);
- VERIFY( str05 == str01 );
-
- str06 = str02;
- str06.append(L"corpus, ");
- VERIFY( str06 == L"corpus, corpus, " );
-
-
- // wstring& append(const wchar_t* s, size_type n)
- str05.erase();
- str06.erase();
- str05.append(L"", 0);
- VERIFY( str05.size() == 0 );
- VERIFY( str05 == str03 );
-
- str05.append(str_lit01, sizeof(str_lit01) / sizeof(wchar_t) - 1);
- VERIFY( str05 == str01 );
-
- str06 = str02;
- str06.append(L"corpus, ", 6);
- VERIFY( str06 == L"corpus, corpus" );
-
- str06 = str02;
- str06.append(L"corpus, ", 12);
- VERIFY( str06 != L"corpus, corpus, " );
-
-
- // wstring& append(size_type n, char c)
- str05.erase();
- str06.erase();
- str05.append(0, L'a');
- VERIFY( str05 == str03 );
- str06.append(8, L'.');
- VERIFY( str06 == L"........" );
-
-
- // template<typename InputIter>
- // wstring& append(InputIter first, InputIter last)
- str05.erase();
- str06.erase();
- str05.append(str03.begin(), str03.end());
- VERIFY( str05 == str03 );
-
- str06 = str02;
- str06.append(str01.begin(), str01.begin() + str01.find(L'r'));
- VERIFY( str06 == L"corpus, point boliva" );
- VERIFY( str06 != str01 );
- VERIFY( str06 != str02 );
-
- str05 = str01;
- str05.append(str05.begin(), str05.begin() + str05.find(L'r'));
- VERIFY( str05 == L"point bolivar, texaspoint boliva" );
- VERIFY( str05 != str01 );
- return test;
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2004-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// append(const _CharT* __s, size_type __n)
-// append(const _CharT* __s)
-void
-test02()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- wstring one;
- wstring two;
- wstring three;
- const wchar_t * source = L"Written in your eyes";
-
- one.append(source);
- VERIFY( one == L"Written in your eyes" );
-
- two.append(source, 20);
- VERIFY( two == L"Written in your eyes" );
-
- three.append(source, 7);
- VERIFY( three == L"Written" );
-
- three.clear();
- three.append(source + 8, 2);
- VERIFY( three == L"in" );
-
- one.append(one.c_str(), 20);
- VERIFY( one == L"Written in your eyesWritten in your eyes" );
-
- two.append(two.c_str() + 16, 4);
- VERIFY( two == L"Written in your eyeseyes" );
-
- two.append(two.c_str(), 3);
- VERIFY( two == L"Written in your eyeseyesWri" );
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2004-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-// { dg-options "-DITERATIONS=14" { target simulator } }
-
-#ifndef ITERATIONS
-#define ITERATIONS 18
-#endif
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// Upon reallocation (basic_string::reserve) we were copying from
-// deallocated memory.
-void
-test03()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- const wchar_t * source = L"Kesto";
-
- for (unsigned i = 0; i < 10; ++i)
- {
- wstring one(source);
- wstring two(source);
- for (unsigned j = 0; j < ITERATIONS; ++j)
- {
- VERIFY( one == two );
- one.append(one);
- one += L'x';
- two.append(two.c_str(), two.size());
- two += L'x';
- }
- }
-}
-
-int main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <cstdio>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii";
- string aux = strlit;
- string::size_type i = aux.rfind("/");
- if (i != string::npos)
- aux.assign(aux, i + 1, string::npos);
- VERIFY(aux == "Hawaii");
-
- aux = strlit;
- i = aux.rfind("r/");
- if (i != string::npos)
- aux.assign(aux, i + 1, string::npos);
- VERIFY(aux.c_str()[9] == 'B');
- VERIFY(aux == "/Hanalei Bay/Kauai/Hawaii");
-
- aux.assign(10, 0);
- VERIFY(aux.length() == 10);
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <cstdio>
-#include <testsuite_hooks.h>
-
-// assign(const basic_string& __str, size_type __pos, size_type __n)
-void
-test02()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- string one = "Selling England by the pound";
- string two = one;
- string three = "Brilliant trees";
-
- one.assign(one, 8, 100);
- VERIFY( one == "England by the pound" );
-
- one.assign(one, 8, 0);
- VERIFY( one == "" );
-
- one.assign(two, 8, 7);
- VERIFY( one == "England" );
-
- one.assign(three, 10, 100);
- VERIFY( one == "trees" );
-
- three.assign(one, 0, 3);
- VERIFY( three == "tre" );
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// assign(const _CharT* __s, size_type __n)
-// assign(const _CharT* __s)
-void
-test03()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- string one;
- string two;
- const char * source = "Selling England by the pound";
-
- one.assign(source);
- VERIFY( one == "Selling England by the pound" );
-
- one.assign(source, 28);
- VERIFY( one == "Selling England by the pound" );
-
- two.assign(source, 7);
- VERIFY( two == "Selling" );
-
- one.assign(one.c_str() + 8, 20);
- VERIFY( one == "England by the pound" );
-
- one.assign(one.c_str() + 8, 6);
- VERIFY( one == "by the" );
-}
-
-int main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// { dg-options "-std=gnu++0x" }
-// { dg-require-string-conversions "" }
-
-// Copyright (C) 2010-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// NOTE: This makes use of the fact that we know how moveable
-// is implemented on string (via swap). If the implementation changes
-// this test may begin to fail.
-
-#include <string>
-#include <utility>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- std::string a, b;
- a.push_back('1');
- b.assign(std::move(a));
- VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <cstdio>
-#include <testsuite_hooks.h>
-
-void
-test01()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii";
- wstring aux = strlit;
- wstring::size_type i = aux.rfind(L"/");
- if (i != wstring::npos)
- aux.assign(aux, i + 1, wstring::npos);
- VERIFY(aux == L"Hawaii");
-
- aux = strlit;
- i = aux.rfind(L"r/");
- if (i != wstring::npos)
- aux.assign(aux, i + 1, wstring::npos);
- VERIFY(aux.c_str()[9] == L'B');
- VERIFY(aux == L"/Hanalei Bay/Kauai/Hawaii");
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <cstdio>
-#include <testsuite_hooks.h>
-
-// assign(const basic_string& __str, size_type __pos, size_type __n)
-void
-test02()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- wstring one = L"Selling England by the pound";
- wstring two = one;
- wstring three = L"Brilliant trees";
-
- one.assign(one, 8, 100);
- VERIFY( one == L"England by the pound" );
-
- one.assign(one, 8, 0);
- VERIFY( one == L"" );
-
- one.assign(two, 8, 7);
- VERIFY( one == L"England" );
-
- one.assign(three, 10, 100);
- VERIFY( one == L"trees" );
-
- three.assign(one, 0, 3);
- VERIFY( three == L"tre" );
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
-
-// Copyright (C) 2001-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5 string modifiers
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// assign(const _CharT* __s, size_type __n)
-// assign(const _CharT* __s)
-void
-test03()
-{
- bool test __attribute__((unused)) = true;
-
- using namespace std;
-
- wstring one;
- wstring two;
- const wchar_t* source = L"Selling England by the pound";
-
- one.assign(source);
- VERIFY( one == L"Selling England by the pound" );
-
- one.assign(source, 28);
- VERIFY( one == L"Selling England by the pound" );
-
- two.assign(source, 7);
- VERIFY( two == L"Selling" );
-
- one.assign(one.c_str() + 8, 20);
- VERIFY( one == L"England by the pound" );
-
- one.assign(one.c_str() + 8, 6);
- VERIFY( one == L"by the" );
-}
-
-int main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// { dg-options "-std=gnu++0x" }
-// { dg-require-string-conversions "" }
-
-// Copyright (C) 2010-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// NOTE: This makes use of the fact that we know how moveable
-// is implemented on string (via swap). If the implementation changes
-// this test may begin to fail.
-
-#include <string>
-#include <utility>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- std::wstring a, b;
- a.push_back(L'1');
- b.assign(std::move(a));
- VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 1999-06-03 bkoz
-
-// Copyright (C) 1999-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.4 basic_string::insert
-
-#include <string>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-int test01(void)
-{
- bool test __attribute__((unused)) = true;
- typedef std::string::size_type csize_type;
- typedef std::string::iterator citerator;
- csize_type csz01, csz02;
-
- const std::string str01("rodeo beach, marin");
- const std::string str02("baker beach, san francisco");
- std::string str03;
-
- // string& insert(size_type p1, const string& str, size_type p2, size_type n)
- // requires:
- // 1) p1 <= size()
- // 2) p2 <= str.size()
- // 3) rlen = min(n, str.size() - p2)
- // throws:
- // 1) out_of_range if p1 > size() || p2 > str.size()
- // 2) length_error if size() >= npos - rlen
- // effects:
- // replaces *this with new string of length size() + rlen such that
- // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1]
- // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen]
- // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...]
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- try {
- str03.insert(csz01 + 1, str02, 0, 5);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- try {
- str03.insert(0, str02, csz02 + 1, 5);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- csz01 = str01.max_size();
- try {
- std::string str04(csz01, 'b');
- str03 = str04;
- csz02 = str02.size();
- try {
- str03.insert(0, str02, 0, 5);
- VERIFY( false );
- }
- catch(std::length_error& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
- }
- catch(std::bad_alloc& failure){
- VERIFY( true );
- }
- catch(std::exception& failure){
- VERIFY( false );
- }
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(13, str02, 0, 12);
- VERIFY( str03 == "rodeo beach, baker beach,marin" );
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(0, str02, 0, 12);
- VERIFY( str03 == "baker beach,rodeo beach, marin" );
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(csz01, str02, 0, csz02);
- VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
-
- // string& insert(size_type __p, const string& string);
- // insert(p1, str, 0, npos)
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(csz01, str02);
- VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(0, str02);
- VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" );
-
- // string& insert(size_type __p, const char* s, size_type n);
- // insert(p1, string(s,n))
- str03 = str02;
- csz01 = str03.size();
- str03.insert(0, "-break at the bridge", 20);
- VERIFY( str03 == "-break at the bridgebaker beach, san francisco" );
-
- // string& insert(size_type __p, const char* s);
- // insert(p1, string(s))
- str03 = str02;
- str03.insert(0, "-break at the bridge");
- VERIFY( str03 == "-break at the bridgebaker beach, san francisco" );
-
- // string& insert(size_type __p, size_type n, char c)
- // insert(p1, string(n,c))
- str03 = str02;
- csz01 = str03.size();
- str03.insert(csz01, 5, 'z');
- VERIFY( str03 == "baker beach, san franciscozzzzz" );
-
- // iterator insert(iterator p, char c)
- // inserts a copy of c before the character referred to by p
- str03 = str02;
- citerator cit01 = str03.begin();
- str03.insert(cit01, 'u');
- VERIFY( str03 == "ubaker beach, san francisco" );
-
- // iterator insert(iterator p, size_type n, char c)
- // inserts n copies of c before the character referred to by p
- str03 = str02;
- cit01 = str03.begin();
- str03.insert(cit01, 5, 'u');
- VERIFY( str03 == "uuuuubaker beach, san francisco" );
-
- // template<inputit>
- // void
- // insert(iterator p, inputit first, inputit, last)
- // ISO-14882: defect #7 part 1 clarifies this member function to be:
- // insert(p - begin(), string(first,last))
- str03 = str02;
- csz01 = str03.size();
- str03.insert(str03.begin(), str01.begin(), str01.end());
- VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
-
- str03 = str02;
- csz01 = str03.size();
- str03.insert(str03.end(), str01.begin(), str01.end());
- VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" );
- return test;
-}
-
-int main()
-{
- __gnu_test::set_memory_limits();
- test01();
- return 0;
-}
+++ /dev/null
-// 1999-06-03 bkoz
-
-// Copyright (C) 1999-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.4 basic_string::insert
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// More
-// string& insert(size_type __p, const char* s, size_type n);
-// string& insert(size_type __p, const char* s);
-// but now s points inside the _Rep
-int test02(void)
-{
- bool test __attribute__((unused)) = true;
-
- std::string str01;
- const char* title = "Everything was beautiful, and nothing hurt";
- // Increasing size: str01 is reallocated every time.
- str01 = title;
- str01.insert(0, str01.c_str() + str01.size() - 4, 4);
- VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str(), 5);
- VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(10, str01.c_str() + 4, 6);
- VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str(), 10);
- VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str() + 11, 13);
- VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str());
- VERIFY( str01 == "Everything was beautiful, and nothing hurt"
- "Everything was beautiful, and nothing hurt");
- // Again: no reallocations.
- str01 = title;
- str01.insert(0, str01.c_str() + str01.size() - 4, 4);
- VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str(), 5);
- VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(10, str01.c_str() + 4, 6);
- VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str(), 10);
- VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str() + 11, 13);
- VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str());
- VERIFY( str01 == "Everything was beautiful, and nothing hurt"
- "Everything was beautiful, and nothing hurt");
- return test;
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 1999-06-03 bkoz
-
-// Copyright (C) 1999-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.4 basic_string::insert
-
-#include <string>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-int test01(void)
-{
- bool test __attribute__((unused)) = true;
- typedef std::wstring::size_type csize_type;
- typedef std::wstring::iterator citerator;
- csize_type csz01, csz02;
-
- const std::wstring str01(L"rodeo beach, marin");
- const std::wstring str02(L"baker beach, san francisco");
- std::wstring str03;
-
- // wstring& insert(size_type p1, const wstring& str, size_type p2, size_type n)
- // requires:
- // 1) p1 <= size()
- // 2) p2 <= str.size()
- // 3) rlen = min(n, str.size() - p2)
- // throws:
- // 1) out_of_range if p1 > size() || p2 > str.size()
- // 2) length_error if size() >= npos - rlen
- // effects:
- // replaces *this with new wstring of length size() + rlen such that
- // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1]
- // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen]
- // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...]
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- try {
- str03.insert(csz01 + 1, str02, 0, 5);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- try {
- str03.insert(0, str02, csz02 + 1, 5);
- VERIFY( false );
- }
- catch(std::out_of_range& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
-
- csz01 = str01.max_size();
- try {
- std::wstring str04(csz01, L'b');
- str03 = str04;
- csz02 = str02.size();
- try {
- str03.insert(0, str02, 0, 5);
- VERIFY( false );
- }
- catch(std::length_error& fail) {
- VERIFY( true );
- }
- catch(...) {
- VERIFY( false );
- }
- }
- catch(std::bad_alloc& failure){
- VERIFY( true );
- }
- catch(std::exception& failure){
- VERIFY( false );
- }
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(13, str02, 0, 12);
- VERIFY( str03 == L"rodeo beach, baker beach,marin" );
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(0, str02, 0, 12);
- VERIFY( str03 == L"baker beach,rodeo beach, marin" );
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(csz01, str02, 0, csz02);
- VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" );
-
- // wstring& insert(size_type __p, const wstring& wstr);
- // insert(p1, str, 0, npos)
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(csz01, str02);
- VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" );
-
- str03 = str01;
- csz01 = str03.size();
- csz02 = str02.size();
- str03.insert(0, str02);
- VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" );
-
- // wstring& insert(size_type __p, const wchar_t* s, size_type n);
- // insert(p1, wstring(s,n))
- str03 = str02;
- csz01 = str03.size();
- str03.insert(0, L"-break at the bridge", 20);
- VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" );
-
- // wstring& insert(size_type __p, const wchar_t* s);
- // insert(p1, wstring(s))
- str03 = str02;
- str03.insert(0, L"-break at the bridge");
- VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" );
-
- // wstring& insert(size_type __p, size_type n, wchar_t c)
- // insert(p1, wstring(n,c))
- str03 = str02;
- csz01 = str03.size();
- str03.insert(csz01, 5, L'z');
- VERIFY( str03 == L"baker beach, san franciscozzzzz" );
-
- // iterator insert(iterator p, wchar_t c)
- // inserts a copy of c before the character referred to by p
- str03 = str02;
- citerator cit01 = str03.begin();
- str03.insert(cit01, L'u');
- VERIFY( str03 == L"ubaker beach, san francisco" );
-
- // iterator insert(iterator p, size_type n, wchar_t c)
- // inserts n copies of c before the character referred to by p
- str03 = str02;
- cit01 = str03.begin();
- str03.insert(cit01, 5, L'u');
- VERIFY( str03 == L"uuuuubaker beach, san francisco" );
-
- // template<inputit>
- // void
- // insert(iterator p, inputit first, inputit, last)
- // ISO-14882: defect #7 part 1 clarifies this member function to be:
- // insert(p - begin(), wstring(first,last))
- str03 = str02;
- csz01 = str03.size();
- str03.insert(str03.begin(), str01.begin(), str01.end());
- VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" );
-
- str03 = str02;
- csz01 = str03.size();
- str03.insert(str03.end(), str01.begin(), str01.end());
- VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" );
- return test;
-}
-
-int main()
-{
- __gnu_test::set_memory_limits();
- test01();
- return 0;
-}
+++ /dev/null
-// 1999-06-03 bkoz
-
-// Copyright (C) 1999-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.4 basic_string::insert
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// More
-// wstring& insert(size_type __p, const wchar_t* s, size_type n);
-// wstring& insert(size_type __p, const wchar_t* s);
-// but now s points inside the _Rep
-int test02(void)
-{
- bool test __attribute__((unused)) = true;
-
- std::wstring str01;
- const wchar_t* title = L"Everything was beautiful, and nothing hurt";
- // Increasing size: str01 is reallocated every time.
- str01 = title;
- str01.insert(0, str01.c_str() + str01.size() - 4, 4);
- VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str(), 5);
- VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(10, str01.c_str() + 4, 6);
- VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str(), 10);
- VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str() + 11, 13);
- VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str());
- VERIFY( str01 == L"Everything was beautiful, and nothing hurt"
- L"Everything was beautiful, and nothing hurt");
- // Again: no reallocations.
- str01 = title;
- str01.insert(0, str01.c_str() + str01.size() - 4, 4);
- VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str(), 5);
- VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(10, str01.c_str() + 4, 6);
- VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str(), 10);
- VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(15, str01.c_str() + 11, 13);
- VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" );
- str01 = title;
- str01.insert(0, str01.c_str());
- VERIFY( str01 == L"Everything was beautiful, and nothing hurt"
- L"Everything was beautiful, and nothing hurt");
- return test;
-}
-
-int main()
-{
- test02();
- return 0;
-}
--- /dev/null
+// 1999-07-08 bkoz
+
+// Copyright (C) 1999-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.2 basic_string::append
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ typedef std::string::const_reference cref;
+ typedef std::string::reference ref;
+ csize_type csz01;
+
+ const char str_lit01[] = "point bolivar, texas";
+ const std::string str01(str_lit01);
+ const std::string str02("corpus, ");
+ const std::string str03;
+ std::string str05;
+
+
+ // string& append(const string&)
+ str05 = str02;
+ str05.append(str05);
+ VERIFY( str05 == "corpus, corpus, " );
+ str05.append(str01);
+ VERIFY( str05 == "corpus, corpus, point bolivar, texas" );
+ str05.append(str03);
+ VERIFY( str05 == "corpus, corpus, point bolivar, texas" );
+ std::string str06;
+ str06.append(str05);
+ VERIFY( str06 == str05 );
+
+
+ // string& append(const string&, size_type pos, size_type n)
+ str05.erase();
+ str06.erase();
+ csz01 = str03.size();
+ try {
+ str06.append(str03, csz01 + 1, 0);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ csz01 = str01.size();
+ try {
+ str06.append(str01, csz01 + 1, 0);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ str05 = str02;
+ str05.append(str01, 0, std::string::npos);
+ VERIFY( str05 == "corpus, point bolivar, texas" );
+ VERIFY( str05 != str02 );
+
+ str06 = str02;
+ str06.append(str01, 15, std::string::npos);
+ VERIFY( str06 == "corpus, texas" );
+ VERIFY( str02 != str06 );
+
+
+ // string& append(const char* s)
+ str05.erase();
+ str06.erase();
+ str05.append("");
+ VERIFY( str05 == str03 );
+
+ str05.append(str_lit01);
+ VERIFY( str05 == str01 );
+
+ str06 = str02;
+ str06.append("corpus, ");
+ VERIFY( str06 == "corpus, corpus, " );
+
+
+ // string& append(const char* s, size_type n)
+ str05.erase();
+ str06.erase();
+ str05.append("", 0);
+ VERIFY( str05.size() == 0 );
+ VERIFY( str05 == str03 );
+
+ str05.append(str_lit01, sizeof(str_lit01) - 1);
+ VERIFY( str05 == str01 );
+
+ str06 = str02;
+ str06.append("corpus, ", 6);
+ VERIFY( str06 == "corpus, corpus" );
+
+ str06 = str02;
+ str06.append("corpus, ", 12);
+ VERIFY( str06 != "corpus, corpus, " );
+
+
+ // string& append(size_type n, char c)
+ str05.erase();
+ str06.erase();
+ str05.append(0, 'a');
+ VERIFY( str05 == str03 );
+ str06.append(8, '.');
+ VERIFY( str06 == "........" );
+
+
+ // template<typename InputIter>
+ // string& append(InputIter first, InputIter last)
+ str05.erase();
+ str06.erase();
+ str05.append(str03.begin(), str03.end());
+ VERIFY( str05 == str03 );
+
+ str06 = str02;
+ str06.append(str01.begin(), str01.begin() + str01.find('r'));
+ VERIFY( str06 == "corpus, point boliva" );
+ VERIFY( str06 != str01 );
+ VERIFY( str06 != str02 );
+
+ str05 = str01;
+ str05.append(str05.begin(), str05.begin() + str05.find('r'));
+ VERIFY( str05 == "point bolivar, texaspoint boliva" );
+ VERIFY( str05 != str01 );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// append(const _CharT* __s, size_type __n)
+// append(const _CharT* __s)
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ string one;
+ string two;
+ string three;
+ const char * source = "Written in your eyes";
+
+ one.append(source);
+ VERIFY( one == "Written in your eyes" );
+
+ two.append(source, 20);
+ VERIFY( two == "Written in your eyes" );
+
+ three.append(source, 7);
+ VERIFY( three == "Written" );
+
+ three.clear();
+ three.append(source + 8, 2);
+ VERIFY( three == "in" );
+
+ one.append(one.c_str(), 20);
+ VERIFY( one == "Written in your eyesWritten in your eyes" );
+
+ two.append(two.c_str() + 16, 4);
+ VERIFY( two == "Written in your eyeseyes" );
+
+ two.append(two.c_str(), 3);
+ VERIFY( two == "Written in your eyeseyesWri" );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// Upon reallocation (basic_string::reserve) we were copying from
+// deallocated memory.
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ const char * source = "Kesto";
+
+ for (unsigned i = 0; i < 10; ++i)
+ {
+ string one(source);
+ string two(source);
+ for (unsigned j = 0; j < 18; ++j)
+ {
+ VERIFY( one == two );
+ one.append(one);
+ one += 'x';
+ two.append(two.c_str(), two.size());
+ two += 'x';
+ }
+ }
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 1999-07-08 bkoz
+
+// Copyright (C) 1999-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.2 basic_string::append
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ typedef std::wstring::const_reference cref;
+ typedef std::wstring::reference ref;
+ csize_type csz01;
+
+ const wchar_t str_lit01[] = L"point bolivar, texas";
+ const std::wstring str01(str_lit01);
+ const std::wstring str02(L"corpus, ");
+ const std::wstring str03;
+ std::wstring str05;
+
+
+ // wstring& append(const wstring&)
+ str05 = str02;
+ str05.append(str05);
+ VERIFY( str05 == L"corpus, corpus, " );
+ str05.append(str01);
+ VERIFY( str05 == L"corpus, corpus, point bolivar, texas" );
+ str05.append(str03);
+ VERIFY( str05 == L"corpus, corpus, point bolivar, texas" );
+ std::wstring str06;
+ str06.append(str05);
+ VERIFY( str06 == str05 );
+
+
+ // wstring& append(const wstring&, size_type pos, size_type n)
+ str05.erase();
+ str06.erase();
+ csz01 = str03.size();
+ try {
+ str06.append(str03, csz01 + 1, 0);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ csz01 = str01.size();
+ try {
+ str06.append(str01, csz01 + 1, 0);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ str05 = str02;
+ str05.append(str01, 0, std::wstring::npos);
+ VERIFY( str05 == L"corpus, point bolivar, texas" );
+ VERIFY( str05 != str02 );
+
+ str06 = str02;
+ str06.append(str01, 15, std::wstring::npos);
+ VERIFY( str06 == L"corpus, texas" );
+ VERIFY( str02 != str06 );
+
+
+ // wstring& append(const wchar_t* s)
+ str05.erase();
+ str06.erase();
+ str05.append(L"");
+ VERIFY( str05 == str03 );
+
+ str05.append(str_lit01);
+ VERIFY( str05 == str01 );
+
+ str06 = str02;
+ str06.append(L"corpus, ");
+ VERIFY( str06 == L"corpus, corpus, " );
+
+
+ // wstring& append(const wchar_t* s, size_type n)
+ str05.erase();
+ str06.erase();
+ str05.append(L"", 0);
+ VERIFY( str05.size() == 0 );
+ VERIFY( str05 == str03 );
+
+ str05.append(str_lit01, sizeof(str_lit01) / sizeof(wchar_t) - 1);
+ VERIFY( str05 == str01 );
+
+ str06 = str02;
+ str06.append(L"corpus, ", 6);
+ VERIFY( str06 == L"corpus, corpus" );
+
+ str06 = str02;
+ str06.append(L"corpus, ", 12);
+ VERIFY( str06 != L"corpus, corpus, " );
+
+
+ // wstring& append(size_type n, char c)
+ str05.erase();
+ str06.erase();
+ str05.append(0, L'a');
+ VERIFY( str05 == str03 );
+ str06.append(8, L'.');
+ VERIFY( str06 == L"........" );
+
+
+ // template<typename InputIter>
+ // wstring& append(InputIter first, InputIter last)
+ str05.erase();
+ str06.erase();
+ str05.append(str03.begin(), str03.end());
+ VERIFY( str05 == str03 );
+
+ str06 = str02;
+ str06.append(str01.begin(), str01.begin() + str01.find(L'r'));
+ VERIFY( str06 == L"corpus, point boliva" );
+ VERIFY( str06 != str01 );
+ VERIFY( str06 != str02 );
+
+ str05 = str01;
+ str05.append(str05.begin(), str05.begin() + str05.find(L'r'));
+ VERIFY( str05 == L"point bolivar, texaspoint boliva" );
+ VERIFY( str05 != str01 );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// append(const _CharT* __s, size_type __n)
+// append(const _CharT* __s)
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ wstring one;
+ wstring two;
+ wstring three;
+ const wchar_t * source = L"Written in your eyes";
+
+ one.append(source);
+ VERIFY( one == L"Written in your eyes" );
+
+ two.append(source, 20);
+ VERIFY( two == L"Written in your eyes" );
+
+ three.append(source, 7);
+ VERIFY( three == L"Written" );
+
+ three.clear();
+ three.append(source + 8, 2);
+ VERIFY( three == L"in" );
+
+ one.append(one.c_str(), 20);
+ VERIFY( one == L"Written in your eyesWritten in your eyes" );
+
+ two.append(two.c_str() + 16, 4);
+ VERIFY( two == L"Written in your eyeseyes" );
+
+ two.append(two.c_str(), 3);
+ VERIFY( two == L"Written in your eyeseyesWri" );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2004-25-10 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+// { dg-options "-DITERATIONS=14" { target simulator } }
+
+#ifndef ITERATIONS
+#define ITERATIONS 18
+#endif
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// Upon reallocation (basic_string::reserve) we were copying from
+// deallocated memory.
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ const wchar_t * source = L"Kesto";
+
+ for (unsigned i = 0; i < 10; ++i)
+ {
+ wstring one(source);
+ wstring two(source);
+ for (unsigned j = 0; j < ITERATIONS; ++j)
+ {
+ VERIFY( one == two );
+ one.append(one);
+ one += L'x';
+ two.append(two.c_str(), two.size());
+ two += L'x';
+ }
+ }
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii";
+ string aux = strlit;
+ string::size_type i = aux.rfind("/");
+ if (i != string::npos)
+ aux.assign(aux, i + 1, string::npos);
+ VERIFY(aux == "Hawaii");
+
+ aux = strlit;
+ i = aux.rfind("r/");
+ if (i != string::npos)
+ aux.assign(aux, i + 1, string::npos);
+ VERIFY(aux.c_str()[9] == 'B');
+ VERIFY(aux == "/Hanalei Bay/Kauai/Hawaii");
+
+ aux.assign(10, 0);
+ VERIFY(aux.length() == 10);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+// assign(const basic_string& __str, size_type __pos, size_type __n)
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ string one = "Selling England by the pound";
+ string two = one;
+ string three = "Brilliant trees";
+
+ one.assign(one, 8, 100);
+ VERIFY( one == "England by the pound" );
+
+ one.assign(one, 8, 0);
+ VERIFY( one == "" );
+
+ one.assign(two, 8, 7);
+ VERIFY( one == "England" );
+
+ one.assign(three, 10, 100);
+ VERIFY( one == "trees" );
+
+ three.assign(one, 0, 3);
+ VERIFY( three == "tre" );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// assign(const _CharT* __s, size_type __n)
+// assign(const _CharT* __s)
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ string one;
+ string two;
+ const char * source = "Selling England by the pound";
+
+ one.assign(source);
+ VERIFY( one == "Selling England by the pound" );
+
+ one.assign(source, 28);
+ VERIFY( one == "Selling England by the pound" );
+
+ two.assign(source, 7);
+ VERIFY( two == "Selling" );
+
+ one.assign(one.c_str() + 8, 20);
+ VERIFY( one == "England by the pound" );
+
+ one.assign(one.c_str() + 8, 6);
+ VERIFY( one == "by the" );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on string (via swap). If the implementation changes
+// this test may begin to fail.
+
+#include <string>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string a, b;
+ a.push_back('1');
+ b.assign(std::move(a));
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii";
+ wstring aux = strlit;
+ wstring::size_type i = aux.rfind(L"/");
+ if (i != wstring::npos)
+ aux.assign(aux, i + 1, wstring::npos);
+ VERIFY(aux == L"Hawaii");
+
+ aux = strlit;
+ i = aux.rfind(L"r/");
+ if (i != wstring::npos)
+ aux.assign(aux, i + 1, wstring::npos);
+ VERIFY(aux.c_str()[9] == L'B');
+ VERIFY(aux == L"/Hanalei Bay/Kauai/Hawaii");
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+// assign(const basic_string& __str, size_type __pos, size_type __n)
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ wstring one = L"Selling England by the pound";
+ wstring two = one;
+ wstring three = L"Brilliant trees";
+
+ one.assign(one, 8, 100);
+ VERIFY( one == L"England by the pound" );
+
+ one.assign(one, 8, 0);
+ VERIFY( one == L"" );
+
+ one.assign(two, 8, 7);
+ VERIFY( one == L"England" );
+
+ one.assign(three, 10, 100);
+ VERIFY( one == L"trees" );
+
+ three.assign(one, 0, 3);
+ VERIFY( three == L"tre" );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// assign(const _CharT* __s, size_type __n)
+// assign(const _CharT* __s)
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ using namespace std;
+
+ wstring one;
+ wstring two;
+ const wchar_t* source = L"Selling England by the pound";
+
+ one.assign(source);
+ VERIFY( one == L"Selling England by the pound" );
+
+ one.assign(source, 28);
+ VERIFY( one == L"Selling England by the pound" );
+
+ two.assign(source, 7);
+ VERIFY( two == L"Selling" );
+
+ one.assign(one.c_str() + 8, 20);
+ VERIFY( one == L"England by the pound" );
+
+ one.assign(one.c_str() + 8, 6);
+ VERIFY( one == L"by the" );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on string (via swap). If the implementation changes
+// this test may begin to fail.
+
+#include <string>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring a, b;
+ a.push_back(L'1');
+ b.assign(std::move(a));
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+++ /dev/null
-// Copyright (C) 2011-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.4.6.5 basic_string::pop_back
-// { dg-options "-std=gnu++0x" }
-
-#include <string>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- const std::string cstr("Badger");
- std::string str = cstr;
- str.pop_back();
- VERIFY( str.size() == cstr.size() - 1 );
-
- str += cstr.back();
- VERIFY( str == cstr );
-}
-
-int main()
-{
- test01();
- return 0;
-}
--- /dev/null
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.4 basic_string::insert
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ typedef std::string::iterator citerator;
+ csize_type csz01, csz02;
+
+ const std::string str01("rodeo beach, marin");
+ const std::string str02("baker beach, san francisco");
+ std::string str03;
+
+ // string& insert(size_type p1, const string& str, size_type p2, size_type n)
+ // requires:
+ // 1) p1 <= size()
+ // 2) p2 <= str.size()
+ // 3) rlen = min(n, str.size() - p2)
+ // throws:
+ // 1) out_of_range if p1 > size() || p2 > str.size()
+ // 2) length_error if size() >= npos - rlen
+ // effects:
+ // replaces *this with new string of length size() + rlen such that
+ // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1]
+ // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen]
+ // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...]
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ try {
+ str03.insert(csz01 + 1, str02, 0, 5);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ try {
+ str03.insert(0, str02, csz02 + 1, 5);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ csz01 = str01.max_size();
+ try {
+ std::string str04(csz01, 'b');
+ str03 = str04;
+ csz02 = str02.size();
+ try {
+ str03.insert(0, str02, 0, 5);
+ VERIFY( false );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ }
+ catch(std::bad_alloc& failure){
+ VERIFY( true );
+ }
+ catch(std::exception& failure){
+ VERIFY( false );
+ }
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(13, str02, 0, 12);
+ VERIFY( str03 == "rodeo beach, baker beach,marin" );
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(0, str02, 0, 12);
+ VERIFY( str03 == "baker beach,rodeo beach, marin" );
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(csz01, str02, 0, csz02);
+ VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
+
+ // string& insert(size_type __p, const string& string);
+ // insert(p1, str, 0, npos)
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(csz01, str02);
+ VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(0, str02);
+ VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" );
+
+ // string& insert(size_type __p, const char* s, size_type n);
+ // insert(p1, string(s,n))
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(0, "-break at the bridge", 20);
+ VERIFY( str03 == "-break at the bridgebaker beach, san francisco" );
+
+ // string& insert(size_type __p, const char* s);
+ // insert(p1, string(s))
+ str03 = str02;
+ str03.insert(0, "-break at the bridge");
+ VERIFY( str03 == "-break at the bridgebaker beach, san francisco" );
+
+ // string& insert(size_type __p, size_type n, char c)
+ // insert(p1, string(n,c))
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(csz01, 5, 'z');
+ VERIFY( str03 == "baker beach, san franciscozzzzz" );
+
+ // iterator insert(iterator p, char c)
+ // inserts a copy of c before the character referred to by p
+ str03 = str02;
+ citerator cit01 = str03.begin();
+ str03.insert(cit01, 'u');
+ VERIFY( str03 == "ubaker beach, san francisco" );
+
+ // iterator insert(iterator p, size_type n, char c)
+ // inserts n copies of c before the character referred to by p
+ str03 = str02;
+ cit01 = str03.begin();
+ str03.insert(cit01, 5, 'u');
+ VERIFY( str03 == "uuuuubaker beach, san francisco" );
+
+ // template<inputit>
+ // void
+ // insert(iterator p, inputit first, inputit, last)
+ // ISO-14882: defect #7 part 1 clarifies this member function to be:
+ // insert(p - begin(), string(first,last))
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(str03.begin(), str01.begin(), str01.end());
+ VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" );
+
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(str03.end(), str01.begin(), str01.end());
+ VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" );
+ return test;
+}
+
+int main()
+{
+ __gnu_test::set_memory_limits();
+ test01();
+ return 0;
+}
--- /dev/null
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.4 basic_string::insert
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// More
+// string& insert(size_type __p, const char* s, size_type n);
+// string& insert(size_type __p, const char* s);
+// but now s points inside the _Rep
+int test02(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string str01;
+ const char* title = "Everything was beautiful, and nothing hurt";
+ // Increasing size: str01 is reallocated every time.
+ str01 = title;
+ str01.insert(0, str01.c_str() + str01.size() - 4, 4);
+ VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str(), 5);
+ VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(10, str01.c_str() + 4, 6);
+ VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str(), 10);
+ VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str() + 11, 13);
+ VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str());
+ VERIFY( str01 == "Everything was beautiful, and nothing hurt"
+ "Everything was beautiful, and nothing hurt");
+ // Again: no reallocations.
+ str01 = title;
+ str01.insert(0, str01.c_str() + str01.size() - 4, 4);
+ VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str(), 5);
+ VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(10, str01.c_str() + 4, 6);
+ VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str(), 10);
+ VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str() + 11, 13);
+ VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str());
+ VERIFY( str01 == "Everything was beautiful, and nothing hurt"
+ "Everything was beautiful, and nothing hurt");
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.4 basic_string::insert
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ typedef std::wstring::iterator citerator;
+ csize_type csz01, csz02;
+
+ const std::wstring str01(L"rodeo beach, marin");
+ const std::wstring str02(L"baker beach, san francisco");
+ std::wstring str03;
+
+ // wstring& insert(size_type p1, const wstring& str, size_type p2, size_type n)
+ // requires:
+ // 1) p1 <= size()
+ // 2) p2 <= str.size()
+ // 3) rlen = min(n, str.size() - p2)
+ // throws:
+ // 1) out_of_range if p1 > size() || p2 > str.size()
+ // 2) length_error if size() >= npos - rlen
+ // effects:
+ // replaces *this with new wstring of length size() + rlen such that
+ // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1]
+ // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen]
+ // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...]
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ try {
+ str03.insert(csz01 + 1, str02, 0, 5);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ try {
+ str03.insert(0, str02, csz02 + 1, 5);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ csz01 = str01.max_size();
+ try {
+ std::wstring str04(csz01, L'b');
+ str03 = str04;
+ csz02 = str02.size();
+ try {
+ str03.insert(0, str02, 0, 5);
+ VERIFY( false );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ }
+ catch(std::bad_alloc& failure){
+ VERIFY( true );
+ }
+ catch(std::exception& failure){
+ VERIFY( false );
+ }
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(13, str02, 0, 12);
+ VERIFY( str03 == L"rodeo beach, baker beach,marin" );
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(0, str02, 0, 12);
+ VERIFY( str03 == L"baker beach,rodeo beach, marin" );
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(csz01, str02, 0, csz02);
+ VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" );
+
+ // wstring& insert(size_type __p, const wstring& wstr);
+ // insert(p1, str, 0, npos)
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(csz01, str02);
+ VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" );
+
+ str03 = str01;
+ csz01 = str03.size();
+ csz02 = str02.size();
+ str03.insert(0, str02);
+ VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" );
+
+ // wstring& insert(size_type __p, const wchar_t* s, size_type n);
+ // insert(p1, wstring(s,n))
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(0, L"-break at the bridge", 20);
+ VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" );
+
+ // wstring& insert(size_type __p, const wchar_t* s);
+ // insert(p1, wstring(s))
+ str03 = str02;
+ str03.insert(0, L"-break at the bridge");
+ VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" );
+
+ // wstring& insert(size_type __p, size_type n, wchar_t c)
+ // insert(p1, wstring(n,c))
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(csz01, 5, L'z');
+ VERIFY( str03 == L"baker beach, san franciscozzzzz" );
+
+ // iterator insert(iterator p, wchar_t c)
+ // inserts a copy of c before the character referred to by p
+ str03 = str02;
+ citerator cit01 = str03.begin();
+ str03.insert(cit01, L'u');
+ VERIFY( str03 == L"ubaker beach, san francisco" );
+
+ // iterator insert(iterator p, size_type n, wchar_t c)
+ // inserts n copies of c before the character referred to by p
+ str03 = str02;
+ cit01 = str03.begin();
+ str03.insert(cit01, 5, L'u');
+ VERIFY( str03 == L"uuuuubaker beach, san francisco" );
+
+ // template<inputit>
+ // void
+ // insert(iterator p, inputit first, inputit, last)
+ // ISO-14882: defect #7 part 1 clarifies this member function to be:
+ // insert(p - begin(), wstring(first,last))
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(str03.begin(), str01.begin(), str01.end());
+ VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" );
+
+ str03 = str02;
+ csz01 = str03.size();
+ str03.insert(str03.end(), str01.begin(), str01.end());
+ VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" );
+ return test;
+}
+
+int main()
+{
+ __gnu_test::set_memory_limits();
+ test01();
+ return 0;
+}
--- /dev/null
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.4 basic_string::insert
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// More
+// wstring& insert(size_type __p, const wchar_t* s, size_type n);
+// wstring& insert(size_type __p, const wchar_t* s);
+// but now s points inside the _Rep
+int test02(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring str01;
+ const wchar_t* title = L"Everything was beautiful, and nothing hurt";
+ // Increasing size: str01 is reallocated every time.
+ str01 = title;
+ str01.insert(0, str01.c_str() + str01.size() - 4, 4);
+ VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str(), 5);
+ VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(10, str01.c_str() + 4, 6);
+ VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str(), 10);
+ VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str() + 11, 13);
+ VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str());
+ VERIFY( str01 == L"Everything was beautiful, and nothing hurt"
+ L"Everything was beautiful, and nothing hurt");
+ // Again: no reallocations.
+ str01 = title;
+ str01.insert(0, str01.c_str() + str01.size() - 4, 4);
+ VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str(), 5);
+ VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(10, str01.c_str() + 4, 6);
+ VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str(), 10);
+ VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(15, str01.c_str() + 11, 13);
+ VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" );
+ str01 = title;
+ str01.insert(0, str01.c_str());
+ VERIFY( str01 == L"Everything was beautiful, and nothing hurt"
+ L"Everything was beautiful, and nothing hurt");
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2011-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.4.6.5 basic_string::pop_back
+// { dg-options "-std=gnu++0x" }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::string cstr("Badger");
+ std::string str = cstr;
+ str.pop_back();
+ VERIFY( str.size() == cstr.size() - 1 );
+
+ str += cstr.back();
+ VERIFY( str == cstr );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// Copyright (C) 2011-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.4.6.5 basic_string::pop_back
+// { dg-options "-std=gnu++0x" }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::wstring cstr(L"Badger");
+ std::wstring str = cstr;
+ str.pop_back();
+ VERIFY( str.size() == cstr.size() - 1 );
+
+ str += cstr.back();
+ VERIFY( str == cstr );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <algorithm> // for std::find
+#include <testsuite_hooks.h>
+
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ typedef std::string::const_reference cref;
+ typedef std::string::reference ref;
+
+ const char str_lit01[] = "ventura, california";
+ const std::string str01(str_lit01);
+ std::string str02("del mar, california");
+ std::string str03(" and ");
+ std::string str05;
+
+ // string& replace(size_type pos, size_type n, const string& string)
+ // string& replace(size_type pos1, size_type n1, const string& string,
+ // size_type pos2, size_type n2)
+ // string& replace(size_type pos, size_type n1, const char* s, size_type n2)
+ // string& replace(size_type pos, size_type n1, const char* s)
+ // string& replace(size_type pos, size_type n1, size_type n2, char c)
+ // string& replace(iterator it1, iterator it2, const string& str)
+ // string& replace(iterator it1, iterator it2, const chat* s, size_type n)
+ // string& replace(iterator it1, iterator it2, const chat* s)
+ // string& replace(iterator it1, iterator it2, size_type n, char c)
+ // template<typename InputIter>
+ // string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
+
+ // with mods, from tstring.cc, from jason merrill, et. al.
+ std::string X = "Hello";
+ std::string x = X;
+
+ char ch = x[0];
+ VERIFY( ch == 'H' );
+
+ std::string z = x.substr(2, 3);
+ VERIFY( z == "llo" );
+
+ x.replace(2, 2, "r");
+ VERIFY( x == "Hero" );
+
+ x = X;
+ x.replace(0, 1, "j");
+ VERIFY( x == "jello" );
+
+ int ar[] = { 'H', 'e', 'l', 'l', 'o' };
+ x.replace(std::find(x.begin(), x.end(), 'l'),
+ std::find(x.rbegin(), x.rend(), 'l').base(), ar,
+ ar + sizeof(ar) / sizeof(ar[0]));
+ VERIFY( x == "jeHelloo" );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+ const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii";
+ std::string aux = strlit;
+ aux.replace(aux.begin()+5, aux.begin()+20,
+ aux.begin()+10, aux.begin()+15);
+ VERIFY(aux == "../thg piealei Bay/Kauai/Hawaii");
+
+ aux = strlit;
+ aux.replace(aux.begin() + 10, aux.begin() + 15,
+ aux.begin() + 5, aux.begin() + 20);
+ VERIFY(aux == "../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii");
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// Some more miscellaneous tests
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+ const char* title01 = "nine types of ambiguity";
+ const char* title02 = "ultra";
+ std::string str01 = title01;
+ std::string str02 = title02;
+
+ str01.replace(0, 4, str02);
+ VERIFY(str01 == "ultra types of ambiguity");
+
+ str01.replace(15, 9, str02, 2, 2);
+ VERIFY(str01 == "ultra types of tr");
+
+ str01 = title01;
+ str02.replace(0, 0, str01, 0, std::string::npos);
+ VERIFY(str02 == "nine types of ambiguityultra");
+
+ str02.replace(11, 2, title02, 5);
+ VERIFY(str02 == "nine types ultra ambiguityultra");
+
+ str02.replace(11, 5, title01, 2);
+ VERIFY(str02 == "nine types ni ambiguityultra");
+
+ str01.replace(str01.size(), 0, title02);
+ VERIFY(str01 == "nine types of ambiguityultra");
+
+ str01 = title01;
+ str02 = title02;
+ str01.replace(str01.begin(), str01.end(), str02);
+ VERIFY(str01 == "ultra");
+
+ str01.replace(str01.begin(), str01.begin(), title01, 4);
+ VERIFY(str01 == "nineultra");
+
+ str01.replace(str01.end(), str01.end(), title01 + 5, 5);
+ VERIFY(str01 == "nineultratypes");
+
+ str01.replace(str01.begin(), str01.end(), title02);
+ VERIFY(str01 == "ultra");
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// Some more tests for
+// template<typename InputIter>
+// string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
+void
+test04()
+{
+ bool test __attribute__((unused)) = true;
+ std::string str01 = "geogaddi";
+ std::string str02;
+
+ typedef std::string::iterator iterator;
+ typedef std::string::const_iterator const_iterator;
+
+ iterator it1 = str01.begin();
+ iterator it2 = str01.end();
+ str02.replace(str02.begin(), str02.end(), it1, it2);
+ VERIFY(str02 == "geogaddi");
+
+ str02 = "boards";
+ const_iterator c_it1 = str01.begin();
+ const_iterator c_it2 = str01.end();
+ str02.replace(str02.begin(), str02.end(), c_it1, c_it2);
+ VERIFY(str02 == "geogaddi");
+
+ str02 = "boards";
+ const char* c_ptr1 = str01.c_str();
+ const char* c_ptr2 = str01.c_str() + 8;
+ str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2);
+ VERIFY(str02 == "geogaddi");
+
+ str02 = "boards";
+ char* ptr1 = &*str01.begin();
+ char* ptr2 = ptr1 + str01.length();
+ str02.replace(str02.begin(), str02.end(), ptr1, ptr2);
+ VERIFY(str02 == "geogaddi");
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// We wrongly used __n1 instead of __foldn1 in the length_error
+// check at the beginning of replace(__pos, __n1, __s, __n2)
+void
+test05()
+{
+ bool test __attribute__((unused)) = true;
+ std::string str01 = "londinium";
+ std::string str02 = "cydonia";
+
+ str01.replace(0, 20, str02.c_str(), 3);
+ VERIFY(str01 == "cyd");
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
--- /dev/null
+// 2004-01-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string str01("Valle Del Salto");
+ str01.replace(0, 5, str01.data() + 10, 5);
+ VERIFY( str01 == "Salto Del Salto" );
+
+ std::string str02("Colle di Val d'Elsa");
+ str02.replace(0, 9, str02.data() + 10, 0);
+ VERIFY( str02 == "Val d'Elsa" );
+
+ std::string str03("Novi Ligure");
+ str03.replace(11, 0, str03.data() + 4, 7);
+ VERIFY( str03 == "Novi Ligure Ligure");
+
+ std::string str04("Trebisacce");
+ str04.replace(3, 4, str04.data(), 0);
+ VERIFY( str04 == "Trecce" );
+
+ std::string str05("Altopiano della Sila");
+ str05.replace(1, 18, str05.data() + 19, 1);
+ VERIFY( str05 == "Aaa" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <algorithm> // for std::find
+#include <testsuite_hooks.h>
+
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ typedef std::wstring::const_reference cref;
+ typedef std::wstring::reference ref;
+
+ const wchar_t str_lit01[] = L"ventura, california";
+ const std::wstring str01(str_lit01);
+ std::wstring str02(L"del mar, california");
+ std::wstring str03(L" and ");
+ std::wstring str05;
+
+ // wstring& replace(size_type pos, size_type n, const wstring& string)
+ // wstring& replace(size_type pos1, size_type n1, const wstring& string,
+ // size_type pos2, size_type n2)
+ // wstring& replace(size_type pos, size_type n1, const wchar_t* s, size_type n2)
+ // wstring& replace(size_type pos, size_type n1, const wchar_t* s)
+ // wstring& replace(size_type pos, size_type n1, size_type n2, wchar_t c)
+ // wstring& replace(iterator it1, iterator it2, const wstring& str)
+ // wstring& replace(iterator it1, iterator it2, const wchar_t* s, size_type n)
+ // wstring& replace(iterator it1, iterator it2, const wchar_t* s)
+ // wstring& replace(iterator it1, iterator it2, size_type n, char c)
+ // template<typename InputIter>
+ // wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
+
+ // with mods, from tstring.cc, from jason merrill, et. al.
+ std::wstring X = L"Hello";
+ std::wstring x = X;
+
+ wchar_t ch = x[0];
+ VERIFY( ch == L'H' );
+
+ std::wstring z = x.substr(2, 3);
+ VERIFY( z == L"llo" );
+
+ x.replace(2, 2, L"r");
+ VERIFY( x == L"Hero" );
+
+ x = X;
+ x.replace(0, 1, L"j");
+ VERIFY( x == L"jello" );
+
+ wchar_t ar[] = { L'H', L'e', L'l', L'l', L'o' };
+ x.replace(std::find(x.begin(), x.end(), L'l'),
+ std::find(x.rbegin(), x.rend(), L'l').base(), ar,
+ ar + sizeof(ar) / sizeof(ar[0]));
+ VERIFY( x == L"jeHelloo" );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test02()
+{
+ bool test __attribute__((unused)) = true;
+ const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii";
+ std::wstring aux = strlit;
+ aux.replace(aux.begin()+5, aux.begin()+20,
+ aux.begin()+10, aux.begin()+15);
+ VERIFY(aux == L"../thg piealei Bay/Kauai/Hawaii");
+
+ aux = strlit;
+ aux.replace(aux.begin() + 10, aux.begin() + 15,
+ aux.begin() + 5, aux.begin() + 20);
+ VERIFY(aux == L"../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii");
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// Some more miscellaneous tests
+void
+test03()
+{
+ bool test __attribute__((unused)) = true;
+ const wchar_t* title01 = L"nine types of ambiguity";
+ const wchar_t* title02 = L"ultra";
+ std::wstring str01 = title01;
+ std::wstring str02 = title02;
+
+ str01.replace(0, 4, str02);
+ VERIFY(str01 == L"ultra types of ambiguity");
+
+ str01.replace(15, 9, str02, 2, 2);
+ VERIFY(str01 == L"ultra types of tr");
+
+ str01 = title01;
+ str02.replace(0, 0, str01, 0, std::wstring::npos);
+ VERIFY(str02 == L"nine types of ambiguityultra");
+
+ str02.replace(11, 2, title02, 5);
+ VERIFY(str02 == L"nine types ultra ambiguityultra");
+
+ str02.replace(11, 5, title01, 2);
+ VERIFY(str02 == L"nine types ni ambiguityultra");
+
+ str01.replace(str01.size(), 0, title02);
+ VERIFY(str01 == L"nine types of ambiguityultra");
+
+ str01 = title01;
+ str02 = title02;
+ str01.replace(str01.begin(), str01.end(), str02);
+ VERIFY(str01 == L"ultra");
+
+ str01.replace(str01.begin(), str01.begin(), title01, 4);
+ VERIFY(str01 == L"nineultra");
+
+ str01.replace(str01.end(), str01.end(), title01 + 5, 5);
+ VERIFY(str01 == L"nineultratypes");
+
+ str01.replace(str01.begin(), str01.end(), title02);
+ VERIFY(str01 == L"ultra");
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// Some more tests for
+// template<typename InputIter>
+// wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
+void
+test04()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring str01 = L"geogaddi";
+ std::wstring str02;
+
+ typedef std::wstring::iterator iterator;
+ typedef std::wstring::const_iterator const_iterator;
+
+ iterator it1 = str01.begin();
+ iterator it2 = str01.end();
+ str02.replace(str02.begin(), str02.end(), it1, it2);
+ VERIFY(str02 == L"geogaddi");
+
+ str02 = L"boards";
+ const_iterator c_it1 = str01.begin();
+ const_iterator c_it2 = str01.end();
+ str02.replace(str02.begin(), str02.end(), c_it1, c_it2);
+ VERIFY(str02 == L"geogaddi");
+
+ str02 = L"boards";
+ const wchar_t* c_ptr1 = str01.c_str();
+ const wchar_t* c_ptr2 = str01.c_str() + 8;
+ str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2);
+ VERIFY(str02 == L"geogaddi");
+
+ str02 = L"boards";
+ wchar_t* ptr1 = &*str01.begin();
+ wchar_t* ptr2 = ptr1 + str01.length();
+ str02.replace(str02.begin(), str02.end(), ptr1, ptr2);
+ VERIFY(str02 == L"geogaddi");
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
--- /dev/null
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// We wrongly used __n1 instead of __foldn1 in the length_error
+// check at the beginning of replace(__pos, __n1, __s, __n2)
+void
+test05()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring str01 = L"londinium";
+ std::wstring str02 = L"cydonia";
+
+ str01.replace(0, 20, str02.c_str(), 3);
+ VERIFY(str01 == L"cyd");
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
--- /dev/null
+// 2004-01-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 21.3.5.6 basic_string::replace
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring str01(L"Valle Del Salto");
+ str01.replace(0, 5, str01.data() + 10, 5);
+ VERIFY( str01 == L"Salto Del Salto" );
+
+ std::wstring str02(L"Colle di Val d'Elsa");
+ str02.replace(0, 9, str02.data() + 10, 0);
+ VERIFY( str02 == L"Val d'Elsa" );
+
+ std::wstring str03(L"Novi Ligure");
+ str03.replace(11, 0, str03.data() + 4, 7);
+ VERIFY( str03 == L"Novi Ligure Ligure");
+
+ std::wstring str04(L"Trebisacce");
+ str04.replace(3, 4, str04.data(), 0);
+ VERIFY( str04 == L"Trecce" );
+
+ std::wstring str05(L"Altopiano della Sila");
+ str05.replace(1, 18, str05.data() + 19, 1);
+ VERIFY( str05 == L"Aaa" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+++ /dev/null
-// Copyright (C) 2011-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.4.6.5 basic_string::pop_back
-// { dg-options "-std=gnu++0x" }
-
-#include <string>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- const std::wstring cstr(L"Badger");
- std::wstring str = cstr;
- str.pop_back();
- VERIFY( str.size() == cstr.size() - 1 );
-
- str += cstr.back();
- VERIFY( str == cstr );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <algorithm> // for std::find
-#include <testsuite_hooks.h>
-
-bool test01(void)
-{
- bool test __attribute__((unused)) = true;
- typedef std::string::size_type csize_type;
- typedef std::string::const_reference cref;
- typedef std::string::reference ref;
-
- const char str_lit01[] = "ventura, california";
- const std::string str01(str_lit01);
- std::string str02("del mar, california");
- std::string str03(" and ");
- std::string str05;
-
- // string& replace(size_type pos, size_type n, const string& string)
- // string& replace(size_type pos1, size_type n1, const string& string,
- // size_type pos2, size_type n2)
- // string& replace(size_type pos, size_type n1, const char* s, size_type n2)
- // string& replace(size_type pos, size_type n1, const char* s)
- // string& replace(size_type pos, size_type n1, size_type n2, char c)
- // string& replace(iterator it1, iterator it2, const string& str)
- // string& replace(iterator it1, iterator it2, const chat* s, size_type n)
- // string& replace(iterator it1, iterator it2, const chat* s)
- // string& replace(iterator it1, iterator it2, size_type n, char c)
- // template<typename InputIter>
- // string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
-
- // with mods, from tstring.cc, from jason merrill, et. al.
- std::string X = "Hello";
- std::string x = X;
-
- char ch = x[0];
- VERIFY( ch == 'H' );
-
- std::string z = x.substr(2, 3);
- VERIFY( z == "llo" );
-
- x.replace(2, 2, "r");
- VERIFY( x == "Hero" );
-
- x = X;
- x.replace(0, 1, "j");
- VERIFY( x == "jello" );
-
- int ar[] = { 'H', 'e', 'l', 'l', 'o' };
- x.replace(std::find(x.begin(), x.end(), 'l'),
- std::find(x.rbegin(), x.rend(), 'l').base(), ar,
- ar + sizeof(ar) / sizeof(ar[0]));
- VERIFY( x == "jeHelloo" );
- return test;
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-void
-test02()
-{
- bool test __attribute__((unused)) = true;
- const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii";
- std::string aux = strlit;
- aux.replace(aux.begin()+5, aux.begin()+20,
- aux.begin()+10, aux.begin()+15);
- VERIFY(aux == "../thg piealei Bay/Kauai/Hawaii");
-
- aux = strlit;
- aux.replace(aux.begin() + 10, aux.begin() + 15,
- aux.begin() + 5, aux.begin() + 20);
- VERIFY(aux == "../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii");
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// Some more miscellaneous tests
-void
-test03()
-{
- bool test __attribute__((unused)) = true;
- const char* title01 = "nine types of ambiguity";
- const char* title02 = "ultra";
- std::string str01 = title01;
- std::string str02 = title02;
-
- str01.replace(0, 4, str02);
- VERIFY(str01 == "ultra types of ambiguity");
-
- str01.replace(15, 9, str02, 2, 2);
- VERIFY(str01 == "ultra types of tr");
-
- str01 = title01;
- str02.replace(0, 0, str01, 0, std::string::npos);
- VERIFY(str02 == "nine types of ambiguityultra");
-
- str02.replace(11, 2, title02, 5);
- VERIFY(str02 == "nine types ultra ambiguityultra");
-
- str02.replace(11, 5, title01, 2);
- VERIFY(str02 == "nine types ni ambiguityultra");
-
- str01.replace(str01.size(), 0, title02);
- VERIFY(str01 == "nine types of ambiguityultra");
-
- str01 = title01;
- str02 = title02;
- str01.replace(str01.begin(), str01.end(), str02);
- VERIFY(str01 == "ultra");
-
- str01.replace(str01.begin(), str01.begin(), title01, 4);
- VERIFY(str01 == "nineultra");
-
- str01.replace(str01.end(), str01.end(), title01 + 5, 5);
- VERIFY(str01 == "nineultratypes");
-
- str01.replace(str01.begin(), str01.end(), title02);
- VERIFY(str01 == "ultra");
-}
-
-int main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// Some more tests for
-// template<typename InputIter>
-// string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
-void
-test04()
-{
- bool test __attribute__((unused)) = true;
- std::string str01 = "geogaddi";
- std::string str02;
-
- typedef std::string::iterator iterator;
- typedef std::string::const_iterator const_iterator;
-
- iterator it1 = str01.begin();
- iterator it2 = str01.end();
- str02.replace(str02.begin(), str02.end(), it1, it2);
- VERIFY(str02 == "geogaddi");
-
- str02 = "boards";
- const_iterator c_it1 = str01.begin();
- const_iterator c_it2 = str01.end();
- str02.replace(str02.begin(), str02.end(), c_it1, c_it2);
- VERIFY(str02 == "geogaddi");
-
- str02 = "boards";
- const char* c_ptr1 = str01.c_str();
- const char* c_ptr2 = str01.c_str() + 8;
- str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2);
- VERIFY(str02 == "geogaddi");
-
- str02 = "boards";
- char* ptr1 = &*str01.begin();
- char* ptr2 = ptr1 + str01.length();
- str02.replace(str02.begin(), str02.end(), ptr1, ptr2);
- VERIFY(str02 == "geogaddi");
-}
-
-int main()
-{
- test04();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// We wrongly used __n1 instead of __foldn1 in the length_error
-// check at the beginning of replace(__pos, __n1, __s, __n2)
-void
-test05()
-{
- bool test __attribute__((unused)) = true;
- std::string str01 = "londinium";
- std::string str02 = "cydonia";
-
- str01.replace(0, 20, str02.c_str(), 3);
- VERIFY(str01 == "cyd");
-}
-
-int main()
-{
- test05();
- return 0;
-}
+++ /dev/null
-// 2004-01-26 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2004-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- std::string str01("Valle Del Salto");
- str01.replace(0, 5, str01.data() + 10, 5);
- VERIFY( str01 == "Salto Del Salto" );
-
- std::string str02("Colle di Val d'Elsa");
- str02.replace(0, 9, str02.data() + 10, 0);
- VERIFY( str02 == "Val d'Elsa" );
-
- std::string str03("Novi Ligure");
- str03.replace(11, 0, str03.data() + 4, 7);
- VERIFY( str03 == "Novi Ligure Ligure");
-
- std::string str04("Trebisacce");
- str04.replace(3, 4, str04.data(), 0);
- VERIFY( str04 == "Trecce" );
-
- std::string str05("Altopiano della Sila");
- str05.replace(1, 18, str05.data() + 19, 1);
- VERIFY( str05 == "Aaa" );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <algorithm> // for std::find
-#include <testsuite_hooks.h>
-
-bool test01(void)
-{
- bool test __attribute__((unused)) = true;
- typedef std::wstring::size_type csize_type;
- typedef std::wstring::const_reference cref;
- typedef std::wstring::reference ref;
-
- const wchar_t str_lit01[] = L"ventura, california";
- const std::wstring str01(str_lit01);
- std::wstring str02(L"del mar, california");
- std::wstring str03(L" and ");
- std::wstring str05;
-
- // wstring& replace(size_type pos, size_type n, const wstring& string)
- // wstring& replace(size_type pos1, size_type n1, const wstring& string,
- // size_type pos2, size_type n2)
- // wstring& replace(size_type pos, size_type n1, const wchar_t* s, size_type n2)
- // wstring& replace(size_type pos, size_type n1, const wchar_t* s)
- // wstring& replace(size_type pos, size_type n1, size_type n2, wchar_t c)
- // wstring& replace(iterator it1, iterator it2, const wstring& str)
- // wstring& replace(iterator it1, iterator it2, const wchar_t* s, size_type n)
- // wstring& replace(iterator it1, iterator it2, const wchar_t* s)
- // wstring& replace(iterator it1, iterator it2, size_type n, char c)
- // template<typename InputIter>
- // wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
-
- // with mods, from tstring.cc, from jason merrill, et. al.
- std::wstring X = L"Hello";
- std::wstring x = X;
-
- wchar_t ch = x[0];
- VERIFY( ch == L'H' );
-
- std::wstring z = x.substr(2, 3);
- VERIFY( z == L"llo" );
-
- x.replace(2, 2, L"r");
- VERIFY( x == L"Hero" );
-
- x = X;
- x.replace(0, 1, L"j");
- VERIFY( x == L"jello" );
-
- wchar_t ar[] = { L'H', L'e', L'l', L'l', L'o' };
- x.replace(std::find(x.begin(), x.end(), L'l'),
- std::find(x.rbegin(), x.rend(), L'l').base(), ar,
- ar + sizeof(ar) / sizeof(ar[0]));
- VERIFY( x == L"jeHelloo" );
- return test;
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-
-void
-test02()
-{
- bool test __attribute__((unused)) = true;
- const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii";
- std::wstring aux = strlit;
- aux.replace(aux.begin()+5, aux.begin()+20,
- aux.begin()+10, aux.begin()+15);
- VERIFY(aux == L"../thg piealei Bay/Kauai/Hawaii");
-
- aux = strlit;
- aux.replace(aux.begin() + 10, aux.begin() + 15,
- aux.begin() + 5, aux.begin() + 20);
- VERIFY(aux == L"../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii");
-}
-
-int main()
-{
- test02();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// Some more miscellaneous tests
-void
-test03()
-{
- bool test __attribute__((unused)) = true;
- const wchar_t* title01 = L"nine types of ambiguity";
- const wchar_t* title02 = L"ultra";
- std::wstring str01 = title01;
- std::wstring str02 = title02;
-
- str01.replace(0, 4, str02);
- VERIFY(str01 == L"ultra types of ambiguity");
-
- str01.replace(15, 9, str02, 2, 2);
- VERIFY(str01 == L"ultra types of tr");
-
- str01 = title01;
- str02.replace(0, 0, str01, 0, std::wstring::npos);
- VERIFY(str02 == L"nine types of ambiguityultra");
-
- str02.replace(11, 2, title02, 5);
- VERIFY(str02 == L"nine types ultra ambiguityultra");
-
- str02.replace(11, 5, title01, 2);
- VERIFY(str02 == L"nine types ni ambiguityultra");
-
- str01.replace(str01.size(), 0, title02);
- VERIFY(str01 == L"nine types of ambiguityultra");
-
- str01 = title01;
- str02 = title02;
- str01.replace(str01.begin(), str01.end(), str02);
- VERIFY(str01 == L"ultra");
-
- str01.replace(str01.begin(), str01.begin(), title01, 4);
- VERIFY(str01 == L"nineultra");
-
- str01.replace(str01.end(), str01.end(), title01 + 5, 5);
- VERIFY(str01 == L"nineultratypes");
-
- str01.replace(str01.begin(), str01.end(), title02);
- VERIFY(str01 == L"ultra");
-}
-
-int main()
-{
- test03();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// Some more tests for
-// template<typename InputIter>
-// wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
-void
-test04()
-{
- bool test __attribute__((unused)) = true;
- std::wstring str01 = L"geogaddi";
- std::wstring str02;
-
- typedef std::wstring::iterator iterator;
- typedef std::wstring::const_iterator const_iterator;
-
- iterator it1 = str01.begin();
- iterator it2 = str01.end();
- str02.replace(str02.begin(), str02.end(), it1, it2);
- VERIFY(str02 == L"geogaddi");
-
- str02 = L"boards";
- const_iterator c_it1 = str01.begin();
- const_iterator c_it2 = str01.end();
- str02.replace(str02.begin(), str02.end(), c_it1, c_it2);
- VERIFY(str02 == L"geogaddi");
-
- str02 = L"boards";
- const wchar_t* c_ptr1 = str01.c_str();
- const wchar_t* c_ptr2 = str01.c_str() + 8;
- str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2);
- VERIFY(str02 == L"geogaddi");
-
- str02 = L"boards";
- wchar_t* ptr1 = &*str01.begin();
- wchar_t* ptr2 = ptr1 + str01.length();
- str02.replace(str02.begin(), str02.end(), ptr1, ptr2);
- VERIFY(str02 == L"geogaddi");
-}
-
-int main()
-{
- test04();
- return 0;
-}
+++ /dev/null
-// 1999-06-10 bkoz
-
-// Copyright (C) 1994-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-// We wrongly used __n1 instead of __foldn1 in the length_error
-// check at the beginning of replace(__pos, __n1, __s, __n2)
-void
-test05()
-{
- bool test __attribute__((unused)) = true;
- std::wstring str01 = L"londinium";
- std::wstring str02 = L"cydonia";
-
- str01.replace(0, 20, str02.c_str(), 3);
- VERIFY(str01 == L"cyd");
-}
-
-int main()
-{
- test05();
- return 0;
-}
+++ /dev/null
-// 2004-01-26 Paolo Carlini <pcarlini@suse.de>
-
-// Copyright (C) 2004-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// 21.3.5.6 basic_string::replace
-
-#include <string>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- std::wstring str01(L"Valle Del Salto");
- str01.replace(0, 5, str01.data() + 10, 5);
- VERIFY( str01 == L"Salto Del Salto" );
-
- std::wstring str02(L"Colle di Val d'Elsa");
- str02.replace(0, 9, str02.data() + 10, 0);
- VERIFY( str02 == L"Val d'Elsa" );
-
- std::wstring str03(L"Novi Ligure");
- str03.replace(11, 0, str03.data() + 4, 7);
- VERIFY( str03 == L"Novi Ligure Ligure");
-
- std::wstring str04(L"Trebisacce");
- str04.replace(3, 4, str04.data(), 0);
- VERIFY( str04 == L"Trecce" );
-
- std::wstring str05(L"Altopiano della Sila");
- str05.replace(1, 18, str05.data() + 19, 1);
- VERIFY( str05 == L"Aaa" );
-}
-
-int main()
-{
- test01();
- return 0;
-}
+++ /dev/null
-// { dg-options "-std=gnu++0x" }
-// { dg-require-string-conversions "" }
-
-// Copyright (C) 2010-2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library. This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3. If not see
-// <http://www.gnu.org/licenses/>.
-
-// NOTE: This makes use of the fact that we know how moveable
-// is implemented on vstring (via swap). If the implementation changes
-// this test may begin to fail.
-
-#include <ext/vstring.h>
-#include <utility>
-#include <testsuite_hooks.h>
-
-void test01()
-{
- bool test __attribute__((unused)) = true;
-
- __gnu_cxx::__sso_string a, b;
- a.push_back('1');
- b.assign(std::move(a));
- VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
-}
-
-void test02()
-{
- bool test __attribute__((unused)) = true;
-
- __gnu_cxx::__rc_string a, b;
- a.push_back('1');
- b.assign(std::move(a));
- VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
-}
-
-int main()
-{
- test01();
- test02();
- return 0;
-}
--- /dev/null
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on vstring (via swap). If the implementation changes
+// this test may begin to fail.
+
+#include <ext/vstring.h>
+#include <utility>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__sso_string a, b;
+ a.push_back('1');
+ b.assign(std::move(a));
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ __gnu_cxx::__rc_string a, b;
+ a.push_back('1');
+ b.assign(std::move(a));
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}