OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [testsuite/] [21_strings/] [basic_string/] [operators/] [wchar_t/] [2.cc] - Blame information for rev 19

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.