summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/21_strings/basic_string/replace
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/21_strings/basic_string/replace
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/21_strings/basic_string/replace')
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc82
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc46
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc74
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc67
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc54
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc82
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc47
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc74
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc67
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc54
12 files changed, 733 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc
new file mode 100644
index 000000000..7d6d3a9b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc
@@ -0,0 +1,82 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+// 2003, 2004, 2005, 2006, 2007, 2009 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc
new file mode 100644
index 000000000..3721ca8c3
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc
@@ -0,0 +1,46 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc
new file mode 100644
index 000000000..c462f3816
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc
@@ -0,0 +1,74 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc
new file mode 100644
index 000000000..9188837c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc
@@ -0,0 +1,67 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc
new file mode 100644
index 000000000..7a3f6aa16
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc
@@ -0,0 +1,43 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc
new file mode 100644
index 000000000..d332498ed
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc
@@ -0,0 +1,54 @@
+// 2004-01-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc
new file mode 100644
index 000000000..c3afcafac
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc
@@ -0,0 +1,82 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+// 2003, 2004, 2005, 2006, 2007, 2009 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc
new file mode 100644
index 000000000..83008ba14
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc
@@ -0,0 +1,47 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc
new file mode 100644
index 000000000..34031673c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc
@@ -0,0 +1,74 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc
new file mode 100644
index 000000000..60d6a1579
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc
@@ -0,0 +1,67 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc
new file mode 100644
index 000000000..959b515b4
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc
@@ -0,0 +1,43 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1994, 1999, 2001, 2002, 2003, 2009
+// 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc
new file mode 100644
index 000000000..98c236cf6
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc
@@ -0,0 +1,54 @@
+// 2004-01-26 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 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;
+}