]>
Commit | Line | Data |
---|---|---|
4aca39bb | 1 | // 1999-06-10 bkoz |
2 | ||
f1717362 | 3 | // Copyright (C) 1994-2016 Free Software Foundation, Inc. |
4aca39bb | 4 | // |
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 | |
6bc9506f | 8 | // Free Software Foundation; either version 3, or (at your option) |
4aca39bb | 9 | // any later version. |
10 | ||
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. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
6bc9506f | 17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
4aca39bb | 19 | |
20 | // 21.3.5.6 basic_string::replace | |
21 | ||
22 | #include <string> | |
23 | #include <testsuite_hooks.h> | |
24 | ||
25 | // Some more miscellaneous tests | |
26 | void | |
27 | test03() | |
28 | { | |
f8ef786c | 29 | bool test __attribute__((unused)) = true; |
4aca39bb | 30 | const wchar_t* title01 = L"nine types of ambiguity"; |
31 | const wchar_t* title02 = L"ultra"; | |
32 | std::wstring str01 = title01; | |
33 | std::wstring str02 = title02; | |
34 | ||
35 | str01.replace(0, 4, str02); | |
36 | VERIFY(str01 == L"ultra types of ambiguity"); | |
37 | ||
38 | str01.replace(15, 9, str02, 2, 2); | |
39 | VERIFY(str01 == L"ultra types of tr"); | |
40 | ||
41 | str01 = title01; | |
42 | str02.replace(0, 0, str01, 0, std::wstring::npos); | |
43 | VERIFY(str02 == L"nine types of ambiguityultra"); | |
44 | ||
45 | str02.replace(11, 2, title02, 5); | |
46 | VERIFY(str02 == L"nine types ultra ambiguityultra"); | |
47 | ||
48 | str02.replace(11, 5, title01, 2); | |
49 | VERIFY(str02 == L"nine types ni ambiguityultra"); | |
50 | ||
51 | str01.replace(str01.size(), 0, title02); | |
52 | VERIFY(str01 == L"nine types of ambiguityultra"); | |
53 | ||
54 | str01 = title01; | |
55 | str02 = title02; | |
56 | str01.replace(str01.begin(), str01.end(), str02); | |
57 | VERIFY(str01 == L"ultra"); | |
58 | ||
59 | str01.replace(str01.begin(), str01.begin(), title01, 4); | |
60 | VERIFY(str01 == L"nineultra"); | |
61 | ||
62 | str01.replace(str01.end(), str01.end(), title01 + 5, 5); | |
63 | VERIFY(str01 == L"nineultratypes"); | |
64 | ||
65 | str01.replace(str01.begin(), str01.end(), title02); | |
66 | VERIFY(str01 == L"ultra"); | |
67 | } | |
68 | ||
69 | int main() | |
70 | { | |
71 | test03(); | |
72 | return 0; | |
73 | } |