summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/21_strings/basic_string
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/21_strings/basic_string')
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/40160.cc26
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc158
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc66
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc55
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc158
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc66
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc55
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc55
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc58
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc58
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc52
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc58
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc58
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc200
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc99
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/18654.cc55
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/2.cc42
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc42
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc99
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc55
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc42
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc42
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/compare/char/1.cc135
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/compare/char/13650.cc47
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/1.cc133
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/13650.cc47
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc161
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/2.cc41
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/3.cc69
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/4.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/42261.cc35
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/5.cc44
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/6.cc55
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable.cc47
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc54
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/1.cc161
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/2.cc41
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/3.cc69
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/4.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/42261.cc35
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/5.cc44
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/6.cc55
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc47
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc54
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc88
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/2.cc110
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc31
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/3.cc83
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/4.cc49
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/empty.cc39
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/front_back.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc88
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/2.cc111
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc31
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/3.cc83
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/4.cc49
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/empty.cc39
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/front_back.cc43
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/char/1.cc93
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/char/2.cc92
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/char/3.cc92
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc42
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/1.cc93
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/2.cc92
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/3.cc92
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc42
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc72
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc189
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc82
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc189
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc82
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/1.cc165
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/10.cc86
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/11.cc85
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/28277.cc54
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/4.cc65
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/5.cc88
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/6.cc61
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/7.cc53
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/8.cc53
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/9.cc56
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-in.cc84
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-out.cc84
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/1.cc165
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc84
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/11.cc83
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/28277.cc54
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/4.cc65
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/5.cc86
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/6.cc61
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/7.cc53
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/8.cc53
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/9.cc56
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc64
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc137
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc137
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc202
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc165
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc114
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc165
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc152
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc152
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc63
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc64
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc140
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc140
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc205
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc168
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc117
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc168
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc155
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc155
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc66
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operations/char/1.cc41
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operations/wchar_t/1.cc41
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc49
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/char/2.cc294
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/char/3.cc93
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/char/4.cc79
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc49
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc294
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/3.cc93
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/4.cc79
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/pthread18185.cc52
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/pthread4.cc106
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/range_access.cc37
-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
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/citerators.cc29
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc27
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/basic.cc41
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/generation_prohibited.cc54
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/propagation_consistent.cc42
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc27
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc22
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc24
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc24
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/debug.cc27
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc22
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/requirements/typedefs.cc28
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/1.cc92
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/2.cc50
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/3.cc64
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/1.cc92
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/2.cc50
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/3.cc64
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/substr/char/1.cc74
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/substr/wchar_t/1.cc74
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc47
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/types/23767.cc43
162 files changed, 12764 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/40160.cc b/libstdc++-v3/testsuite/21_strings/basic_string/40160.cc
new file mode 100644
index 000000000..ec82d474c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/40160.cc
@@ -0,0 +1,26 @@
+// -*- C++ -*-
+
+// Copyright (C) 2009, 2010 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/>.
+
+// NB: This issue affected only debug-mode.
+
+// { dg-options "-fno-rtti" }
+// { dg-do compile }
+
+// libstdc++/40160
+#include <string>
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc
new file mode 100644
index 000000000..850bd52b7
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc
@@ -0,0 +1,158 @@
+// 1999-07-08 bkoz
+
+// Copyright (C) 1999, 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.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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc
new file mode 100644
index 000000000..acfe69d2b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc
@@ -0,0 +1,66 @@
+// 2004-25-10 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc
new file mode 100644
index 000000000..00f2179aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc
@@ -0,0 +1,55 @@
+// 2004-25-10 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc
new file mode 100644
index 000000000..81c388980
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc
@@ -0,0 +1,158 @@
+// 1999-07-08 bkoz
+
+// Copyright (C) 1999, 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.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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc
new file mode 100644
index 000000000..3b30d412a
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc
@@ -0,0 +1,66 @@
+// 2004-25-10 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc
new file mode 100644
index 000000000..dca5dbdaf
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc
@@ -0,0 +1,55 @@
+// 2004-25-10 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 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 wchar_t * source = L"Kesto";
+
+ for (unsigned i = 0; i < 10; ++i)
+ {
+ wstring one(source);
+ wstring two(source);
+ for (unsigned j = 0; j < 18; ++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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc
new file mode 100644
index 000000000..8d3208daf
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc
@@ -0,0 +1,55 @@
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc
new file mode 100644
index 000000000..56ab4d280
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc
@@ -0,0 +1,58 @@
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc
new file mode 100644
index 000000000..45e3fbabc
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc
@@ -0,0 +1,58 @@
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003, 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc
new file mode 100644
index 000000000..064a8cb7d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc
new file mode 100644
index 000000000..ebc02e4b4
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc
@@ -0,0 +1,52 @@
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc
new file mode 100644
index 000000000..ec5351254
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc
@@ -0,0 +1,58 @@
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc
new file mode 100644
index 000000000..ef56a795c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc
@@ -0,0 +1,58 @@
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003, 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 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc
new file mode 100644
index 000000000..7aa48d814
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010 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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc
new file mode 100644
index 000000000..64c5869b1
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/1.cc
@@ -0,0 +1,200 @@
+// 1999-05-11 bkoz
+
+// Copyright (C) 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.3 string capacity
+
+#include <string>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ struct A { };
+
+template<typename T>
+ bool
+ operator==(const A<T>&, const A<T>&) { return true; }
+
+template<typename T>
+ bool
+ operator<(const A<T>&, const A<T>&) { return true; }
+
+struct B { };
+
+// char_traits specialization
+namespace std
+{
+ template<>
+ struct char_traits<A<B> >
+ {
+ typedef A<B> char_type;
+ // Unsigned as wint_t in unsigned.
+ typedef unsigned long int_type;
+ typedef streampos pos_type;
+ typedef streamoff off_type;
+ typedef mbstate_t state_type;
+
+ static void
+ assign(char_type& __c1, const char_type& __c2)
+ { __c1 = __c2; }
+
+ static bool
+ eq(const char_type& __c1, const char_type& __c2)
+ { return __c1 == __c2; }
+
+ static bool
+ lt(const char_type& __c1, const char_type& __c2)
+ { return __c1 < __c2; }
+
+ static int
+ compare(const char_type* __s1, const char_type* __s2, size_t __n)
+ {
+ for (size_t __i = 0; __i < __n; ++__i)
+ if (!eq(__s1[__i], __s2[__i]))
+ return lt(__s1[__i], __s2[__i]) ? -1 : 1;
+ return 0;
+ }
+
+ static size_t
+ length(const char_type* __s)
+ {
+ const char_type* __p = __s;
+ while (__p)
+ ++__p;
+ return (__p - __s);
+ }
+
+ static const char_type*
+ find(const char_type* __s, size_t __n, const char_type& __a)
+ {
+ for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
+ if (*__p == __a) return __p;
+ return 0;
+ }
+
+ static char_type*
+ move(char_type* __s1, const char_type* __s2, size_t __n)
+ { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
+
+ static char_type*
+ copy(char_type* __s1, const char_type* __s2, size_t __n)
+ { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
+
+ static char_type*
+ assign(char_type* __s, size_t __n, char_type __a)
+ {
+ for (char_type* __p = __s; __p < __s + __n; ++__p)
+ assign(*__p, __a);
+ return __s;
+ }
+
+ static char_type
+ to_char_type(const int_type&)
+ { return char_type(); }
+
+ static int_type
+ to_int_type(const char_type&) { return int_type(); }
+
+ static bool
+ eq_int_type(const int_type& __c1, const int_type& __c2)
+ { return __c1 == __c2; }
+
+ static int_type
+ eof() { return static_cast<int_type>(-1); }
+
+ static int_type
+ not_eof(const int_type& __c)
+ { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
+ };
+} // namespace std
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ // non POD types : resize, capacity, reserve
+ std::basic_string< A<B> > str02;
+ typedef std::basic_string< A<B> >::size_type size_type_o;
+ size_type_o sz03;
+ size_type_o sz04;
+
+ sz03 = str02.capacity();
+ str02.reserve(100);
+ sz04 = str02.capacity();
+ VERIFY( sz04 >= sz03 );
+ VERIFY( sz04 >= 100 );
+ str02.reserve();
+ sz03 = str02.capacity();
+ VERIFY( sz03 == 0 );
+
+ sz03 = str02.size() + 5;
+ str02.resize(sz03);
+ sz04 = str02.size();
+ VERIFY( sz03 == sz04 );
+
+ sz03 = str02.size() - 5;
+ str02.resize(sz03);
+ sz04 = str02.size();
+ VERIFY( sz03 == sz04 );
+
+ A<B> inst_obj;
+ std::basic_string<A<B> > str07(30, inst_obj);
+ std::basic_string<A<B> > str08 = str07;
+ str07 = str08 + str07;
+ VERIFY( str07.capacity() >= str07.size() );
+ VERIFY( str08.capacity() >= str08.size() );
+
+ // non-POD types: size, length, max_size, clear(), empty()
+ bool b01 = str02.empty();
+ VERIFY( b01 == true );
+ sz03 = str02.size();
+ sz04 = str02.length();
+ VERIFY( sz03 == sz04 );
+ str02.c_str();
+ sz03 = str02.size();
+ sz04 = str02.length();
+ VERIFY( sz03 == sz04 );
+
+ sz03 = str02.max_size();
+ VERIFY( sz03 >= sz04 );
+
+ sz03 = str02.size();
+ str02.clear();
+ b01 = str02.empty();
+ VERIFY( b01 == true );
+ sz04 = str02.size();
+ VERIFY( sz03 >= sz04 );
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template
+ const std::basic_string< A<B> >::size_type
+ std::basic_string< A<B> >::_Rep::_S_max_size;
+
+template
+ const A<B>
+ std::basic_string< A<B> >::_Rep::_S_terminal;
+#endif
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc
new file mode 100644
index 000000000..2bd36ebf9
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/1.cc
@@ -0,0 +1,99 @@
+// 1999-05-11 bkoz
+
+// Copyright (C) 1999, 2002, 2003, 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.3 string capacity
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ // POD types : resize, capacity, reserve
+ bool test __attribute__((unused)) = true;
+ std::string str01;
+ typedef std::string::size_type size_type_s;
+
+ size_type_s sz01 = str01.capacity();
+ str01.reserve(100);
+ size_type_s sz02 = str01.capacity();
+ VERIFY( sz02 >= sz01 );
+ VERIFY( sz02 >= 100 );
+ str01.reserve();
+ sz01 = str01.capacity();
+ VERIFY( sz01 == 0 );
+
+ sz01 = str01.size() + 5;
+ str01.resize(sz01);
+ sz02 = str01.size();
+ VERIFY( sz01 == sz02 );
+
+ sz01 = str01.size() - 5;
+ str01.resize(sz01);
+ sz02 = str01.size();
+ VERIFY( sz01 == sz02 );
+
+ std::string str05(30, 'q');
+ std::string str06 = str05;
+ str05 = str06 + str05;
+ VERIFY( str05.capacity() >= str05.size() );
+ VERIFY( str06.capacity() >= str06.size() );
+
+ // POD types: size, length, max_size, clear(), empty()
+ bool b01;
+ std::string str011;
+ b01 = str01.empty();
+ VERIFY( b01 == true );
+ sz01 = str01.size();
+ sz02 = str01.length();
+ VERIFY( sz01 == sz02 );
+ str01.c_str();
+ sz01 = str01.size();
+ sz02 = str01.length();
+ VERIFY( sz01 == sz02 );
+
+ sz01 = str01.length();
+ str01.c_str();
+ str011 = str01 + "_addendum_";
+ str01.c_str();
+ sz02 = str01.length();
+ VERIFY( sz01 == sz02 );
+ sz02 = str011.length();
+ VERIFY( sz02 > sz01 );
+
+ // trickster allocator issues involved with these:
+ std::string str3 = "8-chars_8-chars_";
+ std::string str4 = str3 + "7-chars";
+
+ sz01 = str01.size();
+ sz02 = str01.max_size();
+ VERIFY( sz02 >= sz01 );
+
+ sz01 = str01.size();
+ str01.clear();
+ b01 = str01.empty();
+ VERIFY( b01 == true );
+ sz02 = str01.size();
+ VERIFY( sz01 >= sz02 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/18654.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/18654.cc
new file mode 100644
index 000000000..e9fa200a5
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/18654.cc
@@ -0,0 +1,55 @@
+// 2004-11-29 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 Free Software Foundation
+//
+// 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.3 string capacity
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/18654
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef string::size_type size_type;
+
+ // Our current implementation provides exact shrink-to-size
+ // and shrink-to-fit (in the future, maybe this will change
+ // for short strings).
+ const size_type minsize = 2 << 0;
+ const size_type maxsize = 2 << 20;
+ for (size_type i = minsize; i <= maxsize; i *= 2)
+ {
+ string str(i, 'x');
+ str.reserve(3 * i);
+
+ str.reserve(2 * i);
+ VERIFY( str.capacity() == 2 * i );
+
+ str.reserve();
+ VERIFY( str.capacity() == i );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/2.cc
new file mode 100644
index 000000000..dd7574b45
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/2.cc
@@ -0,0 +1,42 @@
+// 1999-05-11 bkoz
+
+// Copyright (C) 1999, 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.3 string capacity
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/4548
+// http://gcc.gnu.org/ml/libstdc++/2001-11/msg00150.html
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string str01 = "twelve chars";
+ // str01 becomes shared
+ std::string str02 = str01;
+ str01.reserve(1);
+ VERIFY( str01.capacity() == 12 );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc
new file mode 100644
index 000000000..cd0d4eb51
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/char/shrink_to_fit.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string s(100, 'a');
+ s.push_back('b');
+ s.push_back('b');
+ VERIFY( s.size() < s.capacity() );
+ s.shrink_to_fit();
+ VERIFY( s.size() == s.capacity() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc
new file mode 100644
index 000000000..427240235
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/1.cc
@@ -0,0 +1,99 @@
+// 1999-05-11 bkoz
+
+// Copyright (C) 1999, 2002, 2003, 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.3 string capacity
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ // POD types : resize, capacity, reserve
+ bool test __attribute__((unused)) = true;
+ std::wstring str01;
+ typedef std::wstring::size_type size_type_s;
+
+ size_type_s sz01 = str01.capacity();
+ str01.reserve(100);
+ size_type_s sz02 = str01.capacity();
+ VERIFY( sz02 >= sz01 );
+ VERIFY( sz02 >= 100 );
+ str01.reserve();
+ sz01 = str01.capacity();
+ VERIFY( sz01 == 0 );
+
+ sz01 = str01.size() + 5;
+ str01.resize(sz01);
+ sz02 = str01.size();
+ VERIFY( sz01 == sz02 );
+
+ sz01 = str01.size() - 5;
+ str01.resize(sz01);
+ sz02 = str01.size();
+ VERIFY( sz01 == sz02 );
+
+ std::wstring str05(30, L'q');
+ std::wstring str06 = str05;
+ str05 = str06 + str05;
+ VERIFY( str05.capacity() >= str05.size() );
+ VERIFY( str06.capacity() >= str06.size() );
+
+ // POD types: size, length, max_size, clear(), empty()
+ bool b01;
+ std::wstring str011;
+ b01 = str01.empty();
+ VERIFY( b01 == true );
+ sz01 = str01.size();
+ sz02 = str01.length();
+ VERIFY( sz01 == sz02 );
+ str01.c_str();
+ sz01 = str01.size();
+ sz02 = str01.length();
+ VERIFY( sz01 == sz02 );
+
+ sz01 = str01.length();
+ str01.c_str();
+ str011 = str01 + L"_addendum_";
+ str01.c_str();
+ sz02 = str01.length();
+ VERIFY( sz01 == sz02 );
+ sz02 = str011.length();
+ VERIFY( sz02 > sz01 );
+
+ // trickster allocator issues involved with these:
+ std::wstring str3 = L"8-chars_8-chars_";
+ std::wstring str4 = str3 + L"7-chars";
+
+ sz01 = str01.size();
+ sz02 = str01.max_size();
+ VERIFY( sz02 >= sz01 );
+
+ sz01 = str01.size();
+ str01.clear();
+ b01 = str01.empty();
+ VERIFY( b01 == true );
+ sz02 = str01.size();
+ VERIFY( sz01 >= sz02 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc
new file mode 100644
index 000000000..fd5117576
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc
@@ -0,0 +1,55 @@
+// 2004-11-29 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 Free Software Foundation
+//
+// 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.3 string capacity
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/18654
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ typedef wstring::size_type size_type;
+
+ // Our current implementation provides exact shrink-to-size
+ // and shrink-to-fit (in the future, maybe this will change
+ // for short strings).
+ const size_type minsize = 2 << 0;
+ const size_type maxsize = 2 << 20;
+ for (size_type i = minsize; i <= maxsize; i *= 2)
+ {
+ wstring str(i, L'x');
+ str.reserve(3 * i);
+
+ str.reserve(2 * i);
+ VERIFY( str.capacity() == 2 * i );
+
+ str.reserve();
+ VERIFY( str.capacity() == i );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc
new file mode 100644
index 000000000..564a3219f
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/2.cc
@@ -0,0 +1,42 @@
+// 1999-05-11 bkoz
+
+// Copyright (C) 1999, 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.3 string capacity
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/4548
+// http://gcc.gnu.org/ml/libstdc++/2001-11/msg00150.html
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring str01 = L"twelve chars";
+ // str01 becomes shared
+ std::wstring str02 = str01;
+ str01.reserve(1);
+ VERIFY( str01.capacity() == 12 );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc
new file mode 100644
index 000000000..88f7c0ab0
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/capacity/wchar_t/shrink_to_fit.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-01-08 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/42573
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring s(100, L'a');
+ s.push_back(L'b');
+ s.push_back(L'b');
+ VERIFY( s.size() < s.capacity() );
+ s.shrink_to_fit();
+ VERIFY( s.size() == s.capacity() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/1.cc
new file mode 100644
index 000000000..d58b02336
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/1.cc
@@ -0,0 +1,135 @@
+// 980930 bkoz work with libstdc++v3
+
+// Copyright (C) 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.6.8 basic_string::compare
+// int compare(const basic_string& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string& str,
+// size_type pos2, size_type n2) const;
+// int compare(const charT* s) const;
+// int compare(size_type pos1, size_type n1,
+// const charT* s, size_type n2 = npos) const;
+
+// NB compare should be thought of as a lexographical compare, ie how
+// things would be sorted in a dictionary.
+
+#include <string>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+enum want_value {lt=0, z=1, gt=2};
+
+int
+test_value(int result, want_value expected);
+
+int
+test_value(int result, want_value expected)
+{
+ bool test __attribute__((unused)) = true;
+ bool pass = false;
+
+ switch (expected) {
+ case lt:
+ if (result < 0)
+ pass = true;
+ break;
+ case z:
+ if (!result)
+ pass = true;
+ break;
+ case gt:
+ if (result > 0)
+ pass = true;
+ break;
+ default:
+ pass = false; //should not get here
+ }
+ VERIFY(pass);
+ return 0;
+}
+
+
+int
+test01()
+{
+ using namespace std;
+
+ string str_0("costa rica");
+ string str_1("costa marbella");
+ string str_2;
+
+ //sanity check
+ test_value(strcmp("costa marbella", "costa rica"), lt);
+ test_value(strcmp("costa rica", "costa rica"), z);
+ test_value(strcmp(str_1.data(), str_0.data()), lt);
+ test_value(strcmp(str_0.data(), str_1.data()), gt);
+ test_value(strncmp(str_1.data(), str_0.data(), 6), z);
+ test_value(strncmp(str_1.data(), str_0.data(), 14), lt);
+ test_value(memcmp(str_1.data(), str_0.data(), 6), z);
+ test_value(memcmp(str_1.data(), str_0.data(), 14), lt);
+ test_value(memcmp("costa marbella", "costa rica", 14), lt);
+
+ // int compare(const basic_string& str) const;
+ test_value(str_0.compare(str_1), gt); //because r>m
+ test_value(str_1.compare(str_0), lt); //because m<r
+ str_2 = str_0;
+ test_value(str_2.compare(str_0), z);
+ str_2 = "cost";
+ test_value(str_2.compare(str_0), lt);
+ str_2 = "costa ricans";
+ test_value(str_2.compare(str_0), gt);
+
+ // int compare(size_type pos1, size_type n1, const basic_string& str) const;
+ test_value(str_1.compare(0, 6, str_0), lt);
+ str_2 = "cost";
+ test_value(str_1.compare(0, 4, str_2), z);
+ test_value(str_1.compare(0, 5, str_2), gt);
+
+ // int compare(size_type pos1, size_type n1, const basic_string& str,
+ // size_type pos2, size_type n2) const;
+ test_value(str_1.compare(0, 6, str_0, 0, 6), z);
+ test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
+ test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
+
+ // int compare(const charT* s) const;
+ test_value(str_0.compare("costa marbella"), gt);
+ test_value(str_1.compare("costa rica"), lt);
+ str_2 = str_0;
+ test_value(str_2.compare("costa rica"), z);
+ test_value(str_2.compare("cost"), gt);
+ test_value(str_2.compare("costa ricans"), lt);
+
+ // int compare(size_type pos, size_type n1, const charT* str,
+ // size_type n2 = npos) const;
+ test_value(str_1.compare(0, 6, "costa rica", 0, 6), z);
+ test_value(str_1.compare(0, 7, "costa rica", 0, 7), lt);
+ test_value(str_0.compare(0, 7, "costa marbella", 0, 7), gt);
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/13650.cc b/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/13650.cc
new file mode 100644
index 000000000..e930c2ef2
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/compare/char/13650.cc
@@ -0,0 +1,47 @@
+// 2004-01-13 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 Free Software Foundation
+//
+// 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.6.8 basic_string::compare [lib.string::compare]
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/13650
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ const char lit_01[] = { 'w', 'e', '\0', 'r', 'd' };
+ const char lit_02[] = { 'w', 'e', 'i', '\0', 'd' };
+
+ const char lit_ref_a[] = { 'w', 'e', '\0', 'q', 'd' };
+ const string str_a(lit_ref_a, 5);
+ VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
+
+ const char lit_ref_b[] = { 'w', 'e', 'i' };
+ const string str_b(lit_ref_b, 3);
+ VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/1.cc
new file mode 100644
index 000000000..78cb0db4d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/1.cc
@@ -0,0 +1,133 @@
+// 980930 bkoz work with libstdc++v3
+
+// Copyright (C) 1998, 1999, 2003, 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.6.8 basic_string::compare
+// int compare(const basic_string& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string& str) const;
+// int compare(size_type pos1, size_type n1, const basic_string& str,
+// size_type pos2, size_type n2) const;
+// int compare(const charT* s) const;
+// int compare(size_type pos1, size_type n1,
+// const charT* s, size_type n2 = npos) const;
+
+// NB compare should be thought of as a lexographical compare, ie how
+// things would be sorted in a dictionary.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+enum want_value {lt=0, z=1, gt=2};
+
+int
+test_value(int result, want_value expected);
+
+int
+test_value(int result, want_value expected)
+{
+ bool test __attribute__((unused)) = true;
+ bool pass = false;
+
+ switch (expected) {
+ case lt:
+ if (result < 0)
+ pass = true;
+ break;
+ case z:
+ if (!result)
+ pass = true;
+ break;
+ case gt:
+ if (result > 0)
+ pass = true;
+ break;
+ default:
+ pass = false; //should not get here
+ }
+
+ VERIFY(pass);
+ return 0;
+}
+
+
+int
+test01()
+{
+ using namespace std;
+
+ wstring str_0(L"costa rica");
+ wstring str_1(L"costa marbella");
+ wstring str_2;
+
+ //sanity check
+ test_value(wcscmp(L"costa marbella", L"costa rica"), lt);
+ test_value(wcscmp(L"costa rica", L"costa rica"), z);
+ test_value(wcscmp(str_1.data(), str_0.data()), lt);
+ test_value(wcscmp(str_0.data(), str_1.data()), gt);
+ test_value(wcsncmp(str_1.data(), str_0.data(), 6), z);
+ test_value(wcsncmp(str_1.data(), str_0.data(), 14), lt);
+ test_value(wmemcmp(str_1.data(), str_0.data(), 6), z);
+ test_value(wmemcmp(str_1.data(), str_0.data(), 14), lt);
+ test_value(wmemcmp(L"costa marbella", L"costa rica", 14), lt);
+
+ // int compare(const basic_string& str) const;
+ test_value(str_0.compare(str_1), gt); //because r>m
+ test_value(str_1.compare(str_0), lt); //because m<r
+ str_2 = str_0;
+ test_value(str_2.compare(str_0), z);
+ str_2 = L"cost";
+ test_value(str_2.compare(str_0), lt);
+ str_2 = L"costa ricans";
+ test_value(str_2.compare(str_0), gt);
+
+ // int compare(size_type pos1, size_type n1, const basic_string& str) const;
+ test_value(str_1.compare(0, 6, str_0), lt);
+ str_2 = L"cost";
+ test_value(str_1.compare(0, 4, str_2), z);
+ test_value(str_1.compare(0, 5, str_2), gt);
+
+ // int compare(size_type pos1, size_type n1, const basic_string& str,
+ // size_type pos2, size_type n2) const;
+ test_value(str_1.compare(0, 6, str_0, 0, 6), z);
+ test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
+ test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
+
+ // int compare(const charT* s) const;
+ test_value(str_0.compare(L"costa marbella"), gt);
+ test_value(str_1.compare(L"costa rica"), lt);
+ str_2 = str_0;
+ test_value(str_2.compare(L"costa rica"), z);
+ test_value(str_2.compare(L"cost"), gt);
+ test_value(str_2.compare(L"costa ricans"), lt);
+
+ // int compare(size_type pos, size_type n1, const charT* str,
+ // size_type n2 = npos) const;
+ test_value(str_1.compare(0, 6, L"costa rica", 0, 6), z);
+ test_value(str_1.compare(0, 7, L"costa rica", 0, 7), lt);
+ test_value(str_0.compare(0, 7, L"costa marbella", 0, 7), gt);
+
+ return 0;
+}
+
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/13650.cc b/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/13650.cc
new file mode 100644
index 000000000..ea18a8500
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/compare/wchar_t/13650.cc
@@ -0,0 +1,47 @@
+// 2004-01-13 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2004, 2009 Free Software Foundation
+//
+// 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.6.8 basic_string::compare [lib.string::compare]
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/13650
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ const wchar_t lit_01[] = { L'w', L'e', L'\0', L'r', L'd' };
+ const wchar_t lit_02[] = { L'w', L'e', L'i', L'\0', L'd' };
+
+ const wchar_t lit_ref_a[] = { L'w', L'e', L'\0', L'q', L'd' };
+ const wstring str_a(lit_ref_a, 5);
+ VERIFY( str_a.compare(0, 5, lit_01, 5) < 0 );
+
+ const wchar_t lit_ref_b[] = { L'w', L'e', L'i' };
+ const wstring str_b(lit_ref_b, 3);
+ VERIFY( str_b.compare(0, 3, lit_02, 5) < 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc
new file mode 100644
index 000000000..79362e677
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/1.cc
@@ -0,0 +1,161 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <new>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ typedef std::string::iterator citerator;
+ csize_type npos = std::string::npos;
+ csize_type csz01;
+
+ const char str_lit01[] = "rodeo beach, marin";
+ const std::string str01(str_lit01);
+ const std::string str02("baker beach, san francisco");
+
+ // basic_string(const string&, size_type pos = 0, siz_type n = npos, alloc)
+ csz01 = str01.size();
+ try {
+ std::string str03(str01, csz01 + 1);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ std::string str03(str01, csz01);
+ VERIFY( str03.size() == 0 );
+ VERIFY( str03.size() <= str03.capacity() );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // basic_string(const char* s, size_type n, alloc)
+ csz01 = str01.max_size();
+ // NB: As strlen(str_lit01) != csz01, this test is undefined. It
+ // should not crash, but what gets constructed is a bit arbitrary.
+ try {
+ std::string str03(str_lit01, csz01 + 1);
+ VERIFY( true );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // NB: As strlen(str_lit01) != csz01, this test is undefined. It
+ // should not crash, but what gets constructed is a bit arbitrary.
+ // The "maverick's" of all string objects.
+ try {
+ std::string str04(str_lit01, npos);
+ VERIFY( true );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // Build a maxsize - 1 lengthed string consisting of all A's
+ try {
+ std::string str03(csz01 - 1, 'A');
+ VERIFY( str03.size() == csz01 - 1 );
+ VERIFY( str03.size() <= str03.capacity() );
+ }
+ // NB: bad_alloc is regrettable but entirely kosher for
+ // out-of-memory situations.
+ catch(std::bad_alloc& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // basic_string(const char* s, const allocator& a = allocator())
+ std::string str04(str_lit01);
+ VERIFY( str01 == str04 );
+
+
+ // basic_string(size_type n, char c, const allocator& a = allocator())
+ csz01 = str01.max_size();
+ try {
+ std::string str03(csz01 + 1, 'z');
+ VERIFY( false );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ std::string str04(npos, 'b'); // the "maverick's" of all string objects.
+ VERIFY( false );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ std::string str03(csz01 - 1, 'z');
+ VERIFY( str03.size() != 0 );
+ VERIFY( str03.size() <= str03.capacity() );
+ }
+ // NB: bad_alloc is regrettable but entirely kosher for
+ // out-of-memory situations.
+ catch(std::bad_alloc& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+
+ // template<typename _InputIter>
+ // basic_string(_InputIter begin, _InputIter end, const allocator& a)
+ std::string str06(str01.begin(), str01.end());
+ VERIFY( str06 == str01 );
+}
+
+int main()
+{
+ __gnu_test::set_memory_limits();
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/2.cc
new file mode 100644
index 000000000..f3d252e3a
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/2.cc
@@ -0,0 +1,41 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ // template<typename _InputIter>
+ // basic_string(_InputIter begin, _InputIter end, const allocator& a)
+ // where _InputIter is integral [21.3.1 para 15]
+ std::string s(10,0);
+ VERIFY( s.size() == 10 );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/3.cc
new file mode 100644
index 000000000..5badcacb9
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/3.cc
@@ -0,0 +1,69 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <new>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const char* with_nulls = "This contains \0 a zero byte.";
+
+ // These are tests to see how basic_string handles data with NUL
+ // bytes. Obviously basic_string(char*) will halt at the first one, but
+ // nothing else should.
+ std::string s1 (with_nulls, 28);
+ VERIFY( s1.size() == 28 );
+ std::string s2 (s1);
+ VERIFY( s2.size() == 28 );
+
+ // Not defined, but libstdc++ throws an exception.
+ const char* bogus = 0;
+ try
+ {
+ std::string str1(bogus);
+ VERIFY( false );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( true );
+ }
+
+ // Not defined, but libstdc++ throws an exception.
+ try
+ {
+ std::string str2(bogus, 5);
+ VERIFY( false );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( true );
+ }
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/4.cc
new file mode 100644
index 000000000..6bc6c19b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/4.cc
@@ -0,0 +1,43 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2002-06/msg00025.html
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string str01("portofino");
+
+ std::string::reverse_iterator i1 = str01.rbegin();
+ std::string::reverse_iterator i2 = str01.rend();
+ std::string str02(i1, i2);
+ VERIFY( str02 == "onifotrop" );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/42261.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/42261.cc
new file mode 100644
index 000000000..a83b74ac7
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/42261.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/42261
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ const string s(string::size_type(6), string::size_type('f'));
+ VERIFY( s == "ffffff" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/5.cc
new file mode 100644
index 000000000..5652478f4
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/5.cc
@@ -0,0 +1,44 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009, 2010
+// 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.1 basic_string constructors.
+
+#include <string>
+#include <vector>
+#include <testsuite_hooks.h>
+
+// libstdc++/8347
+void test05()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::vector<char> empty;
+ std::string empty2(empty.begin(), empty.end());
+
+ // libstdc++/8716 (same underlying situation, same fix)
+ char const * s = 0;
+ std::string zero_length_built_with_NULL(s,0);
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/6.cc
new file mode 100644
index 000000000..3494935f3
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/6.cc
@@ -0,0 +1,55 @@
+// 2004-01-30 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.1 basic_string constructors.
+
+#include <iterator>
+#include <sstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string data(long len)
+{
+ string ret;
+ for (long i = 0; i < len; ++i)
+ ret.push_back('a' + rand() % 26);
+ return ret;
+}
+
+void test01(int iter)
+{
+ bool test __attribute__((unused)) = true;
+
+ for (long i = 0, j = 1; i < iter; ++i, j *= 3)
+ {
+ istringstream isstr(data(j));
+
+ string str((istreambuf_iterator<char>(isstr)),
+ istreambuf_iterator<char>());
+ VERIFY( str == isstr.str() );
+ }
+}
+
+int main()
+{
+ test01(13);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable.cc
new file mode 100644
index 000000000..58b1e4461
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010 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 changed
+// 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 = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+
+ std::string c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == '1' );
+ VERIFY( b.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc
new file mode 100644
index 000000000..19c389521
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/moveable2.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x -fno-inline" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010, 2011 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 changed
+// this test may begin to fail.
+
+#include <string>
+#include <utility>
+#include <testsuite_hooks.h>
+
+class tstring : public std::basic_string<char>
+{
+public:
+ tstring() : std::basic_string<char>() {}
+ tstring(tstring&& s) : std::basic_string<char>(std::move(s)) {}
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ tstring a, b;
+ a.push_back('1');
+ b = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 );
+
+ tstring c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == '1' );
+ VERIFY( b.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/1.cc
new file mode 100644
index 000000000..81bf2bafc
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/1.cc
@@ -0,0 +1,161 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <new>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ typedef std::wstring::iterator citerator;
+ csize_type npos = std::wstring::npos;
+ csize_type csz01;
+
+ const wchar_t str_lit01[] = L"rodeo beach, marin";
+ const std::wstring str01(str_lit01);
+ const std::wstring str02(L"baker beach, san francisco");
+
+ // basic_string(const wstring&, size_type pos = 0, siz_type n = npos, alloc)
+ csz01 = str01.size();
+ try {
+ std::wstring str03(str01, csz01 + 1);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ std::wstring str03(str01, csz01);
+ VERIFY( str03.size() == 0 );
+ VERIFY( str03.size() <= str03.capacity() );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // basic_string(const wchar_t* s, size_type n, alloc)
+ csz01 = str01.max_size();
+ // NB: As strlen(str_lit01) != csz01, this test is undefined. It
+ // should not crash, but what gets constructed is a bit arbitrary.
+ try {
+ std::wstring str03(str_lit01, csz01 + 1);
+ VERIFY( true );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // NB: As strlen(str_lit01) != csz01, this test is undefined. It
+ // should not crash, but what gets constructed is a bit arbitrary.
+ // The "maverick's" of all string objects.
+ try {
+ std::wstring str04(str_lit01, npos);
+ VERIFY( true );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // Build a maxsize - 1 lengthed string consisting of all A's
+ try {
+ std::wstring str03(csz01 - 1, 'A');
+ VERIFY( str03.size() == csz01 - 1 );
+ VERIFY( str03.size() <= str03.capacity() );
+ }
+ // NB: bad_alloc is regrettable but entirely kosher for
+ // out-of-memory situations.
+ catch(std::bad_alloc& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // basic_string(const wchar_t* s, const allocator& a = allocator())
+ std::wstring str04(str_lit01);
+ VERIFY( str01 == str04 );
+
+
+ // basic_string(size_type n, char c, const allocator& a = allocator())
+ csz01 = str01.max_size();
+ try {
+ std::wstring str03(csz01 + 1, L'z');
+ VERIFY( false );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ std::wstring str04(npos, L'b'); // the "maverick's" of all string objects.
+ VERIFY( false );
+ }
+ catch(std::length_error& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ std::wstring str03(csz01 - 1, L'z');
+ VERIFY( str03.size() != 0 );
+ VERIFY( str03.size() <= str03.capacity() );
+ }
+ // NB: bad_alloc is regrettable but entirely kosher for
+ // out-of-memory situations.
+ catch(std::bad_alloc& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+
+ // template<typename _InputIter>
+ // basic_string(_InputIter begin, _InputIter end, const allocator& a)
+ std::wstring str06(str01.begin(), str01.end());
+ VERIFY( str06 == str01 );
+}
+
+int main()
+{
+ __gnu_test::set_memory_limits();
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/2.cc
new file mode 100644
index 000000000..57103e1fa
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/2.cc
@@ -0,0 +1,41 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ // template<typename _InputIter>
+ // basic_string(_InputIter begin, _InputIter end, const allocator& a)
+ // where _InputIter is integral [21.3.1 para 15]
+ std::wstring s(10, 0);
+ VERIFY( s.size() == 10 );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/3.cc
new file mode 100644
index 000000000..f53b9bc17
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/3.cc
@@ -0,0 +1,69 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <new>
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ const wchar_t* with_nulls = L"This contains \0 a zero byte.";
+
+ // These are tests to see how basic_string handles data with NUL
+ // bytes. Obviously basic_string(char*) will halt at the first one, but
+ // nothing else should.
+ std::wstring s1 (with_nulls, 28);
+ VERIFY( s1.size() == 28 );
+ std::wstring s2 (s1);
+ VERIFY( s2.size() == 28 );
+
+ // Not defined, but libstdc++ throws an exception.
+ const wchar_t* bogus = 0;
+ try
+ {
+ std::wstring str1(bogus);
+ VERIFY( false );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( true );
+ }
+
+ // Not defined, but libstdc++ throws an exception.
+ try
+ {
+ std::wstring str2(bogus, 5);
+ VERIFY( false );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( true );
+ }
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/4.cc
new file mode 100644
index 000000000..ed6eb9a28
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/4.cc
@@ -0,0 +1,43 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 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.1 basic_string constructors.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2002-06/msg00025.html
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring str01(L"portofino");
+
+ std::wstring::reverse_iterator i1 = str01.rbegin();
+ std::wstring::reverse_iterator i2 = str01.rend();
+ std::wstring str02(i1, i2);
+ VERIFY( str02 == L"onifotrop" );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/42261.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/42261.cc
new file mode 100644
index 000000000..8782e8caf
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/42261.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/42261
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ const wstring s(wstring::size_type(6), wstring::size_type(L'f'));
+ VERIFY( s == L"ffffff" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/5.cc
new file mode 100644
index 000000000..e72377de6
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/5.cc
@@ -0,0 +1,44 @@
+// 1999-06-04 bkoz
+
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2009, 2010
+// 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.1 basic_string constructors.
+
+#include <string>
+#include <vector>
+#include <testsuite_hooks.h>
+
+// libstdc++/8347
+void test05()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::vector<wchar_t> empty;
+ std::wstring empty2(empty.begin(), empty.end());
+
+ // libstdc++/8716 (same underlying situation, same fix)
+ wchar_t const * s = 0;
+ std::wstring zero_length_built_with_NULL(s,0);
+}
+
+int main()
+{
+ test05();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/6.cc
new file mode 100644
index 000000000..82ed764dd
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/6.cc
@@ -0,0 +1,55 @@
+// 2004-01-30 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.1 basic_string constructors.
+
+#include <iterator>
+#include <sstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring data(long len)
+{
+ wstring ret;
+ for (long i = 0; i < len; ++i)
+ ret.push_back(L'a' + rand() % 26);
+ return ret;
+}
+
+void test01(int iter)
+{
+ bool test __attribute__((unused)) = true;
+
+ for (long i = 0, j = 1; i < iter; ++i, j *= 3)
+ {
+ wistringstream isstr(data(j));
+
+ wstring str((istreambuf_iterator<wchar_t>(isstr)),
+ istreambuf_iterator<wchar_t>());
+ VERIFY( str == isstr.str() );
+ }
+}
+
+int main()
+{
+ test01(13);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc
new file mode 100644
index 000000000..67a0fbed7
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010 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 changed
+// 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 = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == L'1' && a.size() == 0 );
+
+ std::wstring c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == L'1' );
+ VERIFY( b.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc
new file mode 100644
index 000000000..ed527d5cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/wchar_t/moveable2.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x -fno-inline" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 2010, 2011 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 changed
+// this test may begin to fail.
+
+#include <string>
+#include <utility>
+#include <testsuite_hooks.h>
+
+class twstring : public std::basic_string<wchar_t>
+{
+public:
+ twstring() : std::basic_string<wchar_t>() {}
+ twstring(twstring&& s) : std::basic_string<wchar_t>(std::move(s)) {}
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ twstring a, b;
+ a.push_back(L'1');
+ b = std::move(a);
+ VERIFY( b.size() == 1 && b[0] == L'1' && a.size() == 0 );
+
+ twstring c(std::move(b));
+ VERIFY( c.size() == 1 && c[0] == L'1' );
+ VERIFY( b.size() == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc
new file mode 100644
index 000000000..b45db4ccb
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/1.cc
@@ -0,0 +1,88 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 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.4 basic_string element access
+
+#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, csz02;
+
+ const std::string str01("tamarindo, costa rica");
+ std::string str02("41st street beach, capitola, california");
+ std::string str03;
+
+ // const_reference operator[] (size_type pos) const;
+ csz01 = str01.size();
+ cref cref1 = str01[csz01 - 1];
+ VERIFY( cref1 == 'a' );
+ cref cref2 = str01[csz01];
+ VERIFY( cref2 == char() );
+
+ // reference operator[] (size_type pos);
+ csz02 = str02.size();
+ ref ref1 = str02[csz02 - 1];
+ VERIFY( ref1 == 'a' );
+ ref ref2 = str02[1];
+ VERIFY( ref2 == '1' );
+
+ // const_reference at(size_type pos) const;
+ csz01 = str01.size();
+ cref cref3 = str01.at(csz01 - 1);
+ VERIFY( cref3 == 'a' );
+ try {
+ str01.at(csz01);
+ VERIFY( false ); // Should not get here, as exception thrown.
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // reference at(size_type pos);
+ csz01 = str02.size();
+ ref ref3 = str02.at(csz02 - 1);
+ VERIFY( ref3 == 'a' );
+ try {
+ str02.at(csz02);
+ VERIFY( false ); // Should not get here, as exception thrown.
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/2.cc
new file mode 100644
index 000000000..9626b535f
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/2.cc
@@ -0,0 +1,110 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 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 template class basic_string
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Do a quick sanity check on known problems with element access and
+// ref-counted strings. These should all pass, regardless of the
+// underlying string implementation, of course.
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ typedef std::string::iterator siterator;
+ typedef std::string::reverse_iterator sriterator;
+ csize_type csz01, csz02;
+ siterator it1;
+ sriterator rit1;
+
+ std::string str01("montara beach, half moon bay");
+ const std::string str02("ocean beach, san francisco");
+ std::string str03;
+
+ // 21.3 p 5
+
+ // References, pointers, and iterators referring to the elements of
+ // a basic_string may be invalidated by the following uses of that
+ // basic_string object:
+
+ // ...
+
+ // Susequent to any of the above uses except the forms of insert()
+ // and erase() which return iterators, the first call to non-const
+ // member functions operator[](), at(), begin(), rbegin(), end(), or
+ // rend()
+
+ str03 = str01;
+ it1 = str01.begin();
+ *it1 = 'x';
+ VERIFY( str01[0] == 'x' );
+ VERIFY( str03[0] == 'm' );
+
+ str03 = str01;
+ csz01 = str01.size();
+ rit1 = str01.rbegin(); // NB: Pointing at one-past the end, so ...
+ *rit1 = 'z'; // ... but it's taken care of here
+ VERIFY( str01[csz01 - 1] == 'z' );
+ VERIFY( str03[csz01 - 1] == 'y' );
+
+ str03 = str01;
+ csz01 = str01.size();
+ std::string::reference r1 = str01.at(csz01 - 2);
+ VERIFY( str03 == str01 );
+ r1 = 'd';
+ VERIFY( str01[csz01 - 2] == 'd' );
+ VERIFY( str03[csz01 - 2] == 'a' );
+
+ str03 = str01;
+ csz01 = str01.size();
+ std::string::reference r2 = str01[csz01 - 3];
+ VERIFY( str03 == str01 );
+ r2 = 'w';
+ VERIFY( str01[csz01 - 3] == 'w' );
+ VERIFY( str03[csz01 - 3] == 'b' );
+
+ str03 = str01;
+ csz02 = str01.size();
+ it1 = str01.end();
+ VERIFY( str03 == str01 );
+ --it1;
+ *it1 = 'q';
+ VERIFY( str01[csz02 - 1] == 'q' );
+ VERIFY( str03[csz02 - 1] == 'z' );
+
+ str03 = str01;
+ rit1 = str01.rend();
+ VERIFY( str03 == str01 );
+ --rit1;
+ *rit1 = 'p';
+ VERIFY( str01[0] == 'p' );
+ VERIFY( str03[0] == 'x' );
+
+ // need to also test for const begin/const end
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc
new file mode 100644
index 000000000..c8a8b9347
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/21674.cc
@@ -0,0 +1,31 @@
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-O0" }
+// { dg-require-debug-mode "" }
+
+// Copyright (C) 2005, 2009, 2010 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/>.
+
+#include <string>
+
+// libstdc++/21674
+// NB: Should work without any inlining or optimizations (ie. -O0).
+int main()
+{
+ typedef std::string string_type;
+ string_type s;
+ s[1]; // abort
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/3.cc
new file mode 100644
index 000000000..385ef28ba
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/3.cc
@@ -0,0 +1,83 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 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 template class basic_string
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Do another sanity check, this time for member functions that return
+// iterators, namely insert and erase.
+bool test02(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ typedef std::string::iterator siterator;
+ typedef std::string::reverse_iterator sriterator;
+ siterator it1;
+ sriterator rit1;
+
+ const std::string str01("its beach, santa cruz");
+
+ std::string str02 = str01;
+ std::string str05 = str02; // optional, so that begin below causes a mutate
+ std::string::iterator p = str02.insert(str02.begin(), ' ');
+ std::string str03 = str02;
+ VERIFY( str03 == str02 );
+ *p = '!';
+ VERIFY( *str03.c_str() == ' ' );
+ str03[0] = '@';
+ VERIFY( str02[0] == '!' );
+ VERIFY( *p == '!' );
+ VERIFY( str02 != str05 );
+ VERIFY( str02 != str03 );
+
+ std::string str10 = str01;
+ std::string::iterator p2 = str10.insert(str10.begin(), 'a');
+ std::string str11 = str10;
+ *p2 = 'e';
+ VERIFY( str11 != str10 );
+
+ std::string str06 = str01;
+ std::string str07 = str06; // optional, so that begin below causes a mutate
+ p = str06.erase(str06.begin());
+ std::string str08 = str06;
+ VERIFY( str08 == str06 );
+ *p = '!';
+ VERIFY( *str08.c_str() == 't' );
+ str08[0] = '@';
+ VERIFY( str06[0] == '!' );
+ VERIFY( *p == '!' );
+ VERIFY( str06 != str07 );
+ VERIFY( str06 != str08 );
+
+ std::string str12 = str01;
+ p2 = str12.erase(str12.begin(), str12.begin() + str12.size() - 1);
+ std::string str13 = str12;
+ *p2 = 'e';
+ VERIFY( str12 != str13 );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/4.cc
new file mode 100644
index 000000000..5adb1583a
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/4.cc
@@ -0,0 +1,49 @@
+// 2004-01-18 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.4 basic_string element access
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2004-01/msg00184.html
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ for (int i = 0; i < 2000; ++i)
+ {
+ string str_01;
+
+ for (int j = 0; j < i; ++j)
+ str_01 += 'a';
+
+ str_01.reserve(i + 10);
+
+ const string str_02(str_01);
+ VERIFY( str_02[i] == '\0' );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/empty.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/empty.cc
new file mode 100644
index 000000000..af0c7ff41
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/empty.cc
@@ -0,0 +1,39 @@
+// 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/>.
+//
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// as per 21.3.4
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ {
+ std::string empty;
+ char c = empty[0];
+ VERIFY( c == char() );
+ }
+
+ {
+ const std::string empty;
+ char c = empty[0];
+ VERIFY( c == char() );
+ }
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/front_back.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/front_back.cc
new file mode 100644
index 000000000..a7c1386ae
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/char/front_back.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2010-05-31 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string str("ramifications");
+ const std::string cstr("melodien");
+
+ VERIFY( str.front() == 'r' );
+ VERIFY( str.back() == 's' );
+ VERIFY( cstr.front() == 'm' );
+ VERIFY( cstr.back() == 'n' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc
new file mode 100644
index 000000000..13dac274b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/1.cc
@@ -0,0 +1,88 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 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.4 basic_string element access
+
+#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, csz02;
+
+ const std::wstring str01(L"tamarindo, costa rica");
+ std::wstring str02(L"41st street beach, capitola, california");
+ std::wstring str03;
+
+ // const_reference operator[] (size_type pos) const;
+ csz01 = str01.size();
+ cref cref1 = str01[csz01 - 1];
+ VERIFY( cref1 == L'a' );
+ cref cref2 = str01[csz01];
+ VERIFY( cref2 == wchar_t() );
+
+ // reference operator[] (size_type pos);
+ csz02 = str02.size();
+ ref ref1 = str02[csz02 - 1];
+ VERIFY( ref1 == L'a' );
+ ref ref2 = str02[1];
+ VERIFY( ref2 == L'1' );
+
+ // const_reference at(size_type pos) const;
+ csz01 = str01.size();
+ cref cref3 = str01.at(csz01 - 1);
+ VERIFY( cref3 == L'a' );
+ try {
+ str01.at(csz01);
+ VERIFY( false ); // Should not get here, as exception thrown.
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ // reference at(size_type pos);
+ csz01 = str02.size();
+ ref ref3 = str02.at(csz02 - 1);
+ VERIFY( ref3 == L'a' );
+ try {
+ str02.at(csz02);
+ VERIFY( false ); // Should not get here, as exception thrown.
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/2.cc
new file mode 100644
index 000000000..6ffece7da
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/2.cc
@@ -0,0 +1,111 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 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 template class basic_string
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Do a quick sanity check on known problems with element access and
+// ref-counted strings. These should all pass, regardless of the
+// underlying string implementation, of course.
+bool test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ typedef std::wstring::iterator siterator;
+ typedef std::wstring::reverse_iterator sriterator;
+ csize_type csz01, csz02;
+ siterator it1;
+ sriterator rit1;
+
+ std::wstring str01(L"montara beach, half moon bay");
+ const std::wstring str02(L"ocean beach, san francisco");
+ std::wstring str03;
+
+ // 21.3 p 5
+
+ // References, pointers, and iterators referring to the elements of
+ // a basic_string may be invalidated by the following uses of that
+ // basic_string object:
+
+ // ...
+
+ // Susequent to any of the above uses except the forms of insert()
+ // and erase() which return iterators, the first call to non-const
+ // member functions operator[](), at(), begin(), rbegin(), end(), or
+ // rend()
+
+ str03 = str01;
+ it1 = str01.begin();
+ *it1 = L'x';
+ VERIFY( str01[0] == L'x' );
+ VERIFY( str03[0] == L'm' );
+
+ str03 = str01;
+ csz01 = str01.size();
+ rit1 = str01.rbegin(); // NB: Pointing at one-past the end, so ...
+ *rit1 = L'z'; // ... but it's taken care of here
+ VERIFY( str01[csz01 - 1] == L'z' );
+ VERIFY( str03[csz01 - 1] == L'y' );
+
+ str03 = str01;
+ csz01 = str01.size();
+ std::wstring::reference r1 = str01.at(csz01 - 2);
+ VERIFY( str03 == str01 );
+ r1 = L'd';
+ VERIFY( str01[csz01 - 2] == L'd' );
+ VERIFY( str03[csz01 - 2] == L'a' );
+
+ str03 = str01;
+ csz01 = str01.size();
+ std::wstring::reference r2 = str01[csz01 - 3];
+ VERIFY( str03 == str01 );
+ r2 = L'w';
+ VERIFY( str01[csz01 - 3] == L'w' );
+ VERIFY( str03[csz01 - 3] == L'b' );
+
+ str03 = str01;
+ csz02 = str01.size();
+ it1 = str01.end();
+ VERIFY( str03 == str01 );
+ --it1;
+ *it1 = L'q';
+ VERIFY( str01[csz02 - 1] == L'q' );
+ VERIFY( str03[csz02 - 1] == L'z' );
+
+ str03 = str01;
+ rit1 = str01.rend();
+ VERIFY( str03 == str01 );
+ --rit1;
+ *rit1 = L'p';
+ VERIFY( str01[0] == L'p' );
+ VERIFY( str03[0] == L'x' );
+
+ // need to also test for const begin/const end
+ VERIFY(test);
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc
new file mode 100644
index 000000000..95046463d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/21674.cc
@@ -0,0 +1,31 @@
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-O0" }
+// { dg-require-debug-mode "" }
+
+// Copyright (C) 2005, 2009, 2010 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/>.
+
+#include <string>
+
+// libstdc++/21674
+// NB: Should work without any inlining or optimizations (ie. -O0).
+int main()
+{
+ typedef std::wstring string_type;
+ string_type s;
+ s[1]; // abort
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/3.cc
new file mode 100644
index 000000000..266f03736
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/3.cc
@@ -0,0 +1,83 @@
+// 1999-06-08 bkoz
+
+// Copyright (C) 1999, 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 template class basic_string
+
+#include <string>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// Do another sanity check, this time for member functions that return
+// iterators, namely insert and erase.
+bool test02(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ typedef std::wstring::iterator siterator;
+ typedef std::wstring::reverse_iterator sriterator;
+ siterator it1;
+ sriterator rit1;
+
+ const std::wstring str01(L"its beach, santa cruz");
+
+ std::wstring str02 = str01;
+ std::wstring str05 = str02; // optional, so that begin below causes a mutate
+ std::wstring::iterator p = str02.insert(str02.begin(), L' ');
+ std::wstring str03 = str02;
+ VERIFY( str03 == str02 );
+ *p = L'!';
+ VERIFY( *str03.c_str() == L' ' );
+ str03[0] = L'@';
+ VERIFY( str02[0] == L'!' );
+ VERIFY( *p == L'!' );
+ VERIFY( str02 != str05 );
+ VERIFY( str02 != str03 );
+
+ std::wstring str10 = str01;
+ std::wstring::iterator p2 = str10.insert(str10.begin(), L'a');
+ std::wstring str11 = str10;
+ *p2 = L'e';
+ VERIFY( str11 != str10 );
+
+ std::wstring str06 = str01;
+ std::wstring str07 = str06; // optional, so that begin below causes a mutate
+ p = str06.erase(str06.begin());
+ std::wstring str08 = str06;
+ VERIFY( str08 == str06 );
+ *p = L'!';
+ VERIFY( *str08.c_str() == L't' );
+ str08[0] = L'@';
+ VERIFY( str06[0] == L'!' );
+ VERIFY( *p == L'!' );
+ VERIFY( str06 != str07 );
+ VERIFY( str06 != str08 );
+
+ std::wstring str12 = str01;
+ p2 = str12.erase(str12.begin(), str12.begin() + str12.size() - 1);
+ std::wstring str13 = str12;
+ *p2 = L'e';
+ VERIFY( str12 != str13 );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/4.cc
new file mode 100644
index 000000000..d05ab4169
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/4.cc
@@ -0,0 +1,49 @@
+// 2004-01-18 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.4 basic_string element access
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2004-01/msg00184.html
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ for (int i = 0; i < 2000; ++i)
+ {
+ wstring str_01;
+
+ for (int j = 0; j < i; ++j)
+ str_01 += L'a';
+
+ str_01.reserve(i + 10);
+
+ const wstring str_02(str_01);
+ VERIFY( str_02[i] == L'\0' );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/empty.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/empty.cc
new file mode 100644
index 000000000..9a70ace0e
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/empty.cc
@@ -0,0 +1,39 @@
+// 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/>.
+//
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// as per 21.3.4
+int main()
+{
+ bool test __attribute__((unused)) = true;
+
+ {
+ std::wstring empty;
+ wchar_t c = empty[0];
+ VERIFY( c == wchar_t() );
+ }
+
+ {
+ const std::wstring empty;
+ wchar_t c = empty[0];
+ VERIFY( c == wchar_t() );
+ }
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/front_back.cc b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/front_back.cc
new file mode 100644
index 000000000..60b09606f
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/element_access/wchar_t/front_back.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2010-05-31 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation
+//
+// 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring str(L"ramifications");
+ const std::wstring cstr(L"melodien");
+
+ VERIFY( str.front() == L'r' );
+ VERIFY( str.back() == L's' );
+ VERIFY( cstr.front() == L'm' );
+ VERIFY( cstr.back() == L'n' );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/1.cc
new file mode 100644
index 000000000..695b05824
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/1.cc
@@ -0,0 +1,93 @@
+// 1999-06-09 bkoz
+
+// Copyright (C) 1994, 1999, 2000, 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.6.1 basic_string find
+
+#include <string>
+#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 npos = std::string::npos;
+ csize_type csz01, csz02;
+
+ const char str_lit01[] = "mave";
+ const std::string str01("mavericks, santa cruz");
+ std::string str02(str_lit01);
+ std::string str03("s, s");
+ std::string str04;
+
+ // size_type find(const string&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string consists of no characters
+ // therefore it should be found at every point in a string,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
+ // size_type find(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const char* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(char c, size_type pos = 0) const;
+ csz01 = str01.find('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find('/');
+ VERIFY( csz01 == npos );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/2.cc
new file mode 100644
index 000000000..dac20145a
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/2.cc
@@ -0,0 +1,92 @@
+// 1999-06-09 bkoz
+
+// Copyright (C) 1994, 1999, 2000, 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.6.3 basic_string find_first_of
+
+#include <string>
+#include <testsuite_hooks.h>
+
+bool test02(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ csize_type npos = std::string::npos;
+ csize_type csz01, csz02;
+
+ const char str_lit01[] = "mave";
+ const std::string str01("mavericks, santa cruz");
+ std::string str02(str_lit01);
+ std::string str03("s, s");
+ std::string str04;
+
+ // size_type find_first_of(const string&, size_type pos = 0) const;
+ std::string str05("xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string consists of no characters
+ // therefore it should be found at every point in a string,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_of('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/3.cc
new file mode 100644
index 000000000..d06f5a32a
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/3.cc
@@ -0,0 +1,92 @@
+// 2003-05-04 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 2005, 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.6.5 basic_string find_first_not_of
+
+#include <string>
+#include <testsuite_hooks.h>
+
+bool test03(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ csize_type npos = std::string::npos;
+ csize_type csz01;
+
+ const std::string str01("Bob Rock, per me");
+ const char str_lit01[] = "Bob Rock";
+ std::string str02("ovvero Trivi");
+ std::string str03(str_lit01);
+ std::string str04;
+
+ // size_type find_first_not_of(const string&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of('B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of('o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of('z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of('S');
+ VERIFY( csz01 == npos );
+ return test;
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc
new file mode 100644
index 000000000..2d58988c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc
@@ -0,0 +1,42 @@
+// 2007-03-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 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.6.1 basic_string find
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/31401
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ csize_type npos = std::string::npos;
+
+ std::string use = "anu";
+ csize_type pos1 = use.find("a", npos);
+
+ VERIFY( pos1 == npos );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/1.cc
new file mode 100644
index 000000000..8fd5149e5
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/1.cc
@@ -0,0 +1,93 @@
+// 1999-06-09 bkoz
+
+// Copyright (C) 1994, 1999, 2000, 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.6.1 basic_string find
+
+#include <string>
+#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 npos = std::wstring::npos;
+ csize_type csz01, csz02;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring str01(L"mavericks, santa cruz");
+ std::wstring str02(str_lit01);
+ std::wstring str03(L"s, s");
+ std::wstring str04;
+
+ // size_type find(const wstring&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string consists of no characters
+ // therefore it should be found at every point in a string,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
+ // size_type find(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find(L'/');
+ VERIFY( csz01 == npos );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/2.cc
new file mode 100644
index 000000000..ff799163b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/2.cc
@@ -0,0 +1,92 @@
+// 1999-06-09 bkoz
+
+// Copyright (C) 1994, 1999, 2000, 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.6.3 basic_string find_first_of
+
+#include <string>
+#include <testsuite_hooks.h>
+
+bool test02(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ csize_type npos = std::wstring::npos;
+ csize_type csz01, csz02;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring str01(L"mavericks, santa cruz");
+ std::wstring str02(str_lit01);
+ std::wstring str03(L"s, s");
+ std::wstring str04;
+
+ // size_type find_first_of(const wstring&, size_type pos = 0) const;
+ std::wstring str05(L"xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string consists of no characters
+ // therefore it should be found at every point in a string,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find_first_of(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/3.cc
new file mode 100644
index 000000000..4017f7383
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/3.cc
@@ -0,0 +1,92 @@
+// 2003-05-04 Paolo Carlini <pcarlini@unitus.it>
+
+// Copyright (C) 2003, 2005, 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.6.5 basic_string find_first_not_of
+
+#include <string>
+#include <testsuite_hooks.h>
+
+bool test03(void)
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ csize_type npos = std::wstring::npos;
+ csize_type csz01;
+
+ const std::wstring str01(L"Bob Rock, per me");
+ const wchar_t str_lit01[] = L"Bob Rock";
+ std::wstring str02(L"ovvero Trivi");
+ std::wstring str03(str_lit01);
+ std::wstring str04;
+
+ // size_type find_first_not_of(const string&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(L'B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of(L'o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of(L'z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of(L'S');
+ VERIFY( csz01 == npos );
+ return test;
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc
new file mode 100644
index 000000000..973ee92f7
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc
@@ -0,0 +1,42 @@
+// 2007-03-30 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 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.6.1 basic_string find
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// libstdc++/31401
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ csize_type npos = std::wstring::npos;
+
+ std::wstring use = L"anu";
+ csize_type pos1 = use.find(L"a", npos);
+
+ VERIFY( pos1 == npos );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc b/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc
new file mode 100644
index 000000000..c039a4115
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc
@@ -0,0 +1,72 @@
+// Copyright (C) 2008, 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/>.
+//
+
+// { dg-options "-std=gnu++0x" }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+int test01(void)
+{
+ bool test = true;
+
+ string s1 = { 'a', 'b', 'c' };
+ VERIFY(s1 == "abc");
+
+ s1 = { 'd', 'e', 'f' };
+ VERIFY(s1 == "def");
+
+ s1 += { 'g', 'h', 'i' };
+ VERIFY(s1 == "defghi");
+
+ s1.append({ 'j', 'k', 'l' });
+ VERIFY(s1 == "defghijkl");
+
+ s1.assign({ 'm', 'n', 'o' });
+ VERIFY(s1 == "mno");
+
+ // There aren't actually overloads of insert and replace taking size_type
+ // and initializer_list, but test the usage anyway.
+ s1.insert(2, { 'p', 'q', 'r' });
+ VERIFY(s1 == "mnpqro");
+
+ s1.replace(2, 3, { 's', 't', 'u' });
+ VERIFY(s1 == "mnstuo");
+
+ string::iterator i1, i2;
+
+ i1 = s1.begin()+2;
+ s1.insert(i1, { 'v', 'w', 'x' });
+ VERIFY(s1 == "mnvwxstuo");
+
+ i1 = s1.begin()+2;
+ i2 = i1+6;
+ s1.replace(i1, i2, { 'y', 'z' });
+ VERIFY(s1 == "mnyzo");
+
+ return test;
+}
+
+int main()
+{
+ __gnu_test::set_memory_limits();
+ test01();
+ return 0;
+}
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 000000000..de4336d8c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc
@@ -0,0 +1,189 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 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.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;
+}
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 000000000..4cebac110
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc
@@ -0,0 +1,82 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 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.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;
+}
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 000000000..33c044c9e
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc
@@ -0,0 +1,189 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 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.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;
+}
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 000000000..17c03cdae
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc
@@ -0,0 +1,82 @@
+// 1999-06-03 bkoz
+
+// Copyright (C) 1999, 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.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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/1.cc
new file mode 100644
index 000000000..9b3ed4c3c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/1.cc
@@ -0,0 +1,165 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <stdexcept>
+#include <sstream>
+#include <fstream>
+#include <iostream>
+#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 std::string str01("sailing grand traverse bay\n"
+ "\t\t\t from Elk Rapids to the point reminds me of miles");
+ const std::string str02("sailing");
+ const std::string str03("grand");
+ const std::string str04("traverse");
+ const std::string str05;
+ std::string str10;
+
+ // istream& operator>>(istream&, string&)
+ std::istringstream istrs01(str01);
+ istrs01 >> str10;
+ VERIFY( str10 == str02 );
+ try
+ {
+ std::istringstream::int_type i01 = istrs01.peek(); //a-boo
+ VERIFY( std::istringstream::traits_type::to_char_type(i01) == ' ' );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ istrs01.clear();
+ istrs01 >> str10;
+ VERIFY( str10 == str03 );
+ istrs01.clear();
+ istrs01 >> str10;
+ VERIFY( str10 == str04 ); // sentry picks out the white spaces. .
+
+ std::istringstream istrs02(str05); // empty
+ istrs02 >> str10;
+ VERIFY( str10 == str04 );
+
+ // istream& getline(istream&, string&, char)
+ // istream& getline(istream&, string&)
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10);
+ VERIFY( !istrs01.fail() );
+ VERIFY( !istrs01.eof() );
+ VERIFY( istrs01.good() );
+ VERIFY( str10 == " bay" );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10,'\t');
+ VERIFY( !istrs01.fail() );
+ VERIFY( !istrs01.eof() );
+ VERIFY( istrs01.good() );
+ VERIFY( str10 == str05 );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10,'\t');
+ VERIFY( !istrs01.fail() );
+ VERIFY( !istrs01.eof() );
+ VERIFY( istrs01.good() );
+ VERIFY( str10 == str05 );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10, '.');
+ VERIFY( !istrs01.fail() );
+ VERIFY( istrs01.eof() );
+ VERIFY( !istrs01.good() );
+ VERIFY( str10 == "\t from Elk Rapids to the point reminds me of miles" );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ getline(istrs02, str10);
+ VERIFY( istrs02.fail() );
+ VERIFY( istrs02.eof() );
+ VERIFY( str10 =="\t from Elk Rapids to the point reminds me of miles" );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ // ostream& operator<<(ostream&, const basic_string&)
+ std::ostringstream ostrs01;
+ try
+ {
+ ostrs01 << str01;
+ VERIFY( ostrs01.str() == str01 );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false );
+ }
+
+ std::string hello_world;
+ std::cout << hello_world;
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/10.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/10.cc
new file mode 100644
index 000000000..f2722fe96
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/10.cc
@@ -0,0 +1,86 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation
+//
+// 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.7.9 inserters and extractors
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string prepare(string::size_type len, unsigned nchunks, char delim)
+{
+ string ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (string::size_type j = 0; j < len; ++j)
+ ret.push_back('a' + rand() % 26);
+ len *= 2;
+ ret.push_back(delim);
+ }
+ return ret;
+}
+
+void check(istream& stream, const string& str, unsigned nchunks, char delim)
+{
+ bool test __attribute__((unused)) = true;
+
+ string chunk;
+ string::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (getline(stream, chunk, delim))
+ {
+ index_new = str.find(delim, index);
+ VERIFY( !str.compare(index, index_new - index, chunk) );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+}
+
+// istream& getline(istream&, string&, char)
+void test01()
+{
+ const char filename[] = "inserters_extractors-2.txt";
+
+ const char delim = '|';
+ const unsigned nchunks = 10;
+ const string data = prepare(777, nchunks, delim);
+
+ ofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ ifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks, delim);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/11.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/11.cc
new file mode 100644
index 000000000..662311a88
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/11.cc
@@ -0,0 +1,85 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation
+//
+// 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.7.9 inserters and extractors
+
+// { dg-require-fileio "" }
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+string prepare(string::size_type len, unsigned nchunks)
+{
+ string ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (string::size_type j = 0; j < len; ++j)
+ ret.push_back('a' + rand() % 26);
+ len *= 2;
+ ret.push_back(' ');
+ }
+ return ret;
+}
+
+void check(istream& stream, const string& str, unsigned nchunks)
+{
+ bool test __attribute__((unused)) = true;
+
+ string chunk;
+ string::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream >> chunk)
+ {
+ index_new = str.find(' ', index);
+ VERIFY( !str.compare(index, index_new - index, chunk) );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+}
+
+// istream& operator>>(istream&, string&)
+void test01()
+{
+ const char filename[] = "inserters_extractors-3.txt";
+
+ const unsigned nchunks = 10;
+ const string data = prepare(666, nchunks);
+
+ ofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ ifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/28277.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/28277.cc
new file mode 100644
index 000000000..dfcacc089
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/28277.cc
@@ -0,0 +1,54 @@
+// 2006-10-12 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-options "-DWIDTH=200000" { target simulator } }
+
+// 21.3.7.9 inserters and extractors
+
+#include <ostream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+#ifndef WIDTH
+#define WIDTH 20000000
+#endif
+
+// libstdc++/28277
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ ostringstream oss_01;
+ const string str_01(50, 'a');
+
+ oss_01.width(WIDTH);
+ const streamsize width = oss_01.width();
+
+ oss_01 << str_01;
+
+ VERIFY( oss_01.good() );
+ VERIFY( oss_01.str().size() == string::size_type(width) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/4.cc
new file mode 100644
index 000000000..cb1713bc8
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/4.cc
@@ -0,0 +1,65 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// testing basic_stringbuf::xsputn via stress testing with large strings
+// based on a bug report libstdc++ 9
+void test04(std::size_t size)
+{
+ bool test __attribute__((unused)) = true;
+ std::string str(size, 's');
+ std::size_t expected_size = 2 * (size + 1);
+ std::ostringstream oss(str);
+
+ // sanity checks
+ VERIFY( str.size() == size );
+ VERIFY( oss.good() );
+
+ // stress test
+ oss << str << std::endl;
+ if (!oss.good())
+ test = false;
+
+ oss << str << std::endl;
+ if (!oss.good())
+ test = false;
+
+ VERIFY( str.size() == size );
+ VERIFY( oss.good() );
+ std::string str_tmp = oss.str();
+ VERIFY( str_tmp.size() == expected_size );
+}
+
+int main()
+{
+ test04(1); // expected_size == 4
+ test04(1000); // expected_size == 2002
+ test04(10000); // expected_size == 20002
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/5.cc
new file mode 100644
index 000000000..109627325
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/5.cc
@@ -0,0 +1,88 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+// { dg-require-fileio "" }
+
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <testsuite_hooks.h>
+
+// testing basic_filebuf::xsputn via stress testing with large strings
+// based on a bug report libstdc++ 9
+// mode == out
+void test05(std::size_t size)
+{
+ bool test __attribute__((unused)) = true;
+ const char filename[] = "inserters_extractors-1.txt";
+ const char fillc = 'f';
+ std::ofstream ofs(filename);
+ std::string str(size, fillc);
+
+ // sanity checks
+ VERIFY( str.size() == size );
+ VERIFY( ofs.good() );
+
+ // stress test
+ ofs << str << std::endl;
+ if (!ofs.good())
+ test = false;
+
+ ofs << str << std::endl;
+ if (!ofs.good())
+ test = false;
+
+ VERIFY( str.size() == size );
+ VERIFY( ofs.good() );
+
+ ofs.close();
+
+ // sanity check on the written file
+ std::ifstream ifs(filename);
+ std::size_t count = 0;
+ char c;
+ while (count <= (2 * size) + 4)
+ {
+ ifs >> c;
+ if (ifs.good() && c == fillc)
+ {
+ ++count;
+ c = '0';
+ }
+ else
+ break;
+ }
+
+ VERIFY( count == 2 * size );
+}
+
+int main()
+{
+ test05(1);
+ test05(1000);
+ test05(10000);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/6.cc
new file mode 100644
index 000000000..cc0e5d673
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/6.cc
@@ -0,0 +1,61 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// istringstream/stringbuf extractor properly size buffer based on
+// actual, not allocated contents (string.size() vs. string.capacity()).
+// http://gcc.gnu.org/ml/libstdc++/1999-q4/msg00049.html
+void test06(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::string::size_type size_type;
+ std::string str01("@silent");
+ size_type i01 = str01.size();
+ size_type i02 = str01.capacity();
+ str01.erase(0, 1);
+ size_type i03 = str01.size();
+ size_type i04 = str01.capacity();
+ VERIFY( i01 - 1 == i03 );
+ VERIFY( i02 >= i04 );
+
+ std::istringstream is(str01);
+ std::string str02;
+ is >> str02 >> std::ws;
+ size_type i05 = str02.size();
+ size_type i06 = str02.capacity();
+ VERIFY( i05 == i03 );
+ VERIFY( i06 <= i04 );
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/7.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/7.cc
new file mode 100644
index 000000000..c8ae3c580
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/7.cc
@@ -0,0 +1,53 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00085.html
+// istream::operator>>(string)
+// sets failbit
+// NB: this is a defect in the standard.
+void test07(void)
+{
+ bool test __attribute__((unused)) = true;
+ const std::string name("z6.cc");
+ std::istringstream iss (name);
+ int i = 0;
+ std::string s;
+ while (iss >> s)
+ ++i;
+
+ VERIFY( i < 3 );
+ VERIFY( static_cast<bool>(iss.rdstate() & std::ios_base::failbit) );
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/8.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/8.cc
new file mode 100644
index 000000000..4e008a369
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/8.cc
@@ -0,0 +1,53 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+// libstdc++/1019
+void test08()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ istringstream istrm("enero:2001");
+ int year;
+ char sep;
+ string month;
+
+ istrm >> setw(5) >> month >> sep >> year;
+ VERIFY( month.size() == 5 );
+ VERIFY( sep == ':' );
+ VERIFY( year == 2001 );
+}
+
+int main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/9.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/9.cc
new file mode 100644
index 000000000..29d3e7704
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/char/9.cc
@@ -0,0 +1,56 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+// libstdc++/2830
+void test09()
+{
+ bool test __attribute__((unused)) = true;
+ std::string blanks( 3, '\0');
+ std::string foo = "peace";
+ foo += blanks;
+ foo += "& love";
+
+ std::ostringstream oss1;
+ oss1 << foo;
+ VERIFY( oss1.str() == foo );
+
+ std::ostringstream oss2;
+ oss2.width(20);
+ oss2 << foo;
+ VERIFY( oss2.str() != foo );
+ VERIFY( oss2.str().size() == 20 );
+}
+
+int main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-in.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-in.cc
new file mode 100644
index 000000000..142977c0c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-in.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 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/>.
+
+
+// 27.6.1.1.2 class basic_istream::sentry
+
+#include <string>
+#include <istream>
+#include <sstream>
+#include <locale>
+#include <typeinfo>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+void test01()
+{
+ using namespace std;
+ using __gnu_test::pod_ushort;
+ typedef basic_string<pod_ushort> string_type;
+ typedef basic_stringbuf<pod_ushort> stringbuf_type;
+ typedef basic_istream<pod_ushort> istream_type;
+
+ bool test __attribute__((unused)) = true;
+
+ string_type str;
+ stringbuf_type strbuf01;
+ istream_type stream(&strbuf01);
+
+ try
+ {
+ stream >> str;
+ }
+ catch (std::bad_cast& obj)
+ {
+ // Ok, throws bad_cast because locale has no ctype facet.
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
+ stream.imbue(loc);
+ try
+ {
+ stream >> str;
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template
+ const std::basic_string<__gnu_test::pod_ushort>::size_type
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
+
+template
+ const __gnu_test::pod_ushort
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
+#endif
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-out.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-out.cc
new file mode 100644
index 000000000..50c9ec738
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/pod/10081-out.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 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/>.
+
+
+// 27.6.1.1.2 class basic_istream::sentry
+
+#include <string>
+#include <ostream>
+#include <sstream>
+#include <locale>
+#include <typeinfo>
+#include <testsuite_hooks.h>
+#include <testsuite_character.h>
+
+void test01()
+{
+ using namespace std;
+ using __gnu_test::pod_ushort;
+ typedef basic_string<pod_ushort> string_type;
+ typedef basic_stringbuf<pod_ushort> stringbuf_type;
+ typedef basic_ostream<pod_ushort> ostream_type;
+
+ bool test __attribute__((unused)) = true;
+
+ string_type str;
+ stringbuf_type strbuf01;
+ ostream_type stream(&strbuf01);
+
+ try
+ {
+ stream << str;
+ }
+ catch (std::bad_cast& obj)
+ {
+ // Ok, throws bad_cast because locale has no ctype facet.
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
+ stream.imbue(loc);
+ try
+ {
+ stream << str;
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template
+ const std::basic_string<__gnu_test::pod_ushort>::size_type
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
+
+template
+ const __gnu_test::pod_ushort
+ std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
+#endif
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/1.cc
new file mode 100644
index 000000000..a98201f67
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/1.cc
@@ -0,0 +1,165 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <stdexcept>
+#include <sstream>
+#include <fstream>
+#include <iostream>
+#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 std::wstring str01(L"sailing grand traverse bay\n"
+ L"\t\t\t from Elk Rapids to the point reminds me of miles");
+ const std::wstring str02(L"sailing");
+ const std::wstring str03(L"grand");
+ const std::wstring str04(L"traverse");
+ const std::wstring str05;
+ std::wstring str10;
+
+ // istream& operator>>(istream&, string&)
+ std::wistringstream istrs01(str01);
+ istrs01 >> str10;
+ VERIFY( str10 == str02 );
+ try
+ {
+ std::wistringstream::int_type i01 = istrs01.peek(); //a-boo
+ VERIFY( std::wistringstream::traits_type::to_char_type(i01) == L' ' );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ istrs01.clear();
+ istrs01 >> str10;
+ VERIFY( str10 == str03 );
+ istrs01.clear();
+ istrs01 >> str10;
+ VERIFY( str10 == str04 ); // sentry picks out the white spaces. .
+
+ std::wistringstream istrs02(str05); // empty
+ istrs02 >> str10;
+ VERIFY( str10 == str04 );
+
+ // istream& getline(istream&, string&, char)
+ // istream& getline(istream&, string&)
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10);
+ VERIFY( !istrs01.fail() );
+ VERIFY( !istrs01.eof() );
+ VERIFY( istrs01.good() );
+ VERIFY( str10 == L" bay" );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10, L'\t');
+ VERIFY( !istrs01.fail() );
+ VERIFY( !istrs01.eof() );
+ VERIFY( istrs01.good() );
+ VERIFY( str10 == str05 );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10, L'\t');
+ VERIFY( !istrs01.fail() );
+ VERIFY( !istrs01.eof() );
+ VERIFY( istrs01.good() );
+ VERIFY( str10 == str05 );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ istrs01.clear();
+ getline(istrs01, str10, L'.');
+ VERIFY( !istrs01.fail() );
+ VERIFY( istrs01.eof() );
+ VERIFY( !istrs01.good() );
+ VERIFY( str10 == L"\t from Elk Rapids to the point reminds me of miles" );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ try
+ {
+ getline(istrs02, str10);
+ VERIFY( istrs02.fail() );
+ VERIFY( istrs02.eof() );
+ VERIFY( str10 == L"\t from Elk Rapids to the point reminds me of miles" );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false ); // shouldn't throw
+ }
+
+ // ostream& operator<<(ostream&, const basic_string&)
+ std::wostringstream ostrs01;
+ try
+ {
+ ostrs01 << str01;
+ VERIFY( ostrs01.str() == str01 );
+ }
+ catch(std::exception& fail)
+ {
+ VERIFY( false );
+ }
+
+ std::wstring hello_world;
+ std::wcout << hello_world;
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc
new file mode 100644
index 000000000..0883e13c3
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/10.cc
@@ -0,0 +1,84 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation
+//
+// 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.7.9 inserters and extractors
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring prepare(wstring::size_type len, unsigned nchunks, wchar_t delim)
+{
+ wstring ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (wstring::size_type j = 0; j < len; ++j)
+ ret.push_back(L'a' + rand() % 26);
+ len *= 2;
+ ret.push_back(delim);
+ }
+ return ret;
+}
+
+void check(wistream& stream, const wstring& str, unsigned nchunks, wchar_t delim)
+{
+ bool test __attribute__((unused)) = true;
+
+ wstring chunk;
+ wstring::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (getline(stream, chunk, delim))
+ {
+ index_new = str.find(delim, index);
+ VERIFY( !str.compare(index, index_new - index, chunk) );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+}
+
+// istream& getline(istream&, string&, char)
+void test01()
+{
+ const char filename[] = "inserters_extractors-2.txt";
+
+ const wchar_t delim = L'|';
+ const unsigned nchunks = 10;
+ const wstring data = prepare(777, nchunks, delim);
+
+ wofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ wifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks, delim);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/11.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/11.cc
new file mode 100644
index 000000000..2f174cad4
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/11.cc
@@ -0,0 +1,83 @@
+// Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation
+//
+// 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.7.9 inserters and extractors
+
+#include <istream>
+#include <string>
+#include <fstream>
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+wstring prepare(wstring::size_type len, unsigned nchunks)
+{
+ wstring ret;
+ for (unsigned i = 0; i < nchunks; ++i)
+ {
+ for (wstring::size_type j = 0; j < len; ++j)
+ ret.push_back(L'a' + rand() % 26);
+ len *= 2;
+ ret.push_back(L' ');
+ }
+ return ret;
+}
+
+void check(wistream& stream, const wstring& str, unsigned nchunks)
+{
+ bool test __attribute__((unused)) = true;
+
+ wstring chunk;
+ wstring::size_type index = 0, index_new = 0;
+ unsigned n = 0;
+
+ while (stream >> chunk)
+ {
+ index_new = str.find(L' ', index);
+ VERIFY( !str.compare(index, index_new - index, chunk) );
+ index = index_new + 1;
+ ++n;
+ }
+ VERIFY( stream.eof() );
+ VERIFY( n == nchunks );
+}
+
+// istream& operator>>(istream&, string&)
+void test01()
+{
+ const char filename[] = "inserters_extractors-3.txt";
+
+ const unsigned nchunks = 10;
+ const wstring data = prepare(666, nchunks);
+
+ wofstream ofstrm;
+ ofstrm.open(filename);
+ ofstrm.write(data.data(), data.size());
+ ofstrm.close();
+
+ wifstream ifstrm;
+ ifstrm.open(filename);
+ check(ifstrm, data, nchunks);
+ ifstrm.close();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/28277.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/28277.cc
new file mode 100644
index 000000000..51c26fd80
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/28277.cc
@@ -0,0 +1,54 @@
+// 2006-10-12 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-options "-DWIDTH=500000" { target simulator } }
+
+// 21.3.7.9 inserters and extractors
+
+#include <ostream>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+#ifndef WIDTH
+#define WIDTH 50000000
+#endif
+
+// libstdc++/28277
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wostringstream oss_01;
+ const wstring str_01(50, L'a');
+
+ oss_01.width(WIDTH);
+ const streamsize width = oss_01.width();
+
+ oss_01 << str_01;
+
+ VERIFY( oss_01.good() );
+ VERIFY( oss_01.str().size() == wstring::size_type(width) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/4.cc
new file mode 100644
index 000000000..78bdf5132
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/4.cc
@@ -0,0 +1,65 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// testing basic_stringbuf::xsputn via stress testing with large strings
+// based on a bug report libstdc++ 9
+void test04(std::size_t size)
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring str(size, L's');
+ std::size_t expected_size = 2 * (size + 1);
+ std::wostringstream oss(str);
+
+ // sanity checks
+ VERIFY( str.size() == size );
+ VERIFY( oss.good() );
+
+ // stress test
+ oss << str << std::endl;
+ if (!oss.good())
+ test = false;
+
+ oss << str << std::endl;
+ if (!oss.good())
+ test = false;
+
+ VERIFY( str.size() == size );
+ VERIFY( oss.good() );
+ std::wstring str_tmp = oss.str();
+ VERIFY( str_tmp.size() == expected_size );
+}
+
+int main()
+{
+ test04(1); // expected_size == 4
+ test04(1000); // expected_size == 2002
+ test04(10000); // expected_size == 20002
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/5.cc
new file mode 100644
index 000000000..d9657a4c7
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/5.cc
@@ -0,0 +1,86 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <testsuite_hooks.h>
+
+// testing basic_filebuf::xsputn via stress testing with large strings
+// based on a bug report libstdc++ 9
+// mode == out
+void test05(std::size_t size)
+{
+ bool test __attribute__((unused)) = true;
+ const char filename[] = "inserters_extractors-1.txt";
+ const wchar_t fillc = L'f';
+ std::wofstream ofs(filename);
+ std::wstring str(size, fillc);
+
+ // sanity checks
+ VERIFY( str.size() == size );
+ VERIFY( ofs.good() );
+
+ // stress test
+ ofs << str << std::endl;
+ if (!ofs.good())
+ test = false;
+
+ ofs << str << std::endl;
+ if (!ofs.good())
+ test = false;
+
+ VERIFY( str.size() == size );
+ VERIFY( ofs.good() );
+
+ ofs.close();
+
+ // sanity check on the written file
+ std::wifstream ifs(filename);
+ std::size_t count = 0;
+ wchar_t c;
+ while (count <= (2 * size) + 4)
+ {
+ ifs >> c;
+ if (ifs.good() && c == fillc)
+ {
+ ++count;
+ c = '0';
+ }
+ else
+ break;
+ }
+
+ VERIFY( count == 2 * size );
+}
+
+int main()
+{
+ test05(1);
+ test05(1000);
+ test05(10000);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/6.cc
new file mode 100644
index 000000000..e49f61fb0
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/6.cc
@@ -0,0 +1,61 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// istringstream/stringbuf extractor properly size buffer based on
+// actual, not allocated contents (string.size() vs. string.capacity()).
+// http://gcc.gnu.org/ml/libstdc++/1999-q4/msg00049.html
+void test06(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef std::wstring::size_type size_type;
+ std::wstring str01(L"@silent");
+ size_type i01 = str01.size();
+ size_type i02 = str01.capacity();
+ str01.erase(0, 1);
+ size_type i03 = str01.size();
+ size_type i04 = str01.capacity();
+ VERIFY( i01 - 1 == i03 );
+ VERIFY( i02 >= i04 );
+
+ std::wistringstream is(str01);
+ std::wstring str02;
+ is >> str02 >> std::ws;
+ size_type i05 = str02.size();
+ size_type i06 = str02.capacity();
+ VERIFY( i05 == i03 );
+ VERIFY( i06 <= i04 );
+}
+
+int main()
+{
+ test06();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/7.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/7.cc
new file mode 100644
index 000000000..4032e389d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/7.cc
@@ -0,0 +1,53 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <testsuite_hooks.h>
+
+// http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00085.html
+// istream::operator>>(string)
+// sets failbit
+// NB: this is a defect in the standard.
+void test07(void)
+{
+ bool test __attribute__((unused)) = true;
+ const std::wstring name(L"z6.cc");
+ std::wistringstream iss(name);
+ int i = 0;
+ std::wstring s;
+ while (iss >> s)
+ ++i;
+
+ VERIFY( i < 3 );
+ VERIFY( static_cast<bool>(iss.rdstate() & std::ios_base::failbit) );
+}
+
+int main()
+{
+ test07();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/8.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/8.cc
new file mode 100644
index 000000000..58dc00eca
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/8.cc
@@ -0,0 +1,53 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+// libstdc++/1019
+void test08()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ wistringstream istrm(L"enero:2001");
+ int year;
+ wchar_t sep;
+ wstring month;
+
+ istrm >> setw(5) >> month >> sep >> year;
+ VERIFY( month.size() == 5 );
+ VERIFY( sep == ':' );
+ VERIFY( year == 2001 );
+}
+
+int main()
+{
+ test08();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/9.cc b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/9.cc
new file mode 100644
index 000000000..d7fa9467d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/inserters_extractors/wchar_t/9.cc
@@ -0,0 +1,56 @@
+// 1999-07-01 bkoz
+
+// Copyright (C) 1999, 2000, 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.7.9 inserters and extractors
+
+// NB: This file is predicated on sstreams, istreams, and ostreams
+// working, not to mention other major details like char_traits, and
+// all of the string class.
+
+#include <string>
+#include <sstream>
+#include <iomanip>
+#include <testsuite_hooks.h>
+
+// libstdc++/2830
+void test09()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring blanks(3, L'\0');
+ std::wstring foo = L"peace";
+ foo += blanks;
+ foo += L"& love";
+
+ std::wostringstream oss1;
+ oss1 << foo;
+ VERIFY( oss1.str() == foo );
+
+ std::wostringstream oss2;
+ oss2.width(20);
+ oss2 << foo;
+ VERIFY( oss2.str() != foo );
+ VERIFY( oss2.str().size() == 20 );
+}
+
+int main()
+{
+ test09();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc
new file mode 100644
index 000000000..2030b7f63
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc
@@ -0,0 +1,64 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2009-11-11 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// DR 1261. Insufficient overloads for to_string / to_wstring
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ const string one(to_string(-2));
+ VERIFY( one == "-2" );
+
+ const string two(to_string(10u));
+ VERIFY( two == "10" );
+
+ const string three(to_string(2l));
+ VERIFY( three == "2" );
+
+ const string four(to_string(3000ul));
+ VERIFY( four == "3000" );
+
+ const string five(to_string(7ll));
+ VERIFY( five == "7" );
+
+ const string six(to_string(400ull));
+ VERIFY( six == "400" );
+
+ const string seven(to_string(-1.0F));
+ VERIFY( seven == "-1.000000" );
+
+ const string eight(to_string(2.0));
+ VERIFY( eight == "2.000000" );
+
+ const string nine(to_string(-4.0L));
+ VERIFY( nine == "-4.000000" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc
new file mode 100644
index 000000000..e4608d106
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc
@@ -0,0 +1,137 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stod(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stod(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ double d1 = 0.0;
+ size_t idx1 = 0;
+ try
+ {
+ string one("2.0a");
+ d1 = stod(one, &idx1);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( d1 == 2.0 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one("1e");
+ one.append(2 * numeric_limits<double>::max_exponent10, '9');
+ d1 = stod(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( d1 == 2.0 );
+
+ try
+ {
+ long double ld0 = numeric_limits<double>::max() / 100.0;
+ string one(to_string(ld0));
+ stod(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+
+ if ((numeric_limits<long double>::max() / 10000.0L)
+ > numeric_limits<double>::max())
+ {
+ test = false;
+ d1 = -1.0;
+ try
+ {
+ long double ld1 = numeric_limits<double>::max();
+ ld1 *= 100.0;
+ string one(to_string(ld1));
+ d1 = stod(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( d1 == -1.0 );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc
new file mode 100644
index 000000000..6f14bd3ad
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc
@@ -0,0 +1,137 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stof(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stof(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ float f1 = 0.0f;
+ size_t idx1 = 0;
+ try
+ {
+ string one("2.0a");
+ f1 = stof(one, &idx1);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( f1 == 2.0f );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one("1e");
+ one.append(2 * numeric_limits<float>::max_exponent10, '9');
+ f1 = stof(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( f1 == 2.0f );
+
+ try
+ {
+ long double ld0 = numeric_limits<float>::max() / 100.0;
+ string one(to_string(ld0));
+ stof(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+
+ if ((numeric_limits<long double>::max() / 10000.0L)
+ > numeric_limits<float>::max())
+ {
+ test = false;
+ f1 = -1.0f;
+ try
+ {
+ long double ld1 = numeric_limits<float>::max();
+ ld1 *= 100.0;
+ string one(to_string(ld1));
+ f1 = stof(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( f1 == -1.0f );
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc
new file mode 100644
index 000000000..7bcd123cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc
@@ -0,0 +1,202 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stoi(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stoi(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ int i1 = 0;
+ try
+ {
+ string one("a");
+ i1 = stoi(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ string one("78");
+ i1 = stoi(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ string one("10112");
+ i1 = stoi(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ string one("0XE");
+ i1 = stoi(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one(1000, '9');
+ i1 = stoi(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( i1 == 14 );
+
+ try
+ {
+ i1 = numeric_limits<int>::max();
+ string one(to_string((long long)i1));
+ i1 = stoi(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == numeric_limits<int>::max() );
+
+ try
+ {
+ i1 = numeric_limits<int>::min();
+ string one(to_string((long long)i1));
+ i1 = stoi(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == numeric_limits<int>::min() );
+
+ test = false;
+ i1 = 1;
+ try
+ {
+ long long ll0 = numeric_limits<int>::max();
+ ++ll0;
+ string one(to_string(ll0));
+ i1 = stoi(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( i1 == 1 );
+
+ test = false;
+ try
+ {
+ long long ll1 = numeric_limits<int>::min();
+ --ll1;
+ string one(to_string(ll1));
+ i1 = stoi(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( i1 == 1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc
new file mode 100644
index 000000000..7b61db6fb
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc
@@ -0,0 +1,165 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stol(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stol(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ long l1 = 0;
+ try
+ {
+ string one("a");
+ l1 = stol(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ string one("78");
+ l1 = stol(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ string one("10112");
+ l1 = stol(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ string one("0XE");
+ l1 = stol(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one(1000, '9');
+ l1 = stol(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( l1 == 14 );
+
+ try
+ {
+ l1 = numeric_limits<long>::max();
+ string one(to_string((long long)l1));
+ l1 = stol(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == numeric_limits<long>::max() );
+
+ try
+ {
+ l1 = numeric_limits<long>::min();
+ string one(to_string((long long)l1));
+ l1 = stol(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == numeric_limits<long>::min() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc
new file mode 100644
index 000000000..c8123bcd2
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc
@@ -0,0 +1,114 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stold(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stold(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ long double ld1 = 0.0L;
+ size_t idx1 = 0;
+ try
+ {
+ string one("2.0a");
+ ld1 = stold(one, &idx1);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ld1 == 2.0L );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one("1e");
+ one.append(2 * numeric_limits<long double>::max_exponent10, '9');
+ ld1 = stold(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ld1 == 2.0L );
+
+ try
+ {
+ long double ld0 = numeric_limits<long double>::max() / 100.0L;
+ string one(to_string(ld0));
+ stold(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc
new file mode 100644
index 000000000..161c94a09
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc
@@ -0,0 +1,165 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stoll(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stoll(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ long long ll1 = 0;
+ try
+ {
+ string one("a");
+ ll1 = stoll(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ string one("78");
+ ll1 = stoll(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ string one("10112");
+ ll1 = stoll(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ string one("0XE");
+ ll1 = stoll(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one(1000, '9');
+ ll1 = stoll(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 14 );
+
+ try
+ {
+ ll1 = numeric_limits<long long>::max();
+ string one(to_string(ll1));
+ ll1 = stoll(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == numeric_limits<long long>::max() );
+
+ try
+ {
+ ll1 = numeric_limits<long long>::min();
+ string one(to_string(ll1));
+ ll1 = stoll(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == numeric_limits<long long>::min() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc
new file mode 100644
index 000000000..b6f42f15b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc
@@ -0,0 +1,152 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stoul(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stoul(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ unsigned long ul1 = 0;
+ try
+ {
+ string one("a");
+ ul1 = stoul(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ string one("78");
+ ul1 = stoul(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ string one("10112");
+ ul1 = stoul(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ string one("0XE");
+ ul1 = stoul(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one(1000, '9');
+ ul1 = stoul(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 14 );
+
+ try
+ {
+ ul1 = numeric_limits<unsigned long>::max();
+ string one(to_string((unsigned long long)ul1));
+ ul1 = stoul(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == numeric_limits<unsigned long>::max() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc
new file mode 100644
index 000000000..15e3e85e5
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc
@@ -0,0 +1,152 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ string one;
+ stoull(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ string one("a");
+ stoull(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ unsigned long long ull1 = 0;
+ try
+ {
+ string one("a");
+ ull1 = stoull(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ string one("78");
+ ull1 = stoull(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ string one("10112");
+ ull1 = stoull(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ string one("0XE");
+ ull1 = stoull(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ string one(1000, '9');
+ ull1 = stoull(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 14 );
+
+ try
+ {
+ ull1 = numeric_limits<unsigned long long>::max();
+ string one(to_string(ull1));
+ ull1 = stoull(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == numeric_limits<unsigned long long>::max() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc
new file mode 100644
index 000000000..ede975271
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc
@@ -0,0 +1,63 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ long long ll1 = -2;
+ string one(to_string(ll1));
+ VERIFY( one == "-2" );
+
+ long long ll2 = 10;
+ string two(to_string(ll2));
+ VERIFY( two == "10" );
+
+ unsigned long long ull1 = 2;
+ string three(to_string(ull1));
+ VERIFY( three == "2" );
+
+ unsigned long long ull2 = 3000;
+ string four(to_string(ull2));
+ VERIFY( four == "3000" );
+
+ long double ld1 = 2.0L;
+ string five(to_string(ld1));
+ VERIFY( five == "2.000000" );
+
+ long double ld2 = -4.0L;
+ string six(to_string(ld2));
+ VERIFY( six == "-4.000000" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc
new file mode 100644
index 000000000..e17cc5565
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc
@@ -0,0 +1,64 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// 2009-11-11 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// DR 1261. Insufficient overloads for to_string / to_wstring
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ const wstring one(to_wstring(-2));
+ VERIFY( one == L"-2" );
+
+ const wstring two(to_wstring(10u));
+ VERIFY( two == L"10" );
+
+ const wstring three(to_wstring(2l));
+ VERIFY( three == L"2" );
+
+ const wstring four(to_wstring(3000ul));
+ VERIFY( four == L"3000" );
+
+ const wstring five(to_wstring(7ll));
+ VERIFY( five == L"7" );
+
+ const wstring six(to_wstring(400ull));
+ VERIFY( six == L"400" );
+
+ const wstring seven(to_wstring(-1.0F));
+ VERIFY( seven == L"-1.000000" );
+
+ const wstring eight(to_wstring(2.0));
+ VERIFY( eight == L"2.000000" );
+
+ const wstring nine(to_wstring(-4.0L));
+ VERIFY( nine == L"-4.000000" );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
new file mode 100644
index 000000000..e18e7434d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc
@@ -0,0 +1,140 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stod(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stod(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ double d1 = 0.0;
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"2.0a");
+ d1 = stod(one, &idx1);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( d1 == 2.0 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(L"1e");
+ one.append(2 * numeric_limits<double>::max_exponent10, L'9');
+ d1 = stod(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( d1 == 2.0 );
+
+ try
+ {
+ long double ld0 = numeric_limits<double>::max() / 100.0;
+ wstring one(to_wstring(ld0));
+ stod(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+
+ if ((numeric_limits<long double>::max() / 10000.0L)
+ > numeric_limits<double>::max())
+ {
+ test = false;
+ d1 = -1.0;
+ try
+ {
+ long double ld1 = numeric_limits<double>::max();
+ ld1 *= 100.0;
+ wstring one(to_wstring(ld1));
+ d1 = stod(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( d1 == -1.0 );
+ }
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
new file mode 100644
index 000000000..338aa5062
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc
@@ -0,0 +1,140 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stof(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stof(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ float f1 = 0.0f;
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"2.0a");
+ f1 = stof(one, &idx1);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( f1 == 2.0f );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(L"1e");
+ one.append(2 * numeric_limits<float>::max_exponent10, L'9');
+ f1 = stof(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( f1 == 2.0f );
+
+ try
+ {
+ long double ld0 = numeric_limits<float>::max() / 100.0;
+ wstring one(to_wstring(ld0));
+ stof(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+
+ if ((numeric_limits<long double>::max() / 10000.0L)
+ > numeric_limits<float>::max())
+ {
+ test = false;
+ f1 = -1.0f;
+ try
+ {
+ long double ld1 = numeric_limits<float>::max();
+ ld1 *= 100.0;
+ wstring one(to_wstring(ld1));
+ f1 = stof(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( f1 == -1.0f );
+ }
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
new file mode 100644
index 000000000..6ab66e47c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc
@@ -0,0 +1,205 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stoi(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stoi(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ int i1 = 0;
+ try
+ {
+ wstring one(L"a");
+ i1 = stoi(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"78");
+ i1 = stoi(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ wstring one(L"10112");
+ i1 = stoi(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ wstring one(L"0XE");
+ i1 = stoi(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(1000, L'9');
+ i1 = stoi(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( i1 == 14 );
+
+ try
+ {
+ i1 = numeric_limits<int>::max();
+ wstring one(to_wstring((long long)i1));
+ i1 = stoi(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == numeric_limits<int>::max() );
+
+ try
+ {
+ i1 = numeric_limits<int>::min();
+ wstring one(to_wstring((long long)i1));
+ i1 = stoi(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( i1 == numeric_limits<int>::min() );
+
+ test = false;
+ i1 = 1;
+ try
+ {
+ long long ll0 = numeric_limits<int>::max();
+ ++ll0;
+ wstring one(to_wstring(ll0));
+ i1 = stoi(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( i1 == 1 );
+
+ test = false;
+ try
+ {
+ long long ll1 = numeric_limits<int>::min();
+ --ll1;
+ wstring one(to_wstring(ll1));
+ i1 = stoi(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( i1 == 1 );
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
new file mode 100644
index 000000000..eb74d1227
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc
@@ -0,0 +1,168 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stol(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stol(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ long l1 = 0;
+ try
+ {
+ wstring one(L"a");
+ l1 = stol(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"78");
+ l1 = stol(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ wstring one(L"10112");
+ l1 = stol(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ wstring one(L"0XE");
+ l1 = stol(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(1000, L'9');
+ l1 = stol(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( l1 == 14 );
+
+ try
+ {
+ l1 = numeric_limits<long>::max();
+ wstring one(to_wstring((long long)l1));
+ l1 = stol(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == numeric_limits<long>::max() );
+
+ try
+ {
+ l1 = numeric_limits<long>::min();
+ wstring one(to_wstring((long long)l1));
+ l1 = stol(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( l1 == numeric_limits<long>::min() );
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
new file mode 100644
index 000000000..f99659341
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc
@@ -0,0 +1,117 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stold(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stold(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ long double ld1 = 0.0L;
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"2.0a");
+ ld1 = stold(one, &idx1);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ld1 == 2.0L );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(L"1e");
+ one.append(2 * numeric_limits<long double>::max_exponent10, L'9');
+ ld1 = stold(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ld1 == 2.0L );
+
+ try
+ {
+ long double ld0 = numeric_limits<long double>::max() / 100.0L;
+ wstring one(to_wstring(ld0));
+ stold(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
new file mode 100644
index 000000000..e954b13df
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc
@@ -0,0 +1,168 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stoll(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stoll(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ long long ll1 = 0;
+ try
+ {
+ wstring one(L"a");
+ ll1 = stoll(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"78");
+ ll1 = stoll(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ wstring one(L"10112");
+ ll1 = stoll(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ wstring one(L"0XE");
+ ll1 = stoll(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(1000, L'9');
+ ll1 = stoll(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ll1 == 14 );
+
+ try
+ {
+ ll1 = numeric_limits<long long>::max();
+ wstring one(to_wstring(ll1));
+ ll1 = stoll(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == numeric_limits<long long>::max() );
+
+ try
+ {
+ ll1 = numeric_limits<long long>::min();
+ wstring one(to_wstring(ll1));
+ ll1 = stoll(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ll1 == numeric_limits<long long>::min() );
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
new file mode 100644
index 000000000..b1edae4d1
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc
@@ -0,0 +1,155 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stoul(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stoul(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ unsigned long ul1 = 0;
+ try
+ {
+ wstring one(L"a");
+ ul1 = stoul(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"78");
+ ul1 = stoul(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ wstring one(L"10112");
+ ul1 = stoul(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ wstring one(L"0XE");
+ ul1 = stoul(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(1000, L'9');
+ ul1 = stoul(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ul1 == 14 );
+
+ try
+ {
+ ul1 = numeric_limits<unsigned long>::max();
+ wstring one(to_wstring((unsigned long long)ul1));
+ ul1 = stoul(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ul1 == numeric_limits<unsigned long>::max() );
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
new file mode 100644
index 000000000..c65683071
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc
@@ -0,0 +1,155 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <limits>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = false;
+ using namespace std;
+
+ try
+ {
+ wstring one;
+ stoull(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ test = false;
+ try
+ {
+ wstring one(L"a");
+ stoull(one);
+ }
+ catch(std::invalid_argument)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+
+ unsigned long long ull1 = 0;
+ try
+ {
+ wstring one(L"a");
+ ull1 = stoull(one, 0, 16);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 10 );
+
+ size_t idx1 = 0;
+ try
+ {
+ wstring one(L"78");
+ ull1 = stoull(one, &idx1, 8);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 7 );
+ VERIFY( idx1 = 1 );
+
+ try
+ {
+ wstring one(L"10112");
+ ull1 = stoull(one, &idx1, 2);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 11 );
+ VERIFY( idx1 == 4 );
+
+ try
+ {
+ wstring one(L"0XE");
+ ull1 = stoull(one, &idx1, 0);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 14 );
+ VERIFY( idx1 == 3 );
+
+ test = false;
+ try
+ {
+ wstring one(1000, L'9');
+ ull1 = stoull(one);
+ }
+ catch(std::out_of_range)
+ {
+ test = true;
+ }
+ catch(...)
+ {
+ }
+ VERIFY( test );
+ VERIFY( ull1 == 14 );
+
+ try
+ {
+ ull1 = numeric_limits<unsigned long long>::max();
+ wstring one(to_wstring(ull1));
+ ull1 = stoull(one);
+ }
+ catch(...)
+ {
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( ull1 == numeric_limits<unsigned long long>::max() );
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
new file mode 100644
index 000000000..31af58f05
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc
@@ -0,0 +1,66 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+// 2008-06-15 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008, 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.4 Numeric Conversions [string.conversions]
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+#ifdef _GLIBCXX_USE_C99
+
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ long long ll1 = -2;
+ wstring one(to_wstring(ll1));
+ VERIFY( one == L"-2" );
+
+ long long ll2 = 10;
+ wstring two(to_wstring(ll2));
+ VERIFY( two == L"10" );
+
+ unsigned long long ull1 = 2;
+ wstring three(to_wstring(ull1));
+ VERIFY( three == L"2" );
+
+ unsigned long long ull2 = 3000;
+ wstring four(to_wstring(ull2));
+ VERIFY( four == L"3000" );
+
+ long double ld1 = 2.0L;
+ wstring five(to_wstring(ld1));
+ VERIFY( five == L"2.000000" );
+
+ long double ld2 = -4.0L;
+ wstring six(to_wstring(ld2));
+ VERIFY( six == L"-4.000000" );
+
+#endif
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/char/1.cc
new file mode 100644
index 000000000..de0fe168e
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/char/1.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2004, 2009, 2010 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.6 string operations
+
+#include <string>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string empty;
+
+ // data() for size == 0 is non-NULL.
+ VERIFY( empty.size() == 0 );
+ const std::string::value_type* p = empty.data();
+ VERIFY( p );
+
+ return 0;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/wchar_t/1.cc
new file mode 100644
index 000000000..a57464aa5
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/wchar_t/1.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2004, 2009, 2010 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.6 string operations
+
+#include <string>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring empty;
+
+ // data() for size == 0 is non-NULL.
+ VERIFY( empty.size() == 0 );
+ const std::wstring::value_type* p = empty.data();
+ VERIFY( p );
+
+ return 0;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc
new file mode 100644
index 000000000..e9b030e59
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/1.cc
@@ -0,0 +1,49 @@
+// 1999-05-07 bkoz
+
+// Copyright (C) 1999, 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.6 string operations
+
+#include <string>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ std::string str1;
+ std::string str2;
+
+ // Should get this:
+ // 1:8-chars_8-chars_
+ // 2:8-chars_8-chars_
+ str1 = std::string("8-chars_") + "8-chars_";
+ str1.c_str();
+ // printf("1:%s\n", str1.c_str());
+ str2 = str1 + "7-chars";
+ // printf("2:%s\n", str1.c_str()); //str1 is gone
+ str1.c_str();
+ return 0;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/2.cc
new file mode 100644
index 000000000..7be6ae5cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/2.cc
@@ -0,0 +1,294 @@
+// 1998-10-01, 1999-06-25 bkoz
+
+// Copyright (C) 1998, 1999, 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.7.1 basic_string non-member functions
+
+// 21.3.7.2 operator==
+/*
+template<class charT, class traits, class Allocator>
+ bool operator==(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator==(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator==(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+*/
+
+// 21.3.7.3 operator!=
+/*
+template<class charT, class traits, class Allocator>
+ bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator!=(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+*/
+
+// 21.3.7.4 operator<
+/*
+template<class charT, class traits, class Allocator>
+ bool operator< (const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator< (const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator< (const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+// 21.3.7.5 operator>
+/*
+template<class charT, class traits, class Allocator>
+ bool operator> (const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator> (const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator> (const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+//21.3.7.6 operator<=
+/*
+template<class charT, class traits, class Allocator>
+ bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator<=(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+// 21.3.7.7 operator>=
+/*
+template<class charT, class traits, class Allocator>
+ bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator>=(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+#include <string>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ std::string str_0("costa rica");
+ std::string str_1("costa marbella");
+ std::string str_2("cost");
+ std::string str_3("costa ricans");
+ std::string str_4;
+
+ str_4 = str_0;
+ //comparisons between string objects
+ VERIFY( !(str_0 == str_1) );
+ VERIFY( !(str_0 == str_2) );
+ VERIFY( !(str_0 == str_3) );
+ VERIFY( !(str_1 == str_0) );
+ VERIFY( !(str_2 == str_0) );
+ VERIFY( !(str_3 == str_0) );
+ VERIFY( str_4 == str_0 );
+ VERIFY( str_0 == str_4 );
+
+ VERIFY( str_0 != str_1 );
+ VERIFY( str_0 != str_2 );
+ VERIFY( str_0 != str_3 );
+ VERIFY( str_1 != str_0 );
+ VERIFY( str_2 != str_0 );
+ VERIFY( str_3 != str_0 );
+ VERIFY( !(str_0 != str_4) );
+ VERIFY( !(str_4 != str_0) );
+
+ VERIFY( str_0 > str_1 ); //true cuz r>m
+ VERIFY( str_0 > str_2 );
+ VERIFY( !(str_0 > str_3) );
+ VERIFY( !(str_1 > str_0) ); //false cuz m<r
+ VERIFY( !(str_2 > str_0) );
+ VERIFY( str_3 > str_0 );
+ VERIFY( !(str_0 > str_4) );
+ VERIFY( !(str_4 > str_0) );
+
+ VERIFY( !(str_0 < str_1) ); //false cuz r>m
+ VERIFY( !(str_0 < str_2) );
+ VERIFY( str_0 < str_3 );
+ VERIFY( str_1 < str_0 ); //true cuz m<r
+ VERIFY( str_2 < str_0 );
+ VERIFY( !(str_3 < str_0) );
+ VERIFY( !(str_0 < str_4) );
+ VERIFY( !(str_4 < str_0) );
+
+ VERIFY( str_0 >= str_1 ); //true cuz r>m
+ VERIFY( str_0 >= str_2 );
+ VERIFY( !(str_0 >= str_3) );
+ VERIFY( !(str_1 >= str_0) );//false cuz m<r
+ VERIFY( !(str_2 >= str_0) );
+ VERIFY( str_3 >= str_0 );
+ VERIFY( str_0 >= str_4 );
+ VERIFY( str_4 >= str_0 );
+
+ VERIFY( !(str_0 <= str_1) );//false cuz r>m
+ VERIFY( !(str_0 <= str_2) );
+ VERIFY( str_0 <= str_3 );
+ VERIFY( str_1 <= str_0 );//true cuz m<r
+ VERIFY( str_2 <= str_0 );
+ VERIFY( !(str_3 <= str_0) );
+ VERIFY( str_0 <= str_4 );
+ VERIFY( str_4 <= str_0 );
+
+ //comparisons between string object and string literal
+ VERIFY( !(str_0 == "costa marbella") );
+ VERIFY( !(str_0 == "cost") );
+ VERIFY( !(str_0 == "costa ricans") );
+ VERIFY( !("costa marbella" == str_0) );
+ VERIFY( !("cost" == str_0) );
+ VERIFY( !("costa ricans" == str_0) );
+ VERIFY( "costa rica" == str_0 );
+ VERIFY( str_0 == "costa rica" );
+
+ VERIFY( str_0 != "costa marbella" );
+ VERIFY( str_0 != "cost" );
+ VERIFY( str_0 != "costa ricans" );
+ VERIFY( "costa marbella" != str_0 );
+ VERIFY( "cost" != str_0 );
+ VERIFY( "costa ricans" != str_0 );
+ VERIFY( !("costa rica" != str_0) );
+ VERIFY( !(str_0 != "costa rica") );
+
+ VERIFY( str_0 > "costa marbella" ); //true cuz r>m
+ VERIFY( str_0 > "cost" );
+ VERIFY( !(str_0 > "costa ricans") );
+ VERIFY( !("costa marbella" > str_0) );//false cuz m<r
+ VERIFY( !("cost" > str_0) );
+ VERIFY( "costa ricans" > str_0 );
+ VERIFY( !("costa rica" > str_0) );
+ VERIFY( !(str_0 > "costa rica") );
+
+ VERIFY( !(str_0 < "costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 < "cost") );
+ VERIFY( str_0 < "costa ricans" );
+ VERIFY( "costa marbella" < str_0 );//true cuz m<r
+ VERIFY( "cost" < str_0 );
+ VERIFY( !("costa ricans" < str_0) );
+ VERIFY( !("costa rica" < str_0) );
+ VERIFY( !(str_0 < "costa rica") );
+
+ VERIFY( str_0 >= "costa marbella" );//true cuz r>m
+ VERIFY( str_0 >= "cost" );
+ VERIFY( !(str_0 >= "costa ricans") );
+ VERIFY( !("costa marbella" >= str_0) );//false cuz m<r
+ VERIFY( !("cost" >= str_0) );
+ VERIFY( "costa ricans" >= str_0 );
+ VERIFY( "costa rica" >= str_0 );
+ VERIFY( str_0 >= "costa rica" );
+
+ VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 <= "cost") );
+ VERIFY( str_0 <= "costa ricans" );
+ VERIFY( "costa marbella" <= str_0 );//true cuz m<r
+ VERIFY( "cost" <= str_0 );
+ VERIFY( !("costa ricans" <= str_0) );
+ VERIFY( "costa rica" <= str_0 );
+ VERIFY( str_0 <= "costa rica" );
+
+ // 21.3.7.1 operator+
+/*
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
+*/
+
+ str_4 = str_0 + "ns";
+ VERIFY( str_4 == str_3 );
+
+ const std::string str_5(" marbella");
+ str_4 = "costa" + str_5;
+ VERIFY( str_4 == str_1 );
+
+ std::string str_6("ns");
+ str_4 = str_0 + str_6;
+ VERIFY( str_4 == str_3 );
+
+ str_4 = str_0 + 'n';
+ str_4 = str_4 + 's';
+ VERIFY( str_4 == str_3 );
+
+ str_4 = 'a' + str_6;
+ str_4 = 'c' + str_4;
+ str_4 = 'i' + str_4;
+ str_4 = 'r' + str_4;
+ str_4 = ' ' + str_4;
+ str_4 = 'a' + str_4;
+ str_4 = 't' + str_4;
+ str_4 = 's' + str_4;
+ str_4 = 'o' + str_4;
+ str_4 = 'c' + str_4;
+ VERIFY( str_4 == str_3 );
+ return 0;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/3.cc
new file mode 100644
index 000000000..6bd573fe3
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/3.cc
@@ -0,0 +1,93 @@
+// 2010-12-17 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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/>.
+//
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::string;
+
+ VERIFY( (string("abc") + string("def")
+ == string("abcdef")) );
+ string s1("abc");
+ VERIFY( s1 + string("def") == string("abcdef") );
+ string s2("def");
+ VERIFY( string("abc") + s2 == string("abcdef") );
+ VERIFY( string("abc") + 'd' == string("abcd") );
+ VERIFY( string("abc") + "def" == string("abcdef") );
+ VERIFY( 'a' + string("bcd") == string("abcd") );
+ VERIFY( "abc" + string("def") == string("abcdef") );
+
+ VERIFY( (string("abcdefghij") + string("klmnopqrst")
+ == string("abcdefghijklmnopqrst")) );
+ string s1l("abcdefghij");
+ VERIFY( (s1l + string("klmnopqrst")
+ == string("abcdefghijklmnopqrst")) );
+ string s2l("klmnopqrst");
+ VERIFY( (string("abcdefghij") + s2l
+ == string("abcdefghijklmnopqrst")) );
+ VERIFY( (string("abcdefghijklmno") + 'p'
+ == string("abcdefghijklmnop")) );
+ VERIFY( (string("abcdefghijklmno") + "pqrst"
+ == string("abcdefghijklmnopqrst")) );
+ VERIFY( ('a' + string("bcdefghijklmnop")
+ == string("abcdefghijklmnop")) );
+ VERIFY( ("abcde" + string("fghijklmnopqrst")
+ == string("abcdefghijklmnopqrst")) );
+
+ VERIFY( (string("abcdefghijklmnopqrst") + string("uvwxy")
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (string("abcde") + string("fghijklmnopqrstuvwxy")
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ string s1ll1("abcdefghijklmnopqrst");
+ VERIFY( (s1ll1 + string("uvwxy")
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ string s1ll2("abcde");
+ VERIFY( (s1ll2 + string("fghijklmnopqrstuvwxy")
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ string s2ll1("fghijklmnopqrstuvwxy");
+ VERIFY( (string("abcde") + s2ll1
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ string s2ll2("uvwxy");
+ VERIFY( (string("abcdefghijklmnopqrst") + s2ll2
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (string("abcdefghijklmnopqrst") + 'u'
+ == string("abcdefghijklmnopqrstu")) );
+ VERIFY( (string("abcdefghijklmnopqrst") + "uvwxy"
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (string("abcde") + "fghijklmnopqrstuvwxy"
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( ('a' + string("bcdefghijklmnopqrstuvwxy")
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( ("abcde" + string("fghijklmnopqrstuvwxy")
+ == string("abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( ("abcdefghijklmnopqrst" + string("uvwxy")
+ == string("abcdefghijklmnopqrstuvwxy")) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/4.cc
new file mode 100644
index 000000000..e1e771d2d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/4.cc
@@ -0,0 +1,79 @@
+// 2010-12-19 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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/>.
+//
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::string;
+ using std::move;
+
+ string s01("abc");
+ s01.reserve(30);
+ string s02("def");
+ s02.reserve(30);
+ VERIFY( move(s01) + move(s02) == string("abcdef") );
+
+ string s03("abcdefghijklmnopqrstuvw");
+ string s04("xyz");
+ s04.reserve(30);
+ VERIFY( move(s03) + move(s04) == string("abcdefghijklmnopqrstuvwxyz") );
+
+ string s05("abc");
+ s05.reserve(30);
+ string s06("defghijklmnopqrstuvwxyz");
+ VERIFY( move(s05) + move(s06) == string("abcdefghijklmnopqrstuvwxyz") );
+
+ const string sc1("abc");
+ string s07("def");
+ s07.reserve(30);
+ VERIFY( sc1 + move(s07) == string("abcdef") );
+
+ const string sc2("def");
+ string s08("abc");
+ s08.reserve(30);
+ VERIFY( move(s08) + sc2 == string("abcdef") );
+
+ string s09("abc");
+ s09.reserve(30);
+ VERIFY( move(s09) + 'd' == string("abcd") );
+
+ string s10("abc");
+ s10.reserve(30);
+ VERIFY( move(s10) + "def" == string("abcdef") );
+
+ string s11("bcd");
+ s11.reserve(30);
+ VERIFY( 'a' + move(s11) == string("abcd") );
+
+ string s12("def");
+ s12.reserve(30);
+ VERIFY( "abc" + move(s12) == string("abcdef") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc
new file mode 100644
index 000000000..3bdc0d25b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/1.cc
@@ -0,0 +1,49 @@
+// 1999-05-07 bkoz
+
+// Copyright (C) 1999, 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.6 string operations
+
+#include <string>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+
+ std::wstring str1;
+ std::wstring str2;
+
+ // Should get this:
+ // 1:8-chars_8-chars_
+ // 2:8-chars_8-chars_
+ str1 = std::wstring(L"8-chars_") + L"8-chars_";
+ str1.c_str();
+ // wprintf("1:%s\n", str1.c_str());
+ str2 = str1 + L"7-chars";
+ // wprintf("2:%s\n", str1.c_str()); //str1 is gone
+ str1.c_str();
+ return 0;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc
new file mode 100644
index 000000000..a563f5377
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc
@@ -0,0 +1,294 @@
+// 1998-10-01, 1999-06-25 bkoz
+
+// Copyright (C) 1998, 1999, 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.7.1 basic_string non-member functions
+
+// 21.3.7.2 operator==
+/*
+template<class charT, class traits, class Allocator>
+ bool operator==(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator==(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator==(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+*/
+
+// 21.3.7.3 operator!=
+/*
+template<class charT, class traits, class Allocator>
+ bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator!=(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+*/
+
+// 21.3.7.4 operator<
+/*
+template<class charT, class traits, class Allocator>
+ bool operator< (const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator< (const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator< (const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+// 21.3.7.5 operator>
+/*
+template<class charT, class traits, class Allocator>
+ bool operator> (const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator> (const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator> (const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+//21.3.7.6 operator<=
+/*
+template<class charT, class traits, class Allocator>
+ bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator<=(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+// 21.3.7.7 operator>=
+/*
+template<class charT, class traits, class Allocator>
+ bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ bool operator>=(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+*/
+
+#include <string>
+#include <testsuite_hooks.h>
+
+int test01(void)
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring str_0(L"costa rica");
+ std::wstring str_1(L"costa marbella");
+ std::wstring str_2(L"cost");
+ std::wstring str_3(L"costa ricans");
+ std::wstring str_4;
+
+ str_4 = str_0;
+ //comparisons between string objects
+ VERIFY( !(str_0 == str_1) );
+ VERIFY( !(str_0 == str_2) );
+ VERIFY( !(str_0 == str_3) );
+ VERIFY( !(str_1 == str_0) );
+ VERIFY( !(str_2 == str_0) );
+ VERIFY( !(str_3 == str_0) );
+ VERIFY( str_4 == str_0 );
+ VERIFY( str_0 == str_4 );
+
+ VERIFY( str_0 != str_1 );
+ VERIFY( str_0 != str_2 );
+ VERIFY( str_0 != str_3 );
+ VERIFY( str_1 != str_0 );
+ VERIFY( str_2 != str_0 );
+ VERIFY( str_3 != str_0 );
+ VERIFY( !(str_0 != str_4) );
+ VERIFY( !(str_4 != str_0) );
+
+ VERIFY( str_0 > str_1 ); //true cuz r>m
+ VERIFY( str_0 > str_2 );
+ VERIFY( !(str_0 > str_3) );
+ VERIFY( !(str_1 > str_0) ); //false cuz m<r
+ VERIFY( !(str_2 > str_0) );
+ VERIFY( str_3 > str_0 );
+ VERIFY( !(str_0 > str_4) );
+ VERIFY( !(str_4 > str_0) );
+
+ VERIFY( !(str_0 < str_1) ); //false cuz r>m
+ VERIFY( !(str_0 < str_2) );
+ VERIFY( str_0 < str_3 );
+ VERIFY( str_1 < str_0 ); //true cuz m<r
+ VERIFY( str_2 < str_0 );
+ VERIFY( !(str_3 < str_0) );
+ VERIFY( !(str_0 < str_4) );
+ VERIFY( !(str_4 < str_0) );
+
+ VERIFY( str_0 >= str_1 ); //true cuz r>m
+ VERIFY( str_0 >= str_2 );
+ VERIFY( !(str_0 >= str_3) );
+ VERIFY( !(str_1 >= str_0) );//false cuz m<r
+ VERIFY( !(str_2 >= str_0) );
+ VERIFY( str_3 >= str_0 );
+ VERIFY( str_0 >= str_4 );
+ VERIFY( str_4 >= str_0 );
+
+ VERIFY( !(str_0 <= str_1) );//false cuz r>m
+ VERIFY( !(str_0 <= str_2) );
+ VERIFY( str_0 <= str_3 );
+ VERIFY( str_1 <= str_0 );//true cuz m<r
+ VERIFY( str_2 <= str_0 );
+ VERIFY( !(str_3 <= str_0) );
+ VERIFY( str_0 <= str_4 );
+ VERIFY( str_4 <= str_0 );
+
+ //comparisons between string object and string literal
+ VERIFY( !(str_0 == L"costa marbella") );
+ VERIFY( !(str_0 == L"cost") );
+ VERIFY( !(str_0 == L"costa ricans") );
+ VERIFY( !(L"costa marbella" == str_0) );
+ VERIFY( !(L"cost" == str_0) );
+ VERIFY( !(L"costa ricans" == str_0) );
+ VERIFY( L"costa rica" == str_0 );
+ VERIFY( str_0 == L"costa rica" );
+
+ VERIFY( str_0 != L"costa marbella" );
+ VERIFY( str_0 != L"cost" );
+ VERIFY( str_0 != L"costa ricans" );
+ VERIFY( L"costa marbella" != str_0 );
+ VERIFY( L"cost" != str_0 );
+ VERIFY( L"costa ricans" != str_0 );
+ VERIFY( !(L"costa rica" != str_0) );
+ VERIFY( !(str_0 != L"costa rica") );
+
+ VERIFY( str_0 > L"costa marbella" ); //true cuz r>m
+ VERIFY( str_0 > L"cost" );
+ VERIFY( !(str_0 > L"costa ricans") );
+ VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r
+ VERIFY( !(L"cost" > str_0) );
+ VERIFY( L"costa ricans" > str_0 );
+ VERIFY( !(L"costa rica" > str_0) );
+ VERIFY( !(str_0 > L"costa rica") );
+
+ VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 < L"cost") );
+ VERIFY( str_0 < L"costa ricans" );
+ VERIFY( L"costa marbella" < str_0 );//true cuz m<r
+ VERIFY( L"cost" < str_0 );
+ VERIFY( !(L"costa ricans" < str_0) );
+ VERIFY( !(L"costa rica" < str_0) );
+ VERIFY( !(str_0 < L"costa rica") );
+
+ VERIFY( str_0 >= L"costa marbella" );//true cuz r>m
+ VERIFY( str_0 >= L"cost" );
+ VERIFY( !(str_0 >= L"costa ricans") );
+ VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r
+ VERIFY( !(L"cost" >= str_0) );
+ VERIFY( L"costa ricans" >= str_0 );
+ VERIFY( L"costa rica" >= str_0 );
+ VERIFY( str_0 >= L"costa rica" );
+
+ VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 <= L"cost") );
+ VERIFY( str_0 <= L"costa ricans" );
+ VERIFY( L"costa marbella" <= str_0 );//true cuz m<r
+ VERIFY( L"cost" <= str_0 );
+ VERIFY( !(L"costa ricans" <= str_0) );
+ VERIFY( L"costa rica" <= str_0 );
+ VERIFY( str_0 <= L"costa rica" );
+
+ // 21.3.7.1 operator+
+/*
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const basic_string<charT,traits,Allocator>& lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const charT* lhs,
+ const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const basic_string<charT,traits,Allocator>& lhs,
+ const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+ basic_string<charT,traits,Allocator>
+ operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
+*/
+
+ str_4 = str_0 + L"ns";
+ VERIFY( str_4 == str_3 );
+
+ const std::wstring str_5(L" marbella");
+ str_4 = L"costa" + str_5;
+ VERIFY( str_4 == str_1 );
+
+ std::wstring str_6(L"ns");
+ str_4 = str_0 + str_6;
+ VERIFY( str_4 == str_3 );
+
+ str_4 = str_0 + L'n';
+ str_4 = str_4 + L's';
+ VERIFY( str_4 == str_3 );
+
+ str_4 = L'a' + str_6;
+ str_4 = L'c' + str_4;
+ str_4 = L'i' + str_4;
+ str_4 = L'r' + str_4;
+ str_4 = L' ' + str_4;
+ str_4 = L'a' + str_4;
+ str_4 = L't' + str_4;
+ str_4 = L's' + str_4;
+ str_4 = L'o' + str_4;
+ str_4 = L'c' + str_4;
+ VERIFY( str_4 == str_3 );
+ return 0;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/3.cc
new file mode 100644
index 000000000..77915f5e3
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/3.cc
@@ -0,0 +1,93 @@
+// 2010-12-17 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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/>.
+//
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::wstring;
+
+ VERIFY( (wstring(L"abc") + wstring(L"def")
+ == wstring(L"abcdef")) );
+ wstring s1(L"abc");
+ VERIFY( s1 + wstring(L"def") == wstring(L"abcdef") );
+ wstring s2(L"def");
+ VERIFY( wstring(L"abc") + s2 == wstring(L"abcdef") );
+ VERIFY( wstring(L"abc") + L'd' == wstring(L"abcd") );
+ VERIFY( wstring(L"abc") + L"def" == wstring(L"abcdef") );
+ VERIFY( L'a' + wstring(L"bcd") == wstring(L"abcd") );
+ VERIFY( L"abc" + wstring(L"def") == wstring(L"abcdef") );
+
+ VERIFY( (wstring(L"abcdefghij") + wstring(L"klmnopqrst")
+ == wstring(L"abcdefghijklmnopqrst")) );
+ wstring s1l(L"abcdefghij");
+ VERIFY( (s1l + wstring(L"klmnopqrst")
+ == wstring(L"abcdefghijklmnopqrst")) );
+ wstring s2l(L"klmnopqrst");
+ VERIFY( (wstring(L"abcdefghij") + s2l
+ == wstring(L"abcdefghijklmnopqrst")) );
+ VERIFY( (wstring(L"abcdefghijklmno") + L'p'
+ == wstring(L"abcdefghijklmnop")) );
+ VERIFY( (wstring(L"abcdefghijklmno") + L"pqrst"
+ == wstring(L"abcdefghijklmnopqrst")) );
+ VERIFY( (L'a' + wstring(L"bcdefghijklmnop")
+ == wstring(L"abcdefghijklmnop")) );
+ VERIFY( (L"abcde" + wstring(L"fghijklmnopqrst")
+ == wstring(L"abcdefghijklmnopqrst")) );
+
+ VERIFY( (wstring(L"abcdefghijklmnopqrst") + wstring(L"uvwxy")
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (wstring(L"abcde") + wstring(L"fghijklmnopqrstuvwxy")
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ wstring s1ll1(L"abcdefghijklmnopqrst");
+ VERIFY( (s1ll1 + wstring(L"uvwxy")
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ wstring s1ll2(L"abcde");
+ VERIFY( (s1ll2 + wstring(L"fghijklmnopqrstuvwxy")
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ wstring s2ll1(L"fghijklmnopqrstuvwxy");
+ VERIFY( (wstring(L"abcde") + s2ll1
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ wstring s2ll2(L"uvwxy");
+ VERIFY( (wstring(L"abcdefghijklmnopqrst") + s2ll2
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (wstring(L"abcdefghijklmnopqrst") + L'u'
+ == wstring(L"abcdefghijklmnopqrstu")) );
+ VERIFY( (wstring(L"abcdefghijklmnopqrst") + L"uvwxy"
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (wstring(L"abcde") + L"fghijklmnopqrstuvwxy"
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (L'a' + wstring(L"bcdefghijklmnopqrstuvwxy")
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (L"abcde" + wstring(L"fghijklmnopqrstuvwxy")
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+ VERIFY( (L"abcdefghijklmnopqrst" + wstring(L"uvwxy")
+ == wstring(L"abcdefghijklmnopqrstuvwxy")) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/4.cc
new file mode 100644
index 000000000..36e307d65
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/4.cc
@@ -0,0 +1,79 @@
+// 2010-12-19 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 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/>.
+//
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::wstring;
+ using std::move;
+
+ wstring s01(L"abc");
+ s01.reserve(30);
+ wstring s02(L"def");
+ s02.reserve(30);
+ VERIFY( move(s01) + move(s02) == wstring(L"abcdef") );
+
+ wstring s03(L"abcdefghijklmnopqrstuvw");
+ wstring s04(L"xyz");
+ s04.reserve(30);
+ VERIFY( move(s03) + move(s04) == wstring(L"abcdefghijklmnopqrstuvwxyz") );
+
+ wstring s05(L"abc");
+ s05.reserve(30);
+ wstring s06(L"defghijklmnopqrstuvwxyz");
+ VERIFY( move(s05) + move(s06) == wstring(L"abcdefghijklmnopqrstuvwxyz") );
+
+ const wstring sc1(L"abc");
+ wstring s07(L"def");
+ s07.reserve(30);
+ VERIFY( sc1 + move(s07) == wstring(L"abcdef") );
+
+ const wstring sc2(L"def");
+ wstring s08(L"abc");
+ s08.reserve(30);
+ VERIFY( move(s08) + sc2 == wstring(L"abcdef") );
+
+ wstring s09(L"abc");
+ s09.reserve(30);
+ VERIFY( move(s09) + L'd' == wstring(L"abcd") );
+
+ wstring s10(L"abc");
+ s10.reserve(30);
+ VERIFY( move(s10) + L"def" == wstring(L"abcdef") );
+
+ wstring s11(L"bcd");
+ s11.reserve(30);
+ VERIFY( L'a' + move(s11) == wstring(L"abcd") );
+
+ wstring s12(L"def");
+ s12.reserve(30);
+ VERIFY( L"abc" + move(s12) == wstring(L"abcdef") );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/pthread18185.cc b/libstdc++-v3/testsuite/21_strings/basic_string/pthread18185.cc
new file mode 100644
index 000000000..12f80c443
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/pthread18185.cc
@@ -0,0 +1,52 @@
+//
+// Copyright (C) 2004, 2005, 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/>.
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <ext/new_allocator.h>
+#include <string>
+#include <pthread.h>
+
+static void*
+foo (void*)
+{
+ typedef std::char_traits<char> traits_type;
+ typedef __gnu_cxx::new_allocator<char> allocator_type;
+ typedef std::basic_string<char, traits_type, allocator_type> string_type;
+ try
+ {
+ throw string_type("leak");
+ }
+ catch (const string_type&)
+ {
+ pthread_exit (0);
+ }
+}
+
+// c++/18185
+// This used to leak memory.
+int
+main ()
+{
+ pthread_t t;
+ pthread_create (&t, 0, foo, 0);
+ pthread_join (t, 0);
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/pthread4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/pthread4.cc
new file mode 100644
index 000000000..b3dc9b20e
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/pthread4.cc
@@ -0,0 +1,106 @@
+// 2002-01-23 Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
+// Adapted from http://gcc.gnu.org/ml/gcc-bugs/2002-01/msg00679.html
+// which was adapted from pthread1.cc by Mike Lu <MLu@dynamicsoft.com>
+//
+// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
+// 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/>.
+
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options "-pthreads" { target *-*-solaris* } }
+
+#include <string>
+#include <list>
+#include <pthread.h>
+
+using namespace std;
+
+static list<string> foo;
+static pthread_mutex_t fooLock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t fooCondOverflow = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t fooCondUnderflow = PTHREAD_COND_INITIALIZER;
+static unsigned max_size = 10;
+#if defined(__CYGWIN__)
+static int iters = 10000;
+#else
+static int iters = 300000;
+#endif
+
+void*
+produce (void*)
+{
+ for (int num = 0; num < iters; )
+ {
+ string str ("test string");
+
+ pthread_mutex_lock (&fooLock);
+ while (foo.size () >= max_size)
+ pthread_cond_wait (&fooCondOverflow, &fooLock);
+ foo.push_back (str);
+ num++;
+ if (foo.size () >= (max_size / 2))
+ pthread_cond_signal (&fooCondUnderflow);
+ pthread_mutex_unlock (&fooLock);
+ }
+
+ // No more data will ever be written, ensure no fini race
+ pthread_mutex_lock (&fooLock);
+ pthread_cond_signal (&fooCondUnderflow);
+ pthread_mutex_unlock (&fooLock);
+
+ return 0;
+}
+
+void*
+consume (void*)
+{
+ for (int num = 0; num < iters; )
+ {
+ pthread_mutex_lock (&fooLock);
+ while (foo.size () == 0)
+ pthread_cond_wait (&fooCondUnderflow, &fooLock);
+ while (foo.size () > 0)
+ {
+ string str = foo.back ();
+ foo.pop_back ();
+ num++;
+ }
+ pthread_cond_signal (&fooCondOverflow);
+ pthread_mutex_unlock (&fooLock);
+ }
+
+ return 0;
+}
+
+int
+main (void)
+{
+#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500
+ pthread_setconcurrency (2);
+#endif
+
+ pthread_t prod;
+ pthread_create (&prod, 0, produce, 0);
+ pthread_t cons;
+ pthread_create (&cons, 0, consume, 0);
+
+ pthread_join (prod, 0);
+ pthread_join (cons, 0);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/range_access.cc b/libstdc++-v3/testsuite/21_strings/basic_string/range_access.cc
new file mode 100644
index 000000000..fe61b901b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/range_access.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 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/>.
+
+// 24.6.5, range access [iterator.range]
+
+#include <string>
+
+void
+test01()
+{
+ std::string s("Hello, World!");
+ std::begin(s);
+ std::end(s);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ std::wstring ws(L"Hello, World!");
+ std::begin(ws);
+ std::end(ws);
+#endif
+}
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;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/citerators.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/citerators.cc
new file mode 100644
index 000000000..fe262b098
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/citerators.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-string-conversions "" }
+
+// Copyright (C) 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/>.
+
+#include <string>
+#include <testsuite_containers.h>
+
+int main()
+{
+ __gnu_test::citerator<std::string> test1;
+ __gnu_test::citerator<std::wstring> test2;
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc
new file mode 100644
index 000000000..49ea816c4
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/dr438/constructor.cc
@@ -0,0 +1,27 @@
+// 2007-04-27 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2007, 2009 Free Software Foundation
+//
+// 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/>.
+
+// { dg-do compile }
+
+#include <string>
+
+void f()
+{
+ std::string s(10, 1);
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/basic.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/basic.cc
new file mode 100644
index 000000000..1f6b970d2
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/basic.cc
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// 2009-11-10 Benjamin Kosnik <benjamin@redhat.com>
+
+// Copyright (C) 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/>.
+
+#include <string>
+#include <exception/safety.h>
+
+void
+value()
+{
+ typedef __gnu_cxx::throw_value_limit value_type;
+ typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+ typedef std::basic_string<value_type, traits_type, allocator_type> test_type;
+ __gnu_test::basic_safety<test_type> test;
+}
+
+// Container requirement testing, exceptional behavior
+int main()
+{
+ value();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/generation_prohibited.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/generation_prohibited.cc
new file mode 100644
index 000000000..211d7c21d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/generation_prohibited.cc
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// 2009-09-14 Benjamin Kosnik <benjamin@redhat.com>
+
+// Copyright (C) 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/>.
+
+#include <string>
+#include <exception/safety.h>
+
+void
+char_allocator()
+{
+ typedef char value_type;
+ typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+ typedef std::basic_string<value_type, traits_type, allocator_type> test_type;
+ __gnu_test::generation_prohibited<test_type> test;
+}
+
+void
+wchar_allocator()
+{
+ typedef wchar_t value_type;
+ typedef __gnu_cxx::throw_allocator_random<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+ typedef std::basic_string<value_type, traits_type, allocator_type> test_type;
+ __gnu_test::generation_prohibited<test_type> test;
+}
+
+// Container requirement testing, exceptional behavior
+int main()
+{
+ // throw_allocator
+ char_allocator();
+ wchar_allocator();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/propagation_consistent.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/propagation_consistent.cc
new file mode 100644
index 000000000..8e27a919c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/exception/propagation_consistent.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-do run { xfail *-*-* } }
+
+// 2009-09-14 Benjamin Kosnik <benjamin@redhat.com>
+
+// Copyright (C) 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/>.
+
+#include <string>
+#include <exception/safety.h>
+
+void
+value()
+{
+ typedef __gnu_cxx::throw_value_limit value_type;
+ typedef __gnu_cxx::throw_allocator_limit<value_type> allocator_type;
+ typedef std::char_traits<value_type> traits_type;
+ typedef std::basic_string<value_type, traits_type, allocator_type> test_type;
+ __gnu_test::propagation_consistent<test_type> test;
+}
+
+// Container requirement testing, exceptional behavior
+int main()
+{
+ value();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc
new file mode 100644
index 000000000..11e4138f0
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 2005, 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/>.
+
+
+// This file tests explicit instantiation of basic_string
+
+#include <string>
+
+// { dg-do compile }
+
+// libstdc++/21770
+template class std::basic_string<int, std::char_traits<int>,
+ std::allocator<char> >;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc
new file mode 100644
index 000000000..759548bae
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc
@@ -0,0 +1,22 @@
+// { dg-do compile }
+
+// Copyright (C) 2008, 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/>.
+
+#include <string>
+
+template class std::basic_string<char>;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc
new file mode 100644
index 000000000..f89a26786
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// Copyright (C) 2008, 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/>.
+
+#include <string>
+
+template class std::basic_string<char16_t>;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc
new file mode 100644
index 000000000..0fdbe3c49
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+
+// Copyright (C) 2008, 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/>.
+
+#include <string>
+
+template class std::basic_string<char32_t>;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/debug.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/debug.cc
new file mode 100644
index 000000000..c9bbbd773
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/debug.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 2005, 2006, 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/>.
+
+// This file tests explicit instantiation of basic_string
+
+#include <debug/string>
+
+// { dg-do compile }
+
+// libstdc++/21770
+namespace debug = __gnu_debug;
+template class debug::basic_string<int, std::char_traits<int>,
+ std::allocator<char> >;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc
new file mode 100644
index 000000000..3137f3f70
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc
@@ -0,0 +1,22 @@
+// { dg-do compile }
+
+// Copyright (C) 2008, 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/>.
+
+#include <string>
+
+template class std::basic_string<wchar_t>;
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/requirements/typedefs.cc b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/typedefs.cc
new file mode 100644
index 000000000..240ae1fd4
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/requirements/typedefs.cc
@@ -0,0 +1,28 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009, 2010, 2011 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/>.
+
+#include <testsuite_containers.h>
+#include <string>
+
+// Check container for required typedefs.
+__gnu_test::types<std::string> t1;
+#ifdef _GLIBCXX_USE_WCHAR_T
+__gnu_test::types<std::wstring> t2;
+#endif
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/1.cc
new file mode 100644
index 000000000..752aecaba
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/1.cc
@@ -0,0 +1,92 @@
+// 2000-06-22 -=dbv=- (shamelessy copied from bkoz' find.cc)
+
+// Copyright (C) 2000, 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// 21.3.6.2 basic_string rfind
+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 npos = std::string::npos;
+ csize_type csz01, csz02;
+
+ const char str_lit01[] = "mave";
+ const std::string str01("mavericks, santa cruz");
+ std::string str02(str_lit01);
+ std::string str03("s, s");
+ std::string str04;
+
+ // size_type rfind(const string&, size_type pos = 0) const;
+ csz01 = str01.rfind(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str01, 4);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str02,3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str02);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str03);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.rfind(str03, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.rfind(str03, 12);
+ VERIFY( csz01 == 8 );
+
+ // An empty string consists of no characters
+ // therefore it should be found at every point in a string,
+ // except beyond the end
+ csz01 = str01.rfind(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.rfind(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.rfind(str04, str01.size()+1);
+ VERIFY( csz01 == str01.size() );
+
+ // size_type rfind(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.rfind(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type rfind(const char* s, size_type pos = 0) const;
+ csz01 = str01.rfind(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str_lit01, 3);
+ VERIFY( csz01 == 0 );
+
+ // size_type rfind(char c, size_type pos = 0) const;
+ csz01 = str01.rfind('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.rfind('/');
+ VERIFY( csz01 == npos );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/2.cc
new file mode 100644
index 000000000..dd41fe0d9
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/2.cc
@@ -0,0 +1,50 @@
+// from tstring.cc, from jason merrill, et. al.
+
+// Copyright (C) 2000, 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// 21.3.6.4 basic_string::find_last_of
+bool test02()
+{
+ bool test __attribute__((unused)) = true;
+ std::string z("ab");
+ std::string::size_type pos;
+ pos = z.find_last_of("ab");
+ VERIFY( pos == 1 );
+ pos = z.find_last_of("Xa");
+ VERIFY( pos == 0 );
+ pos = z.find_last_of("Xb");
+ VERIFY( pos == 1 );
+ pos = z.find_last_of("XYZ");
+ VERIFY( pos == std::string::npos );
+ pos = z.find_last_of('a');
+ VERIFY( pos == 0 );
+ pos = z.find_last_of('b');
+ VERIFY( pos == 1 );
+ pos = z.find_last_of('X');
+ VERIFY( pos == std::string::npos );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/3.cc
new file mode 100644
index 000000000..378c7c21e
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/char/3.cc
@@ -0,0 +1,64 @@
+// from tstring.cc, from jason merrill, et. al.
+
+// Copyright (C) 2000, 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// 21.3.6.6 basic_string::find_last_not_of
+bool test03()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::string::size_type csize_type;
+ std::string::size_type pos;
+ csize_type npos = std::string::npos;
+
+ std::string x;
+ pos = x.find_last_not_of('X');
+ VERIFY( pos == npos );
+ pos = x.find_last_not_of("XYZ");
+ VERIFY( pos == npos );
+
+ std::string y("a");
+ pos = y.find_last_not_of('X');
+ VERIFY( pos == 0 );
+ pos = y.find_last_not_of('a');
+ VERIFY( pos == npos );
+ pos = y.find_last_not_of("XYZ");
+ VERIFY( pos == 0 );
+ pos = y.find_last_not_of("a");
+ VERIFY( pos == npos );
+
+ std::string z("ab");
+ pos = z.find_last_not_of('X');
+ VERIFY( pos == 1 );
+ pos = z.find_last_not_of("XYZ");
+ VERIFY( pos == 1 );
+ pos = z.find_last_not_of('b');
+ VERIFY( pos == 0 );
+ pos = z.find_last_not_of("Xb");
+ VERIFY( pos == 0 );
+ pos = z.find_last_not_of("Xa");
+ VERIFY( pos == 1 );
+ return test;
+}
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/1.cc
new file mode 100644
index 000000000..ff1e7593d
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/1.cc
@@ -0,0 +1,92 @@
+// 2000-06-22 -=dbv=- (shamelessy copied from bkoz' find.cc)
+
+// Copyright (C) 2000, 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// 21.3.6.2 basic_string rfind
+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 npos = std::wstring::npos;
+ csize_type csz01, csz02;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring str01(L"mavericks, santa cruz");
+ std::wstring str02(str_lit01);
+ std::wstring str03(L"s, s");
+ std::wstring str04;
+
+ // size_type rfind(const wstring&, size_type pos = 0) const;
+ csz01 = str01.rfind(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str01, 4);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str02,3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str02);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str03);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.rfind(str03, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.rfind(str03, 12);
+ VERIFY( csz01 == 8 );
+
+ // An empty string consists of no characters
+ // therefore it should be found at every point in a string,
+ // except beyond the end
+ csz01 = str01.rfind(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.rfind(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.rfind(str04, str01.size()+1);
+ VERIFY( csz01 == str01.size() );
+
+ // size_type rfind(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.rfind(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type rfind(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.rfind(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.rfind(str_lit01, 3);
+ VERIFY( csz01 == 0 );
+
+ // size_type rfind(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.rfind(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.rfind(L'/');
+ VERIFY( csz01 == npos );
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/2.cc
new file mode 100644
index 000000000..1d4eaeeb8
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/2.cc
@@ -0,0 +1,50 @@
+// from tstring.cc, from jason merrill, et. al.
+
+// Copyright (C) 2000, 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// 21.3.6.4 basic_string::find_last_of
+bool test02()
+{
+ bool test __attribute__((unused)) = true;
+ std::wstring::size_type pos;
+ std::wstring z(L"ab");
+ pos = z.find_last_of(L"ab");
+ VERIFY( pos == 1 );
+ pos = z.find_last_of(L"Xa");
+ VERIFY( pos == 0 );
+ pos = z.find_last_of(L"Xb");
+ VERIFY( pos == 1 );
+ pos = z.find_last_of(L"XYZ");
+ VERIFY( pos == std::wstring::npos );
+ pos = z.find_last_of(L'a');
+ VERIFY( pos == 0 );
+ pos = z.find_last_of(L'b');
+ VERIFY( pos == 1 );
+ pos = z.find_last_of(L'X');
+ VERIFY( pos == std::wstring::npos );
+ return test;
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/3.cc
new file mode 100644
index 000000000..30dcba623
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/rfind/wchar_t/3.cc
@@ -0,0 +1,64 @@
+// from tstring.cc, from jason merrill, et. al.
+
+// Copyright (C) 2000, 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/>.
+
+#include <string>
+#include <testsuite_hooks.h>
+
+// 21.3.6.6 basic_string::find_last_not_of
+bool test03()
+{
+ bool test __attribute__((unused)) = true;
+ typedef std::wstring::size_type csize_type;
+ std::wstring::size_type pos;
+ csize_type npos = std::wstring::npos;
+
+ std::wstring x;
+ pos = x.find_last_not_of(L'X');
+ VERIFY( pos == npos );
+ pos = x.find_last_not_of(L"XYZ");
+ VERIFY( pos == npos );
+
+ std::wstring y(L"a");
+ pos = y.find_last_not_of(L'X');
+ VERIFY( pos == 0 );
+ pos = y.find_last_not_of(L'a');
+ VERIFY( pos == npos );
+ pos = y.find_last_not_of(L"XYZ");
+ VERIFY( pos == 0 );
+ pos = y.find_last_not_of(L"a");
+ VERIFY( pos == npos );
+
+ std::wstring z(L"ab");
+ pos = z.find_last_not_of(L'X');
+ VERIFY( pos == 1 );
+ pos = z.find_last_not_of(L"XYZ");
+ VERIFY( pos == 1 );
+ pos = z.find_last_not_of(L'b');
+ VERIFY( pos == 0 );
+ pos = z.find_last_not_of(L"Xb");
+ VERIFY( pos == 0 );
+ pos = z.find_last_not_of(L"Xa");
+ VERIFY( pos == 1 );
+ return test;
+}
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/substr/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/substr/char/1.cc
new file mode 100644
index 000000000..8aecfdc85
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/substr/char/1.cc
@@ -0,0 +1,74 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1999, 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.6.7 basic_string::substr
+
+#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[] = "rockaway, pacifica";
+ const std::string str01(str_lit01);
+ std::string str02;
+
+ // basic_string<charT, _Traits, _Alloc>
+ // substr(size_type pos = 0, size_type n = npos) const;
+ csz01 = str01.size();
+ str02 = str01.substr(0, 1);
+ VERIFY( str02 == "r" );
+ str02 = str01.substr(10);
+ VERIFY( str02 == "pacifica" );
+
+ try {
+ str02 = str01.substr(csz01 + 1);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ str02 = str01.substr(csz01);
+ VERIFY( str02.size() == 0 );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( false );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/substr/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/substr/wchar_t/1.cc
new file mode 100644
index 000000000..56c8b8362
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/substr/wchar_t/1.cc
@@ -0,0 +1,74 @@
+// 1999-06-10 bkoz
+
+// Copyright (C) 1999, 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.6.7 basic_string::substr
+
+#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"rockaway, pacifica";
+ const std::wstring str01(str_lit01);
+ std::wstring str02;
+
+ // basic_string<charT, _Traits, _Alloc>
+ // substr(size_type pos = 0, size_type n = npos) const;
+ csz01 = str01.size();
+ str02 = str01.substr(0, 1);
+ VERIFY( str02 == L"r" );
+ str02 = str01.substr(10);
+ VERIFY( str02 == L"pacifica" );
+
+ try {
+ str02 = str01.substr(csz01 + 1);
+ VERIFY( false );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( true );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+
+ try {
+ str02 = str01.substr(csz01);
+ VERIFY( str02.size() == 0 );
+ }
+ catch(std::out_of_range& fail) {
+ VERIFY( false );
+ }
+ catch(...) {
+ VERIFY( false );
+ }
+ return test;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc
new file mode 100644
index 000000000..b30bee244
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/types/1.cc
@@ -0,0 +1,47 @@
+// 2005-12-01 Paolo Carlini <pcarlini@suse.de>
+
+// Copyright (C) 2005, 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/>.
+
+// { dg-do compile }
+
+#include <string>
+
+namespace N
+{
+ struct X { };
+
+ template<typename T>
+ X operator+(T, std::size_t)
+ { return X(); }
+
+ template<typename T>
+ X operator-(T, T)
+ { return X(); }
+}
+
+int main()
+{
+ std::basic_string<N::X> s(5, N::X());
+
+ s.erase(s.begin());
+ s.erase(s.begin(), s.end());
+ s.insert(s.begin(), N::X());
+ s.replace(s.begin(), s.end(), s.begin(), s.end());
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/types/23767.cc b/libstdc++-v3/testsuite/21_strings/basic_string/types/23767.cc
new file mode 100644
index 000000000..d402ccdb0
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/types/23767.cc
@@ -0,0 +1,43 @@
+// 2005-09-12 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2005, 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/>.
+//
+
+// { dg-do compile }
+
+#include <string>
+
+struct T
+{
+ typedef std::string String;
+ typedef String::iterator iterator;
+ typedef String::const_iterator const_iterator;
+
+ char t(iterator f) { return *f; }
+ char t(const_iterator f) const { return *f; }
+};
+
+// libstdc++/23767
+void f()
+{
+ std::string s;
+ T t;
+ T::const_iterator i = s.begin();
+
+ t.t(i);
+}