]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/3.cc
3 // Copyright (C) 1994-2016 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 3, 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 COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // 21.3.5.6 basic_string::replace
23 #include <testsuite_hooks.h>
25 // Some more miscellaneous tests
29 const wchar_t* title01
= L
"nine types of ambiguity";
30 const wchar_t* title02
= L
"ultra";
31 std::wstring str01
= title01
;
32 std::wstring str02
= title02
;
34 str01
.replace(0, 4, str02
);
35 VERIFY(str01
== L
"ultra types of ambiguity");
37 str01
.replace(15, 9, str02
, 2, 2);
38 VERIFY(str01
== L
"ultra types of tr");
41 str02
.replace(0, 0, str01
, 0, std::wstring::npos
);
42 VERIFY(str02
== L
"nine types of ambiguityultra");
44 str02
.replace(11, 2, title02
, 5);
45 VERIFY(str02
== L
"nine types ultra ambiguityultra");
47 str02
.replace(11, 5, title01
, 2);
48 VERIFY(str02
== L
"nine types ni ambiguityultra");
50 str01
.replace(str01
.size(), 0, title02
);
51 VERIFY(str01
== L
"nine types of ambiguityultra");
55 str01
.replace(str01
.begin(), str01
.end(), str02
);
56 VERIFY(str01
== L
"ultra");
58 str01
.replace(str01
.begin(), str01
.begin(), title01
, 4);
59 VERIFY(str01
== L
"nineultra");
61 str01
.replace(str01
.end(), str01
.end(), title01
+ 5, 5);
62 VERIFY(str01
== L
"nineultratypes");
64 str01
.replace(str01
.begin(), str01
.end(), title02
);
65 VERIFY(str01
== L
"ultra");