3 // Copyright (C) 1994-2013 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 bool test __attribute__((unused)) = true;
30 const char* title01 = "nine types of ambiguity";
31 const char* title02 = "ultra";
32 std::string str01 = title01;
33 std::string str02 = title02;
35 str01.replace(0, 4, str02);
36 VERIFY(str01 == "ultra types of ambiguity");
38 str01.replace(15, 9, str02, 2, 2);
39 VERIFY(str01 == "ultra types of tr");
42 str02.replace(0, 0, str01, 0, std::string::npos);
43 VERIFY(str02 == "nine types of ambiguityultra");
45 str02.replace(11, 2, title02, 5);
46 VERIFY(str02 == "nine types ultra ambiguityultra");
48 str02.replace(11, 5, title01, 2);
49 VERIFY(str02 == "nine types ni ambiguityultra");
51 str01.replace(str01.size(), 0, title02);
52 VERIFY(str01 == "nine types of ambiguityultra");
56 str01.replace(str01.begin(), str01.end(), str02);
57 VERIFY(str01 == "ultra");
59 str01.replace(str01.begin(), str01.begin(), title01, 4);
60 VERIFY(str01 == "nineultra");
62 str01.replace(str01.end(), str01.end(), title01 + 5, 5);
63 VERIFY(str01 == "nineultratypes");
65 str01.replace(str01.begin(), str01.end(), title02);
66 VERIFY(str01 == "ultra");