]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/replace.cc
3 // Copyright (C) 1994, 1999 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // 21.3.5.6 basic_string::replace
25 #include <testsuite_hooks.h>
30 typedef std::string::size_type csize_type
;
31 typedef std::string::const_reference cref
;
32 typedef std::string::reference ref
;
33 csize_type npos
= std::string::npos
;
34 csize_type csz01
, csz02
;
36 const char str_lit01
[] = "ventura, california";
37 const std::string
str01(str_lit01
);
38 std::string
str02("del mar, california");
39 std::string
str03(" and ");
42 // string& replace(size_type pos, size_type n, const string& string)
43 // string& replace(size_type pos1, size_type n1, const string& string,
44 // size_type pos2, size_type n2)
45 // string& replace(size_type pos, size_type n1, const char* s, size_type n2)
46 // string& replace(size_type pos, size_type n1, const char* s)
47 // string& replace(size_type pos, size_type n1, size_type n2, char c)
48 // string& replace(iterator it1, iterator it2, const string& str)
49 // string& replace(iterator it1, iterator it2, const chat* s, size_type n)
50 // string& replace(iterator it1, iterator it2, const chat* s)
51 // string& replace(iterator it1, iterator it2, size_type n, char c)
52 // template<typename InputIter>
53 // string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2)
56 // with mods, from tstring.cc, from jason merrill, et. al.
57 std::string X
= "Hello";
63 std::string z
= x
.substr(2, 3);
67 VERIFY( x
== "Hero" );
71 VERIFY( x
== "jello" );
73 int ar
[] = { 'H', 'e', 'l', 'l', 'o' };
74 x
.replace(std::find(x
.begin(), x
.end(), 'l'),
75 std::find(x
.rbegin(), x
.rend(), 'l').base(), ar
,
76 ar
+ sizeof(ar
) / sizeof(ar
[0]));
77 VERIFY( x
== "jeHelloo" );