summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/21_strings/basic_string/insert
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-18 05:04:14 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2003-03-18 05:04:14 +0000
commit4aca39bba4209cb95f2219085d85e41a3d4e4e1c (patch)
treec6e9fc88ee389602c75762e964df73cf7771d3e2 /libstdc++-v3/testsuite/21_strings/basic_string/insert
parentf81dcff3f5d3ae7290eb1c20af31d7e5427e96aa (diff)
downloadgcc-4aca39bba4209cb95f2219085d85e41a3d4e4e1c.tar.gz
2003-03-18 Paolo Carlini <pcarlini@unitus.it>
Reshuffle 21_strings testsuite. * testsuite/21_strings/append.cc, c_strings.cc, invariants.cc, assign.cc, ctor_copy_dtor.cc, nonmember.cc, capacity.cc, element_access.cc, operations.cc, char_traits_requirements.cc, find.cc, replace.cc, char_traits_typedefs.cc, insert.cc, rfind.cc, compare.cc, inserters_extractors.cc, substr.cc: Split up, add wchar_t tests as follows. * 21_strings/basic_string/append/char/1.cc: New. * 21_strings/basic_string/append/wchar_t/1.cc: New. * 21_strings/basic_string/assign/char/1.cc: New. * 21_strings/basic_string/assign/char/2.cc: New. * 21_strings/basic_string/assign/char/3.cc: New. * 21_strings/basic_string/assign/wchar_t/1.cc: New. * 21_strings/basic_string/assign/wchar_t/2.cc: New. * 21_strings/basic_string/assign/wchar_t/3.cc: New. * 21_strings/basic_string/capacity/1.cc: New. * 21_strings/basic_string/capacity/char/1.cc: New. * 21_strings/basic_string/capacity/char/2.cc: New. * 21_strings/basic_string/capacity/wchar_t/1.cc: New. * 21_strings/basic_string/capacity/wchar_t/2.cc: New. * 21_strings/basic_string/compare/char/1.cc: New. * 21_strings/basic_string/compare/wchar_t/1.cc: New. * 21_strings/basic_string/cons/char/1.cc: New. * 21_strings/basic_string/cons/char/2.cc: New. * 21_strings/basic_string/cons/char/3.cc: New. * 21_strings/basic_string/cons/char/4.cc: New. * 21_strings/basic_string/cons/char/5.cc: New. * 21_strings/basic_string/cons/wchar_t/1.cc: New. * 21_strings/basic_string/cons/wchar_t/2.cc: New. * 21_strings/basic_string/cons/wchar_t/3.cc: New. * 21_strings/basic_string/cons/wchar_t/4.cc: New. * 21_strings/basic_string/cons/wchar_t/5.cc: New. * 21_strings/basic_string/element_access/char/1.cc: New. * 21_strings/basic_string/element_access/char/2.cc: New. * 21_strings/basic_string/element_access/char/3.cc: New. * 21_strings/basic_string/element_access/wchar_t/1.cc: New. * 21_strings/basic_string/element_access/wchar_t/2.cc: New. * 21_strings/basic_string/element_access/wchar_t/3.cc: New. * 21_strings/basic_string/find/char/1.cc: New. * 21_strings/basic_string/find/wchar_t/1.cc: New. * 21_strings/basic_string/insert/char/1.cc: New. * 21_strings/basic_string/insert/char/2.cc: New. * 21_strings/basic_string/insert/wchar_t/1.cc: New. * 21_strings/basic_string/insert/wchar_t/2.cc: New. * 21_strings/basic_string/inserters_extractors/char/1.cc: New. * 21_strings/basic_string/inserters_extractors/char/4.cc: New. * 21_strings/basic_string/inserters_extractors/char/5.cc: New. * 21_strings/basic_string/inserters_extractors/char/6.cc: New. * 21_strings/basic_string/inserters_extractors/char/7.cc: New. * 21_strings/basic_string/inserters_extractors/char/8.cc: New. * 21_strings/basic_string/inserters_extractors/char/9.cc: New. * 21_strings/basic_string/inserters_extractors/wchar_t/1.cc: New. * 21_strings/basic_string/inserters_extractors/wchar_t/4.cc: New. * 21_strings/basic_string/inserters_extractors/wchar_t/5.cc: New. * 21_strings/basic_string/inserters_extractors/wchar_t/6.cc: New. * 21_strings/basic_string/inserters_extractors/wchar_t/7.cc: New. * 21_strings/basic_string/inserters_extractors/wchar_t/8.cc: New. * 21_strings/basic_string/inserters_extractors/wchar_t/9.cc: New. * 21_strings/basic_string/operators/char/1.cc: New. * 21_strings/basic_string/operators/char/2.cc: New. * 21_strings/basic_string/operators/wchar_t/1.cc: New. * 21_strings/basic_string/operators/wchar_t/2.cc: New. * 21_strings/basic_string/replace/char/1.cc: New. * 21_strings/basic_string/replace/char/2.cc: New. * 21_strings/basic_string/replace/char/3.cc: New. * 21_strings/basic_string/replace/char/4.cc: New. * 21_strings/basic_string/replace/char/5.cc: New. * 21_strings/basic_string/replace/wchar_t/1.cc: New. * 21_strings/basic_string/replace/wchar_t/2.cc: New. * 21_strings/basic_string/replace/wchar_t/3.cc: New. * 21_strings/basic_string/replace/wchar_t/4.cc: New. * 21_strings/basic_string/replace/wchar_t/5.cc: New. * 21_strings/basic_string/rfind/char/1.cc: New. * 21_strings/basic_string/rfind/char/2.cc: New. * 21_strings/basic_string/rfind/char/3.cc: New. * 21_strings/basic_string/rfind/wchar_t/1.cc: New. * 21_strings/basic_string/rfind/wchar_t/2.cc: New. * 21_strings/basic_string/rfind/wchar_t/3.cc: New. * 21_strings/basic_string/substr/char/1.cc: New. * 21_strings/basic_string/substr/wchar_t/1.cc: New. * 21_strings/c_strings/char/1.cc: New. * 21_strings/c_strings/char/2.cc: New. * 21_strings/c_strings/wchar_t/1.cc: New. * 21_strings/c_strings/wchar_t/2.cc: New. * 21_strings/char_traits/requirements/char/1.cc: New. * 21_strings/char_traits/requirements/wchar_t/1.cc: New. * 21_strings/char_traits/typedefs/char/1.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64524 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/21_strings/basic_string/insert')
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc195
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc87
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc195
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc87
4 files changed, 564 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc
new file mode 100644
index 00000000000..a6052e2170b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc
@@ -0,0 +1,195 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 21.3.5.4 basic_string::insert
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test = true;
+ typedef std::string::size_type csize_type;
+ typedef std::string::iterator citerator;
+ csize_type npos = std::string::npos;
+ 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" );
+
+#ifdef DEBUG_ASSERT
+ assert(test);
+#endif
+ return test;
+}
+
+int main()
+{
+ __gnu_cxx_test::set_memory_limits();
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc
new file mode 100644
index 00000000000..80b0cee58b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc
@@ -0,0 +1,87 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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 = 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");
+
+#ifdef DEBUG_ASSERT
+ assert(test);
+#endif
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc
new file mode 100644
index 00000000000..96f71b0839e
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc
@@ -0,0 +1,195 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 21.3.5.4 basic_string::insert
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test = true;
+ typedef std::wstring::size_type csize_type;
+ typedef std::wstring::iterator citerator;
+ csize_type npos = std::wstring::npos;
+ 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" );
+
+#ifdef DEBUG_ASSERT
+ assert(test);
+#endif
+ return test;
+}
+
+int main()
+{
+ __gnu_cxx_test::set_memory_limits();
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc
new file mode 100644
index 00000000000..04cc454e14b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc
@@ -0,0 +1,87 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 2003 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 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 = 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");
+
+#ifdef DEBUG_ASSERT
+ assert(test);
+#endif
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}