aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-31 08:27:20 +0000
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>2001-10-31 08:27:20 +0000
commitd61598c22b5fab0eeab652fb613bf08e7dc1be1e (patch)
tree5576383af19838d1ade2b679e004f0b504a28d8e /libstdc++-v3/testsuite
parentfa98834e1e6b1000b2995e84b9c26d083da4995b (diff)
2001-10-30 Paolo Carlini <pcarlini@unitus.it>
Benjamin Kosnik <bkoz@redhat.com> * include/bits/basic_string.h: Tweaks. * include/bits/basic_string.tcc (string::_M_replace(iterator, iterator, _ForwardIter, _ForwardIter, forward_iterator_tag): Fix. * src/string-inst.cc: Tweaks, add instantiation. * testsuite/21_strings/replace.cc (test02): Add test. * testsuite/21_strings/assign.cc (test01): New file. 0 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46674 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/21_strings/assign.cc46
-rw-r--r--libstdc++-v3/testsuite/21_strings/replace.cc18
2 files changed, 62 insertions, 2 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/assign.cc b/libstdc++-v3/testsuite/21_strings/assign.cc
new file mode 100644
index 00000000000..271ef65ca78
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/assign.cc
@@ -0,0 +1,46 @@
+// 2001-10-30 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 21.3.5 string modifiers
+
+#include <string>
+#include <cstdio>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test = 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");
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/replace.cc b/libstdc++-v3/testsuite/21_strings/replace.cc
index b4aac625ea1..b42ae8d3fa6 100644
--- a/libstdc++-v3/testsuite/21_strings/replace.cc
+++ b/libstdc++-v3/testsuite/21_strings/replace.cc
@@ -52,7 +52,6 @@ bool test01(void)
// template<typename InputIter>
// string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
-#if 1
// with mods, from tstring.cc, from jason merrill, et. al.
std::string X = "Hello";
std::string x = X;
@@ -75,7 +74,6 @@ bool test01(void)
std::find(x.rbegin(), x.rend(), 'l').base(), ar,
ar + sizeof(ar) / sizeof(ar[0]));
VERIFY( x == "jeHelloo" );
-#endif
#ifdef DEBUG_ASSERT
assert(test);
@@ -83,8 +81,24 @@ bool test01(void)
return test;
}
+void
+test02()
+{
+ 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()
{
test01();
+ test02();
return 0;
}