]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc
3 // Copyright (C) 1999-2019 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.2 basic_string::append
24 #include <testsuite_hooks.h>
28 typedef std::wstring::size_type csize_type
;
29 typedef std::wstring::const_reference cref
;
30 typedef std::wstring::reference ref
;
33 const wchar_t str_lit01
[] = L
"point bolivar, texas";
34 const std::wstring
str01(str_lit01
);
35 const std::wstring
str02(L
"corpus, ");
36 const std::wstring str03
;
40 // wstring& append(const wstring&)
43 VERIFY( str05
== L
"corpus, corpus, " );
45 VERIFY( str05
== L
"corpus, corpus, point bolivar, texas" );
47 VERIFY( str05
== L
"corpus, corpus, point bolivar, texas" );
50 VERIFY( str06
== str05
);
53 // wstring& append(const wstring&, size_type pos, size_type n)
58 str06
.append(str03
, csz01
+ 1, 0);
61 catch(std::out_of_range
& fail
) {
70 str06
.append(str01
, csz01
+ 1, 0);
73 catch(std::out_of_range
& fail
) {
81 str05
.append(str01
, 0, std::wstring::npos
);
82 VERIFY( str05
== L
"corpus, point bolivar, texas" );
83 VERIFY( str05
!= str02
);
86 str06
.append(str01
, 15, std::wstring::npos
);
87 VERIFY( str06
== L
"corpus, texas" );
88 VERIFY( str02
!= str06
);
91 // wstring& append(const wchar_t* s)
95 VERIFY( str05
== str03
);
97 str05
.append(str_lit01
);
98 VERIFY( str05
== str01
);
101 str06
.append(L
"corpus, ");
102 VERIFY( str06
== L
"corpus, corpus, " );
105 // wstring& append(const wchar_t* s, size_type n)
108 str05
.append(L
"", 0);
109 VERIFY( str05
.size() == 0 );
110 VERIFY( str05
== str03
);
112 str05
.append(str_lit01
, sizeof(str_lit01
) / sizeof(wchar_t) - 1);
113 VERIFY( str05
== str01
);
116 str06
.append(L
"corpus, ", 6);
117 VERIFY( str06
== L
"corpus, corpus" );
120 str06
.append(L
"corpus, ", 12);
121 VERIFY( str06
!= L
"corpus, corpus, " );
124 // wstring& append(size_type n, char c)
127 str05
.append(0, L
'a');
128 VERIFY( str05
== str03
);
129 str06
.append(8, L
'.');
130 VERIFY( str06
== L
"........" );
133 // template<typename InputIter>
134 // wstring& append(InputIter first, InputIter last)
137 str05
.append(str03
.begin(), str03
.end());
138 VERIFY( str05
== str03
);
141 str06
.append(str01
.begin(), str01
.begin() + str01
.find(L
'r'));
142 VERIFY( str06
== L
"corpus, point boliva" );
143 VERIFY( str06
!= str01
);
144 VERIFY( str06
!= str02
);
147 str05
.append(str05
.begin(), str05
.begin() + str05
.find(L
'r'));
148 VERIFY( str05
== L
"point bolivar, texaspoint boliva" );
149 VERIFY( str05
!= str01
);