]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 21_strings / basic_string / operators / wchar_t / 2.cc
1 // 1998-10-01, 1999-06-25 bkoz
2
3 // Copyright (C) 1998-2014 Free Software Foundation, Inc.
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
8 // Free Software Foundation; either version 3, or (at your option)
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
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20 // 21.3.7.1 basic_string non-member functions
21
22 // 21.3.7.2 operator==
23 /*
24 template<class charT, class traits, class Allocator>
25 bool operator==(const basic_string<charT,traits,Allocator>& lhs,
26 const basic_string<charT,traits,Allocator>& rhs);
27
28 template<class charT, class traits, class Allocator>
29 bool operator==(const charT* lhs,
30 const basic_string<charT,traits,Allocator>& rhs);
31
32 template<class charT, class traits, class Allocator>
33 bool operator==(const basic_string<charT,traits,Allocator>& lhs,
34 const charT* rhs);
35 */
36
37 // 21.3.7.3 operator!=
38 /*
39 template<class charT, class traits, class Allocator>
40 bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
41 const basic_string<charT,traits,Allocator>& rhs);
42
43 template<class charT, class traits, class Allocator>
44 bool operator!=(const charT* lhs,
45 const basic_string<charT,traits,Allocator>& rhs);
46
47 template<class charT, class traits, class Allocator>
48 bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
49 const charT* rhs);
50 */
51
52 // 21.3.7.4 operator<
53 /*
54 template<class charT, class traits, class Allocator>
55 bool operator< (const basic_string<charT,traits,Allocator>& lhs,
56 const basic_string<charT,traits,Allocator>& rhs);
57
58 template<class charT, class traits, class Allocator>
59 bool operator< (const basic_string<charT,traits,Allocator>& lhs,
60 const charT* rhs);
61
62 template<class charT, class traits, class Allocator>
63 bool operator< (const charT* lhs,
64 const basic_string<charT,traits,Allocator>& rhs);
65 */
66
67 // 21.3.7.5 operator>
68 /*
69 template<class charT, class traits, class Allocator>
70 bool operator> (const basic_string<charT,traits,Allocator>& lhs,
71 const basic_string<charT,traits,Allocator>& rhs);
72
73 template<class charT, class traits, class Allocator>
74 bool operator> (const basic_string<charT,traits,Allocator>& lhs,
75 const charT* rhs);
76
77 template<class charT, class traits, class Allocator>
78 bool operator> (const charT* lhs,
79 const basic_string<charT,traits,Allocator>& rhs);
80 */
81
82 //21.3.7.6 operator<=
83 /*
84 template<class charT, class traits, class Allocator>
85 bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
86 const basic_string<charT,traits,Allocator>& rhs);
87
88 template<class charT, class traits, class Allocator>
89 bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
90 const charT* rhs);
91
92 template<class charT, class traits, class Allocator>
93 bool operator<=(const charT* lhs,
94 const basic_string<charT,traits,Allocator>& rhs);
95 */
96
97 // 21.3.7.7 operator>=
98 /*
99 template<class charT, class traits, class Allocator>
100 bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
101 const basic_string<charT,traits,Allocator>& rhs);
102
103 template<class charT, class traits, class Allocator>
104 bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
105 const charT* rhs);
106
107 template<class charT, class traits, class Allocator>
108 bool operator>=(const charT* lhs,
109 const basic_string<charT,traits,Allocator>& rhs);
110 */
111
112 #include <string>
113 #include <testsuite_hooks.h>
114
115 int test01(void)
116 {
117 bool test __attribute__((unused)) = true;
118 std::wstring str_0(L"costa rica");
119 std::wstring str_1(L"costa marbella");
120 std::wstring str_2(L"cost");
121 std::wstring str_3(L"costa ricans");
122 std::wstring str_4;
123
124 str_4 = str_0;
125 //comparisons between string objects
126 VERIFY( !(str_0 == str_1) );
127 VERIFY( !(str_0 == str_2) );
128 VERIFY( !(str_0 == str_3) );
129 VERIFY( !(str_1 == str_0) );
130 VERIFY( !(str_2 == str_0) );
131 VERIFY( !(str_3 == str_0) );
132 VERIFY( str_4 == str_0 );
133 VERIFY( str_0 == str_4 );
134
135 VERIFY( str_0 != str_1 );
136 VERIFY( str_0 != str_2 );
137 VERIFY( str_0 != str_3 );
138 VERIFY( str_1 != str_0 );
139 VERIFY( str_2 != str_0 );
140 VERIFY( str_3 != str_0 );
141 VERIFY( !(str_0 != str_4) );
142 VERIFY( !(str_4 != str_0) );
143
144 VERIFY( str_0 > str_1 ); //true cuz r>m
145 VERIFY( str_0 > str_2 );
146 VERIFY( !(str_0 > str_3) );
147 VERIFY( !(str_1 > str_0) ); //false cuz m<r
148 VERIFY( !(str_2 > str_0) );
149 VERIFY( str_3 > str_0 );
150 VERIFY( !(str_0 > str_4) );
151 VERIFY( !(str_4 > str_0) );
152
153 VERIFY( !(str_0 < str_1) ); //false cuz r>m
154 VERIFY( !(str_0 < str_2) );
155 VERIFY( str_0 < str_3 );
156 VERIFY( str_1 < str_0 ); //true cuz m<r
157 VERIFY( str_2 < str_0 );
158 VERIFY( !(str_3 < str_0) );
159 VERIFY( !(str_0 < str_4) );
160 VERIFY( !(str_4 < str_0) );
161
162 VERIFY( str_0 >= str_1 ); //true cuz r>m
163 VERIFY( str_0 >= str_2 );
164 VERIFY( !(str_0 >= str_3) );
165 VERIFY( !(str_1 >= str_0) );//false cuz m<r
166 VERIFY( !(str_2 >= str_0) );
167 VERIFY( str_3 >= str_0 );
168 VERIFY( str_0 >= str_4 );
169 VERIFY( str_4 >= str_0 );
170
171 VERIFY( !(str_0 <= str_1) );//false cuz r>m
172 VERIFY( !(str_0 <= str_2) );
173 VERIFY( str_0 <= str_3 );
174 VERIFY( str_1 <= str_0 );//true cuz m<r
175 VERIFY( str_2 <= str_0 );
176 VERIFY( !(str_3 <= str_0) );
177 VERIFY( str_0 <= str_4 );
178 VERIFY( str_4 <= str_0 );
179
180 //comparisons between string object and string literal
181 VERIFY( !(str_0 == L"costa marbella") );
182 VERIFY( !(str_0 == L"cost") );
183 VERIFY( !(str_0 == L"costa ricans") );
184 VERIFY( !(L"costa marbella" == str_0) );
185 VERIFY( !(L"cost" == str_0) );
186 VERIFY( !(L"costa ricans" == str_0) );
187 VERIFY( L"costa rica" == str_0 );
188 VERIFY( str_0 == L"costa rica" );
189
190 VERIFY( str_0 != L"costa marbella" );
191 VERIFY( str_0 != L"cost" );
192 VERIFY( str_0 != L"costa ricans" );
193 VERIFY( L"costa marbella" != str_0 );
194 VERIFY( L"cost" != str_0 );
195 VERIFY( L"costa ricans" != str_0 );
196 VERIFY( !(L"costa rica" != str_0) );
197 VERIFY( !(str_0 != L"costa rica") );
198
199 VERIFY( str_0 > L"costa marbella" ); //true cuz r>m
200 VERIFY( str_0 > L"cost" );
201 VERIFY( !(str_0 > L"costa ricans") );
202 VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r
203 VERIFY( !(L"cost" > str_0) );
204 VERIFY( L"costa ricans" > str_0 );
205 VERIFY( !(L"costa rica" > str_0) );
206 VERIFY( !(str_0 > L"costa rica") );
207
208 VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m
209 VERIFY( !(str_0 < L"cost") );
210 VERIFY( str_0 < L"costa ricans" );
211 VERIFY( L"costa marbella" < str_0 );//true cuz m<r
212 VERIFY( L"cost" < str_0 );
213 VERIFY( !(L"costa ricans" < str_0) );
214 VERIFY( !(L"costa rica" < str_0) );
215 VERIFY( !(str_0 < L"costa rica") );
216
217 VERIFY( str_0 >= L"costa marbella" );//true cuz r>m
218 VERIFY( str_0 >= L"cost" );
219 VERIFY( !(str_0 >= L"costa ricans") );
220 VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r
221 VERIFY( !(L"cost" >= str_0) );
222 VERIFY( L"costa ricans" >= str_0 );
223 VERIFY( L"costa rica" >= str_0 );
224 VERIFY( str_0 >= L"costa rica" );
225
226 VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m
227 VERIFY( !(str_0 <= L"cost") );
228 VERIFY( str_0 <= L"costa ricans" );
229 VERIFY( L"costa marbella" <= str_0 );//true cuz m<r
230 VERIFY( L"cost" <= str_0 );
231 VERIFY( !(L"costa ricans" <= str_0) );
232 VERIFY( L"costa rica" <= str_0 );
233 VERIFY( str_0 <= L"costa rica" );
234
235 // 21.3.7.1 operator+
236 /*
237 template<class charT, class traits, class Allocator>
238 basic_string<charT,traits,Allocator>
239 operator+(const basic_string<charT,traits,Allocator>& lhs,
240 const basic_string<charT,traits,Allocator>& rhs);
241
242 template<class charT, class traits, class Allocator>
243 basic_string<charT,traits,Allocator>
244 operator+(const charT* lhs,
245 const basic_string<charT,traits,Allocator>& rhs);
246
247 template<class charT, class traits, class Allocator>
248 basic_string<charT,traits,Allocator>
249 operator+(const basic_string<charT,traits,Allocator>& lhs,
250 const charT* rhs);
251
252 template<class charT, class traits, class Allocator>
253 basic_string<charT,traits,Allocator>
254 operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
255
256 template<class charT, class traits, class Allocator>
257 basic_string<charT,traits,Allocator>
258 operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
259 */
260
261 str_4 = str_0 + L"ns";
262 VERIFY( str_4 == str_3 );
263
264 const std::wstring str_5(L" marbella");
265 str_4 = L"costa" + str_5;
266 VERIFY( str_4 == str_1 );
267
268 std::wstring str_6(L"ns");
269 str_4 = str_0 + str_6;
270 VERIFY( str_4 == str_3 );
271
272 str_4 = str_0 + L'n';
273 str_4 = str_4 + L's';
274 VERIFY( str_4 == str_3 );
275
276 str_4 = L'a' + str_6;
277 str_4 = L'c' + str_4;
278 str_4 = L'i' + str_4;
279 str_4 = L'r' + str_4;
280 str_4 = L' ' + str_4;
281 str_4 = L'a' + str_4;
282 str_4 = L't' + str_4;
283 str_4 = L's' + str_4;
284 str_4 = L'o' + str_4;
285 str_4 = L'c' + str_4;
286 VERIFY( str_4 == str_3 );
287 return 0;
288 }
289
290 int main()
291 {
292 test01();
293 return 0;
294 }