1 // { dg-options "-std=gnu++14" }
3 // Copyright (C) 2013-2014 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 // basic_string non-member functions
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,
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);
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);
112 #include <experimental/string_view>
113 #include <testsuite_hooks.h>
118 bool test
[[gnu::unused
]] = true;
120 std::experimental::string_view
str_0("costa rica");
121 std::experimental::string_view
str_1("costa marbella");
122 std::experimental::string_view
str_2("cost");
123 std::experimental::string_view
str_3("costa ricans");
124 std::experimental::string_view str_4
;
127 //comparisons between string objects
128 VERIFY( !(str_0
== str_1
) );
129 VERIFY( !(str_0
== str_2
) );
130 VERIFY( !(str_0
== str_3
) );
131 VERIFY( !(str_1
== str_0
) );
132 VERIFY( !(str_2
== str_0
) );
133 VERIFY( !(str_3
== str_0
) );
134 VERIFY( str_4
== str_0
);
135 VERIFY( str_0
== str_4
);
137 VERIFY( str_0
!= str_1
);
138 VERIFY( str_0
!= str_2
);
139 VERIFY( str_0
!= str_3
);
140 VERIFY( str_1
!= str_0
);
141 VERIFY( str_2
!= str_0
);
142 VERIFY( str_3
!= str_0
);
143 VERIFY( !(str_0
!= str_4
) );
144 VERIFY( !(str_4
!= str_0
) );
146 VERIFY( str_0
> str_1
); //true cuz r>m
147 VERIFY( str_0
> str_2
);
148 VERIFY( !(str_0
> str_3
) );
149 VERIFY( !(str_1
> str_0
) ); //false cuz m<r
150 VERIFY( !(str_2
> str_0
) );
151 VERIFY( str_3
> str_0
);
152 VERIFY( !(str_0
> str_4
) );
153 VERIFY( !(str_4
> str_0
) );
155 VERIFY( !(str_0
< str_1
) ); //false cuz r>m
156 VERIFY( !(str_0
< str_2
) );
157 VERIFY( str_0
< str_3
);
158 VERIFY( str_1
< str_0
); //true cuz m<r
159 VERIFY( str_2
< str_0
);
160 VERIFY( !(str_3
< str_0
) );
161 VERIFY( !(str_0
< str_4
) );
162 VERIFY( !(str_4
< str_0
) );
164 VERIFY( str_0
>= str_1
); //true cuz r>m
165 VERIFY( str_0
>= str_2
);
166 VERIFY( !(str_0
>= str_3
) );
167 VERIFY( !(str_1
>= str_0
) );//false cuz m<r
168 VERIFY( !(str_2
>= str_0
) );
169 VERIFY( str_3
>= str_0
);
170 VERIFY( str_0
>= str_4
);
171 VERIFY( str_4
>= str_0
);
173 VERIFY( !(str_0
<= str_1
) );//false cuz r>m
174 VERIFY( !(str_0
<= str_2
) );
175 VERIFY( str_0
<= str_3
);
176 VERIFY( str_1
<= str_0
);//true cuz m<r
177 VERIFY( str_2
<= str_0
);
178 VERIFY( !(str_3
<= str_0
) );
179 VERIFY( str_0
<= str_4
);
180 VERIFY( str_4
<= str_0
);
182 //comparisons between string object and string literal
183 VERIFY( !(str_0
== "costa marbella") );
184 VERIFY( !(str_0
== "cost") );
185 VERIFY( !(str_0
== "costa ricans") );
186 VERIFY( !("costa marbella" == str_0
) );
187 VERIFY( !("cost" == str_0
) );
188 VERIFY( !("costa ricans" == str_0
) );
189 VERIFY( "costa rica" == str_0
);
190 VERIFY( str_0
== "costa rica" );
192 VERIFY( str_0
!= "costa marbella" );
193 VERIFY( str_0
!= "cost" );
194 VERIFY( str_0
!= "costa ricans" );
195 VERIFY( "costa marbella" != str_0
);
196 VERIFY( "cost" != str_0
);
197 VERIFY( "costa ricans" != str_0
);
198 VERIFY( !("costa rica" != str_0
) );
199 VERIFY( !(str_0
!= "costa rica") );
201 VERIFY( str_0
> "costa marbella" ); //true cuz r>m
202 VERIFY( str_0
> "cost" );
203 VERIFY( !(str_0
> "costa ricans") );
204 VERIFY( !("costa marbella" > str_0
) );//false cuz m<r
205 VERIFY( !("cost" > str_0
) );
206 VERIFY( "costa ricans" > str_0
);
207 VERIFY( !("costa rica" > str_0
) );
208 VERIFY( !(str_0
> "costa rica") );
210 VERIFY( !(str_0
< "costa marbella") );//false cuz r>m
211 VERIFY( !(str_0
< "cost") );
212 VERIFY( str_0
< "costa ricans" );
213 VERIFY( "costa marbella" < str_0
);//true cuz m<r
214 VERIFY( "cost" < str_0
);
215 VERIFY( !("costa ricans" < str_0
) );
216 VERIFY( !("costa rica" < str_0
) );
217 VERIFY( !(str_0
< "costa rica") );
219 VERIFY( str_0
>= "costa marbella" );//true cuz r>m
220 VERIFY( str_0
>= "cost" );
221 VERIFY( !(str_0
>= "costa ricans") );
222 VERIFY( !("costa marbella" >= str_0
) );//false cuz m<r
223 VERIFY( !("cost" >= str_0
) );
224 VERIFY( "costa ricans" >= str_0
);
225 VERIFY( "costa rica" >= str_0
);
226 VERIFY( str_0
>= "costa rica" );
228 VERIFY( !(str_0
<= "costa marbella") );//false cuz r>m
229 VERIFY( !(str_0
<= "cost") );
230 VERIFY( str_0
<= "costa ricans" );
231 VERIFY( "costa marbella" <= str_0
);//true cuz m<r
232 VERIFY( "cost" <= str_0
);
233 VERIFY( !("costa ricans" <= str_0
) );
234 VERIFY( "costa rica" <= str_0
);
235 VERIFY( str_0
<= "costa rica" );