]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/21_strings/basic_string/operators/wchar_t/2.cc
1 // 1998-10-01, 1999-06-25 bkoz
3 // Copyright (C) 1998-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.7.1 basic_string non-member functions
22 // 21.3.7.2 operator==
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);
28 template<class charT, class traits, class Allocator>
29 bool operator==(const charT* lhs,
30 const basic_string<charT,traits,Allocator>& rhs);
32 template<class charT, class traits, class Allocator>
33 bool operator==(const basic_string<charT,traits,Allocator>& lhs,
37 // 21.3.7.3 operator!=
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);
43 template<class charT, class traits, class Allocator>
44 bool operator!=(const charT* lhs,
45 const basic_string<charT,traits,Allocator>& rhs);
47 template<class charT, class traits, class Allocator>
48 bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
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);
58 template<class charT, class traits, class Allocator>
59 bool operator< (const basic_string<charT,traits,Allocator>& lhs,
62 template<class charT, class traits, class Allocator>
63 bool operator< (const charT* lhs,
64 const basic_string<charT,traits,Allocator>& rhs);
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);
73 template<class charT, class traits, class Allocator>
74 bool operator> (const basic_string<charT,traits,Allocator>& lhs,
77 template<class charT, class traits, class Allocator>
78 bool operator> (const charT* lhs,
79 const basic_string<charT,traits,Allocator>& rhs);
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);
88 template<class charT, class traits, class Allocator>
89 bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
92 template<class charT, class traits, class Allocator>
93 bool operator<=(const charT* lhs,
94 const basic_string<charT,traits,Allocator>& rhs);
97 // 21.3.7.7 operator>=
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);
103 template<class charT, class traits, class Allocator>
104 bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
107 template<class charT, class traits, class Allocator>
108 bool operator>=(const charT* lhs,
109 const basic_string<charT,traits,Allocator>& rhs);
113 #include <testsuite_hooks.h>
117 std::wstring
str_0(L
"costa rica");
118 std::wstring
str_1(L
"costa marbella");
119 std::wstring
str_2(L
"cost");
120 std::wstring
str_3(L
"costa ricans");
124 //comparisons between string objects
125 VERIFY( !(str_0
== str_1
) );
126 VERIFY( !(str_0
== str_2
) );
127 VERIFY( !(str_0
== str_3
) );
128 VERIFY( !(str_1
== str_0
) );
129 VERIFY( !(str_2
== str_0
) );
130 VERIFY( !(str_3
== str_0
) );
131 VERIFY( str_4
== str_0
);
132 VERIFY( str_0
== str_4
);
134 VERIFY( str_0
!= str_1
);
135 VERIFY( str_0
!= str_2
);
136 VERIFY( str_0
!= str_3
);
137 VERIFY( str_1
!= str_0
);
138 VERIFY( str_2
!= str_0
);
139 VERIFY( str_3
!= str_0
);
140 VERIFY( !(str_0
!= str_4
) );
141 VERIFY( !(str_4
!= str_0
) );
143 VERIFY( str_0
> str_1
); //true cuz r>m
144 VERIFY( str_0
> str_2
);
145 VERIFY( !(str_0
> str_3
) );
146 VERIFY( !(str_1
> str_0
) ); //false cuz m<r
147 VERIFY( !(str_2
> str_0
) );
148 VERIFY( str_3
> str_0
);
149 VERIFY( !(str_0
> str_4
) );
150 VERIFY( !(str_4
> str_0
) );
152 VERIFY( !(str_0
< str_1
) ); //false cuz r>m
153 VERIFY( !(str_0
< str_2
) );
154 VERIFY( str_0
< str_3
);
155 VERIFY( str_1
< str_0
); //true cuz m<r
156 VERIFY( str_2
< str_0
);
157 VERIFY( !(str_3
< str_0
) );
158 VERIFY( !(str_0
< str_4
) );
159 VERIFY( !(str_4
< str_0
) );
161 VERIFY( str_0
>= str_1
); //true cuz r>m
162 VERIFY( str_0
>= str_2
);
163 VERIFY( !(str_0
>= str_3
) );
164 VERIFY( !(str_1
>= str_0
) );//false cuz m<r
165 VERIFY( !(str_2
>= str_0
) );
166 VERIFY( str_3
>= str_0
);
167 VERIFY( str_0
>= str_4
);
168 VERIFY( str_4
>= str_0
);
170 VERIFY( !(str_0
<= str_1
) );//false cuz r>m
171 VERIFY( !(str_0
<= str_2
) );
172 VERIFY( str_0
<= str_3
);
173 VERIFY( str_1
<= str_0
);//true cuz m<r
174 VERIFY( str_2
<= str_0
);
175 VERIFY( !(str_3
<= str_0
) );
176 VERIFY( str_0
<= str_4
);
177 VERIFY( str_4
<= str_0
);
179 //comparisons between string object and string literal
180 VERIFY( !(str_0
== L
"costa marbella") );
181 VERIFY( !(str_0
== L
"cost") );
182 VERIFY( !(str_0
== L
"costa ricans") );
183 VERIFY( !(L
"costa marbella" == str_0
) );
184 VERIFY( !(L
"cost" == str_0
) );
185 VERIFY( !(L
"costa ricans" == str_0
) );
186 VERIFY( L
"costa rica" == str_0
);
187 VERIFY( str_0
== L
"costa rica" );
189 VERIFY( str_0
!= L
"costa marbella" );
190 VERIFY( str_0
!= L
"cost" );
191 VERIFY( str_0
!= L
"costa ricans" );
192 VERIFY( L
"costa marbella" != str_0
);
193 VERIFY( L
"cost" != str_0
);
194 VERIFY( L
"costa ricans" != str_0
);
195 VERIFY( !(L
"costa rica" != str_0
) );
196 VERIFY( !(str_0
!= L
"costa rica") );
198 VERIFY( str_0
> L
"costa marbella" ); //true cuz r>m
199 VERIFY( str_0
> L
"cost" );
200 VERIFY( !(str_0
> L
"costa ricans") );
201 VERIFY( !(L
"costa marbella" > str_0
) );//false cuz m<r
202 VERIFY( !(L
"cost" > str_0
) );
203 VERIFY( L
"costa ricans" > str_0
);
204 VERIFY( !(L
"costa rica" > str_0
) );
205 VERIFY( !(str_0
> L
"costa rica") );
207 VERIFY( !(str_0
< L
"costa marbella") );//false cuz r>m
208 VERIFY( !(str_0
< L
"cost") );
209 VERIFY( str_0
< L
"costa ricans" );
210 VERIFY( L
"costa marbella" < str_0
);//true cuz m<r
211 VERIFY( L
"cost" < str_0
);
212 VERIFY( !(L
"costa ricans" < str_0
) );
213 VERIFY( !(L
"costa rica" < str_0
) );
214 VERIFY( !(str_0
< L
"costa rica") );
216 VERIFY( str_0
>= L
"costa marbella" );//true cuz r>m
217 VERIFY( str_0
>= L
"cost" );
218 VERIFY( !(str_0
>= L
"costa ricans") );
219 VERIFY( !(L
"costa marbella" >= str_0
) );//false cuz m<r
220 VERIFY( !(L
"cost" >= str_0
) );
221 VERIFY( L
"costa ricans" >= str_0
);
222 VERIFY( L
"costa rica" >= str_0
);
223 VERIFY( str_0
>= L
"costa rica" );
225 VERIFY( !(str_0
<= L
"costa marbella") );//false cuz r>m
226 VERIFY( !(str_0
<= L
"cost") );
227 VERIFY( str_0
<= L
"costa ricans" );
228 VERIFY( L
"costa marbella" <= str_0
);//true cuz m<r
229 VERIFY( L
"cost" <= str_0
);
230 VERIFY( !(L
"costa ricans" <= str_0
) );
231 VERIFY( L
"costa rica" <= str_0
);
232 VERIFY( str_0
<= L
"costa rica" );
234 // 21.3.7.1 operator+
236 template<class charT, class traits, class Allocator>
237 basic_string<charT,traits,Allocator>
238 operator+(const basic_string<charT,traits,Allocator>& lhs,
239 const basic_string<charT,traits,Allocator>& rhs);
241 template<class charT, class traits, class Allocator>
242 basic_string<charT,traits,Allocator>
243 operator+(const charT* lhs,
244 const basic_string<charT,traits,Allocator>& rhs);
246 template<class charT, class traits, class Allocator>
247 basic_string<charT,traits,Allocator>
248 operator+(const basic_string<charT,traits,Allocator>& lhs,
251 template<class charT, class traits, class Allocator>
252 basic_string<charT,traits,Allocator>
253 operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
255 template<class charT, class traits, class Allocator>
256 basic_string<charT,traits,Allocator>
257 operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
260 str_4
= str_0
+ L
"ns";
261 VERIFY( str_4
== str_3
);
263 const std::wstring
str_5(L
" marbella");
264 str_4
= L
"costa" + str_5
;
265 VERIFY( str_4
== str_1
);
267 std::wstring
str_6(L
"ns");
268 str_4
= str_0
+ str_6
;
269 VERIFY( str_4
== str_3
);
271 str_4
= str_0
+ L
'n';
272 str_4
= str_4
+ L
's';
273 VERIFY( str_4
== str_3
);
275 str_4
= L
'a' + str_6
;
276 str_4
= L
'c' + str_4
;
277 str_4
= L
'i' + str_4
;
278 str_4
= L
'r' + str_4
;
279 str_4
= L
' ' + str_4
;
280 str_4
= L
'a' + str_4
;
281 str_4
= L
't' + str_4
;
282 str_4
= L
's' + str_4
;
283 str_4
= L
'o' + str_4
;
284 str_4
= L
'c' + str_4
;
285 VERIFY( str_4
== str_3
);