]>
Commit | Line | Data |
---|---|---|
c9f78968 VS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: tests/strings/unichar.cpp | |
3 | // Purpose: Test for wxUniChar class | |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2007-03-11 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2007 REA Elektronik GmbH | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // ---------------------------------------------------------------------------- | |
12 | // headers | |
13 | // ---------------------------------------------------------------------------- | |
14 | ||
15 | #include "testprec.h" | |
16 | ||
17 | #ifdef __BORLANDC__ | |
18 | #pragma hdrstop | |
19 | #endif | |
20 | ||
21 | #ifndef WX_PRECOMP | |
22 | #include "wx/wx.h" | |
23 | #endif // WX_PRECOMP | |
24 | ||
25 | #include "wx/string.h" | |
26 | ||
27 | // ---------------------------------------------------------------------------- | |
28 | // test class | |
29 | // ---------------------------------------------------------------------------- | |
30 | ||
31 | class UniCharTestCase : public CppUnit::TestCase | |
32 | { | |
33 | public: | |
34 | UniCharTestCase() {} | |
35 | ||
36 | private: | |
37 | CPPUNIT_TEST_SUITE( UniCharTestCase ); | |
38 | CPPUNIT_TEST( CharCompare ); | |
39 | CPPUNIT_TEST( CharCompareIntl ); | |
40 | CPPUNIT_TEST( StringCompare ); | |
622bc15f VZ |
41 | CPPUNIT_TEST( ShortCompare ); |
42 | CPPUNIT_TEST( UnsignedShortCompare ); | |
43 | CPPUNIT_TEST( IntCompare ); | |
44 | CPPUNIT_TEST( UnsignedIntCompare ); | |
45 | CPPUNIT_TEST( LongCompare ); | |
46 | CPPUNIT_TEST( UnsignedLongCompare ); | |
47 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongCompare ); ) | |
48 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongCompare ); ) | |
49 | wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharCompare ); ) | |
50 | CPPUNIT_TEST( UniCharAssignmentOperator ); | |
51 | CPPUNIT_TEST( UniCharRefAssignmentOperator ); | |
52 | CPPUNIT_TEST( CharAssignmentOperator ); | |
53 | CPPUNIT_TEST( UnsignedCharAssignmentOperator ); | |
54 | CPPUNIT_TEST( ShortAssignmentOperator ); | |
55 | CPPUNIT_TEST( UnsignedShortAssignmentOperator ); | |
56 | CPPUNIT_TEST( IntAssignmentOperator ); | |
57 | CPPUNIT_TEST( UnsignedIntAssignmentOperator ); | |
58 | CPPUNIT_TEST( LongAssignmentOperator ); | |
59 | CPPUNIT_TEST( UnsignedLongAssignmentOperator ); | |
60 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongAssignmentOperator ); ) | |
61 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongAssignmentOperator ); ) | |
62 | wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharAssignmentOperator ); ) | |
63 | CPPUNIT_TEST( CharParenOperator ); | |
64 | CPPUNIT_TEST( UnsignedCharParenOperator ); | |
65 | CPPUNIT_TEST( ShortParenOperator ); | |
66 | CPPUNIT_TEST( UnsignedShortParenOperator ); | |
67 | CPPUNIT_TEST( IntParenOperator ); | |
68 | CPPUNIT_TEST( UnsignedIntParenOperator ); | |
69 | CPPUNIT_TEST( LongParenOperator ); | |
70 | CPPUNIT_TEST( UnsignedLongParenOperator ); | |
71 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongParenOperator ); ) | |
72 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongParenOperator ); ) | |
73 | wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharParenOperator ); ) | |
74 | CPPUNIT_TEST(RefUniCharAssignmentOperator); | |
75 | CPPUNIT_TEST(RefUniCharRefAssignmentOperator); | |
76 | CPPUNIT_TEST(RefCharAssignmentOperator); | |
77 | CPPUNIT_TEST( RefShortAssignmentOperator ); | |
78 | CPPUNIT_TEST( RefUnsignedShortAssignmentOperator ); | |
79 | CPPUNIT_TEST( RefIntAssignmentOperator ); | |
80 | CPPUNIT_TEST( RefUnsignedIntAssignmentOperator ); | |
81 | CPPUNIT_TEST( RefLongAssignmentOperator ); | |
82 | CPPUNIT_TEST( RefUnsignedLongAssignmentOperator ); | |
83 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongAssignmentOperator ); ) | |
84 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongAssignmentOperator ); ) | |
85 | wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharAssignmentOperator ); ) | |
86 | CPPUNIT_TEST(RefCharParenOperator); | |
87 | CPPUNIT_TEST( RefShortParenOperator ); | |
88 | CPPUNIT_TEST( RefUnsignedShortParenOperator ); | |
89 | CPPUNIT_TEST( RefIntParenOperator ); | |
90 | CPPUNIT_TEST( RefUnsignedIntParenOperator ); | |
91 | CPPUNIT_TEST( RefLongParenOperator ); | |
92 | CPPUNIT_TEST( RefUnsignedLongParenOperator ); | |
93 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongParenOperator ); ) | |
94 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongParenOperator ); ) | |
95 | wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharParenOperator ); ) | |
96 | CPPUNIT_TEST( RefShortCompare ); | |
97 | CPPUNIT_TEST( RefUnsignedShortCompare ); | |
98 | CPPUNIT_TEST( RefIntCompare ); | |
99 | CPPUNIT_TEST( RefUnsignedIntCompare ); | |
100 | CPPUNIT_TEST( RefLongCompare ); | |
101 | CPPUNIT_TEST( RefUnsignedLongCompare ); | |
102 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongCompare ); ) | |
103 | wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongCompare ); ) | |
104 | wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharCompare ); ) | |
87f528f1 | 105 | #if wxUSE_UNICODE |
c9f78968 | 106 | CPPUNIT_TEST( StringCompareIntl ); |
87f528f1 | 107 | #endif // wxUSE_UNICODE |
c9f78968 VS |
108 | CPPUNIT_TEST_SUITE_END(); |
109 | ||
110 | void CharCompare(); | |
111 | void CharCompareIntl(); | |
112 | void StringCompare(); | |
113 | void StringCompareIntl(); | |
622bc15f VZ |
114 | void ShortCompare(); |
115 | void UnsignedShortCompare(); | |
116 | void IntCompare(); | |
117 | void UnsignedIntCompare(); | |
118 | void LongCompare(); | |
119 | void UnsignedLongCompare(); | |
120 | wxIF_LONG_LONG_TYPE( void wxLongLongCompare(); ) | |
121 | wxIF_LONG_LONG_TYPE( void wxULongLongCompare(); ) | |
122 | wxIF_WCHAR_T_TYPE( void WideCharCompare(); ) | |
123 | void UniCharAssignmentOperator(); | |
124 | void UniCharRefAssignmentOperator(); | |
125 | void CharAssignmentOperator(); | |
126 | void UnsignedCharAssignmentOperator(); | |
127 | void ShortAssignmentOperator(); | |
128 | void UnsignedShortAssignmentOperator(); | |
129 | void IntAssignmentOperator(); | |
130 | void UnsignedIntAssignmentOperator(); | |
131 | void LongAssignmentOperator(); | |
132 | void UnsignedLongAssignmentOperator(); | |
133 | wxIF_LONG_LONG_TYPE( void wxLongLongAssignmentOperator(); ) | |
134 | wxIF_LONG_LONG_TYPE( void wxULongLongAssignmentOperator(); ) | |
135 | wxIF_WCHAR_T_TYPE( void WideCharAssignmentOperator(); ) | |
136 | void CharParenOperator(); | |
137 | void UnsignedCharParenOperator(); | |
138 | void ShortParenOperator(); | |
139 | void UnsignedShortParenOperator(); | |
140 | void IntParenOperator(); | |
141 | void UnsignedIntParenOperator(); | |
142 | void LongParenOperator(); | |
143 | void UnsignedLongParenOperator(); | |
144 | wxIF_LONG_LONG_TYPE( void wxLongLongParenOperator(); ) | |
145 | wxIF_LONG_LONG_TYPE( void wxULongLongParenOperator(); ) | |
146 | wxIF_WCHAR_T_TYPE( void WideCharParenOperator(); ) | |
147 | void RefUniCharAssignmentOperator(); | |
148 | void RefUniCharRefAssignmentOperator(); | |
149 | void RefCharAssignmentOperator(); | |
150 | void RefUnsignedCharAssignmentOperator(); | |
151 | void RefShortAssignmentOperator(); | |
152 | void RefUnsignedShortAssignmentOperator(); | |
153 | void RefIntAssignmentOperator(); | |
154 | void RefUnsignedIntAssignmentOperator(); | |
155 | void RefLongAssignmentOperator(); | |
156 | void RefUnsignedLongAssignmentOperator(); | |
157 | wxIF_LONG_LONG_TYPE( void RefwxLongLongAssignmentOperator(); ) | |
158 | wxIF_LONG_LONG_TYPE( void RefwxULongLongAssignmentOperator(); ) | |
159 | wxIF_WCHAR_T_TYPE( void RefWideCharAssignmentOperator(); ) | |
160 | void RefCharParenOperator(); | |
161 | void RefUnsignedCharParenOperator(); | |
162 | void RefShortParenOperator(); | |
163 | void RefUnsignedShortParenOperator(); | |
164 | void RefIntParenOperator(); | |
165 | void RefUnsignedIntParenOperator(); | |
166 | void RefLongParenOperator(); | |
167 | void RefUnsignedLongParenOperator(); | |
168 | wxIF_LONG_LONG_TYPE( void RefwxLongLongParenOperator(); ) | |
169 | wxIF_LONG_LONG_TYPE( void RefwxULongLongParenOperator(); ) | |
170 | wxIF_WCHAR_T_TYPE( void RefWideCharParenOperator(); ) | |
171 | void RefShortCompare(); | |
172 | void RefUnsignedShortCompare(); | |
173 | void RefIntCompare(); | |
174 | void RefUnsignedIntCompare(); | |
175 | void RefLongCompare(); | |
176 | void RefUnsignedLongCompare(); | |
177 | wxIF_LONG_LONG_TYPE( void RefwxLongLongCompare(); ) | |
178 | wxIF_LONG_LONG_TYPE( void RefwxULongLongCompare(); ) | |
179 | wxIF_WCHAR_T_TYPE( void RefWideCharCompare(); ) | |
c9f78968 VS |
180 | |
181 | DECLARE_NO_COPY_CLASS(UniCharTestCase) | |
182 | }; | |
183 | ||
184 | // register in the unnamed registry so that these tests are run by default | |
185 | CPPUNIT_TEST_SUITE_REGISTRATION( UniCharTestCase ); | |
186 | ||
e3778b4d | 187 | // also include in its own registry so that these tests can be run alone |
c9f78968 VS |
188 | CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UniCharTestCase, "UniCharTestCase" ); |
189 | ||
190 | void UniCharTestCase::CharCompare() | |
191 | { | |
192 | wxUniChar a('a'); | |
193 | wxUniChar b('b'); | |
194 | ||
195 | CPPUNIT_ASSERT( a == a ); | |
196 | CPPUNIT_ASSERT( a == 'a' ); | |
9a83f860 | 197 | CPPUNIT_ASSERT( a == wxT('a') ); |
c9f78968 | 198 | CPPUNIT_ASSERT( a == wxUniChar('a') ); |
9a83f860 | 199 | CPPUNIT_ASSERT( a == wxUniChar(wxT('a')) ); |
c9f78968 | 200 | |
6d93e28a VZ |
201 | CPPUNIT_ASSERT( a == a ); |
202 | CPPUNIT_ASSERT( 'a' == a ); | |
203 | CPPUNIT_ASSERT( wxT('a') == a ); | |
204 | CPPUNIT_ASSERT( wxUniChar('a') == a ); | |
205 | CPPUNIT_ASSERT( wxUniChar(wxT('a')) == a ); | |
206 | ||
c9f78968 VS |
207 | CPPUNIT_ASSERT( a != b ); |
208 | CPPUNIT_ASSERT( a != 'b' ); | |
9a83f860 | 209 | CPPUNIT_ASSERT( a != wxT('b') ); |
c9f78968 | 210 | CPPUNIT_ASSERT( a != wxUniChar('b') ); |
9a83f860 | 211 | CPPUNIT_ASSERT( a != wxUniChar(wxT('b')) ); |
c9f78968 | 212 | |
6d93e28a VZ |
213 | CPPUNIT_ASSERT( b != a ); |
214 | CPPUNIT_ASSERT( 'b' != a ); | |
215 | CPPUNIT_ASSERT( wxT('b') != a ); | |
216 | CPPUNIT_ASSERT( wxUniChar('b') != a ); | |
217 | CPPUNIT_ASSERT( wxUniChar(wxT('b')) != a ); | |
218 | ||
c9f78968 VS |
219 | CPPUNIT_ASSERT( a < b ); |
220 | CPPUNIT_ASSERT( a < 'b' ); | |
9a83f860 | 221 | CPPUNIT_ASSERT( a < wxT('b') ); |
c9f78968 | 222 | CPPUNIT_ASSERT( a < wxUniChar('b') ); |
9a83f860 | 223 | CPPUNIT_ASSERT( a < wxUniChar(wxT('b')) ); |
c9f78968 | 224 | |
6d93e28a VZ |
225 | CPPUNIT_ASSERT( b > a ); |
226 | CPPUNIT_ASSERT( 'b' > a ); | |
227 | CPPUNIT_ASSERT( wxT('b') > a ); | |
228 | CPPUNIT_ASSERT( wxUniChar('b') > a ); | |
229 | CPPUNIT_ASSERT( wxUniChar(wxT('b')) > a ); | |
230 | ||
c9f78968 VS |
231 | CPPUNIT_ASSERT( a <= b ); |
232 | CPPUNIT_ASSERT( a <= 'b' ); | |
9a83f860 | 233 | CPPUNIT_ASSERT( a <= wxT('b') ); |
c9f78968 | 234 | CPPUNIT_ASSERT( a <= wxUniChar('b') ); |
9a83f860 | 235 | CPPUNIT_ASSERT( a <= wxUniChar(wxT('b')) ); |
c9f78968 | 236 | |
6d93e28a VZ |
237 | CPPUNIT_ASSERT( b >= a ); |
238 | CPPUNIT_ASSERT( 'b' >= a ); | |
239 | CPPUNIT_ASSERT( wxT('b') >= a ); | |
240 | CPPUNIT_ASSERT( wxUniChar('b') >= a ); | |
241 | CPPUNIT_ASSERT( wxUniChar(wxT('b')) >= a ); | |
242 | ||
c9f78968 VS |
243 | CPPUNIT_ASSERT( a <= a ); |
244 | CPPUNIT_ASSERT( a <= 'a' ); | |
9a83f860 | 245 | CPPUNIT_ASSERT( a <= wxT('a') ); |
c9f78968 | 246 | CPPUNIT_ASSERT( a <= wxUniChar('a') ); |
9a83f860 | 247 | CPPUNIT_ASSERT( a <= wxUniChar(wxT('a')) ); |
c9f78968 | 248 | |
6d93e28a VZ |
249 | CPPUNIT_ASSERT( a >= a ); |
250 | CPPUNIT_ASSERT( 'a' >= a ); | |
251 | CPPUNIT_ASSERT( wxT('a') >= a ); | |
252 | CPPUNIT_ASSERT( wxUniChar('a') >= a ); | |
253 | CPPUNIT_ASSERT( wxUniChar(wxT('a')) >= a ); | |
254 | ||
c9f78968 VS |
255 | CPPUNIT_ASSERT( b > a ); |
256 | CPPUNIT_ASSERT( b > 'a' ); | |
9a83f860 | 257 | CPPUNIT_ASSERT( b > wxT('a') ); |
c9f78968 | 258 | CPPUNIT_ASSERT( b > wxUniChar('a') ); |
9a83f860 | 259 | CPPUNIT_ASSERT( b > wxUniChar(wxT('a')) ); |
c9f78968 | 260 | |
6d93e28a VZ |
261 | CPPUNIT_ASSERT( a < b ); |
262 | CPPUNIT_ASSERT( 'a' < b ); | |
263 | CPPUNIT_ASSERT( wxT('a') < b ); | |
264 | CPPUNIT_ASSERT( wxUniChar('a') < b ); | |
265 | CPPUNIT_ASSERT( wxUniChar(wxT('a')) < b ); | |
266 | ||
c9f78968 VS |
267 | CPPUNIT_ASSERT( b >= a ); |
268 | CPPUNIT_ASSERT( b >= 'a' ); | |
9a83f860 | 269 | CPPUNIT_ASSERT( b >= wxT('a') ); |
c9f78968 | 270 | CPPUNIT_ASSERT( b >= wxUniChar('a') ); |
9a83f860 | 271 | CPPUNIT_ASSERT( b >= wxUniChar(wxT('a')) ); |
c9f78968 | 272 | |
6d93e28a VZ |
273 | CPPUNIT_ASSERT( a <= b ); |
274 | CPPUNIT_ASSERT( 'a' <= b ); | |
275 | CPPUNIT_ASSERT( wxT('a') <= b ); | |
276 | CPPUNIT_ASSERT( wxUniChar('a') <= b ); | |
277 | CPPUNIT_ASSERT( wxUniChar(wxT('a')) <= b ); | |
278 | ||
c9f78968 VS |
279 | CPPUNIT_ASSERT( b >= b ); |
280 | CPPUNIT_ASSERT( b >= 'b' ); | |
9a83f860 | 281 | CPPUNIT_ASSERT( b >= wxT('b') ); |
c9f78968 | 282 | CPPUNIT_ASSERT( b >= wxUniChar('b') ); |
9a83f860 | 283 | CPPUNIT_ASSERT( b >= wxUniChar(wxT('b')) ); |
c9f78968 | 284 | |
6d93e28a VZ |
285 | CPPUNIT_ASSERT( b <= b ); |
286 | CPPUNIT_ASSERT( 'b' <= b ); | |
287 | CPPUNIT_ASSERT( wxT('b') <= b ); | |
288 | CPPUNIT_ASSERT( wxUniChar('b') <= b ); | |
289 | CPPUNIT_ASSERT( wxUniChar(wxT('b')) <= b ); | |
290 | ||
c9f78968 VS |
291 | CPPUNIT_ASSERT( b - a == 1 ); |
292 | CPPUNIT_ASSERT( a - b == -1 ); | |
293 | } | |
294 | ||
295 | ||
296 | #define CYRILLIC_SMALL_LETTER_YU ((wchar_t)0x044E) | |
297 | #define ARABIC_LETTER_NOON ((wchar_t)0x0646) | |
298 | ||
299 | void UniCharTestCase::CharCompareIntl() | |
300 | { | |
301 | wxUniChar a(CYRILLIC_SMALL_LETTER_YU); | |
302 | wxUniChar b(ARABIC_LETTER_NOON); | |
303 | ||
304 | CPPUNIT_ASSERT( a == a ); | |
305 | CPPUNIT_ASSERT( a == CYRILLIC_SMALL_LETTER_YU ); | |
306 | CPPUNIT_ASSERT( a == wxUniChar(CYRILLIC_SMALL_LETTER_YU) ); | |
307 | ||
308 | CPPUNIT_ASSERT( a != b ); | |
309 | CPPUNIT_ASSERT( a != ARABIC_LETTER_NOON ); | |
310 | CPPUNIT_ASSERT( a != wxUniChar(ARABIC_LETTER_NOON) ); | |
311 | ||
312 | CPPUNIT_ASSERT( a < b ); | |
313 | CPPUNIT_ASSERT( a < ARABIC_LETTER_NOON ); | |
314 | CPPUNIT_ASSERT( a < wxUniChar(ARABIC_LETTER_NOON) ); | |
315 | ||
316 | CPPUNIT_ASSERT( a <= b ); | |
317 | CPPUNIT_ASSERT( a <= ARABIC_LETTER_NOON ); | |
318 | CPPUNIT_ASSERT( a <= wxUniChar(ARABIC_LETTER_NOON) ); | |
319 | ||
320 | CPPUNIT_ASSERT( a <= a ); | |
321 | CPPUNIT_ASSERT( a <= CYRILLIC_SMALL_LETTER_YU ); | |
322 | CPPUNIT_ASSERT( a <= wxUniChar(CYRILLIC_SMALL_LETTER_YU) ); | |
323 | ||
324 | CPPUNIT_ASSERT( b > a ); | |
325 | CPPUNIT_ASSERT( b > CYRILLIC_SMALL_LETTER_YU ); | |
326 | CPPUNIT_ASSERT( b > wxUniChar(CYRILLIC_SMALL_LETTER_YU) ); | |
327 | ||
328 | CPPUNIT_ASSERT( b >= a ); | |
329 | CPPUNIT_ASSERT( b >= CYRILLIC_SMALL_LETTER_YU ); | |
330 | CPPUNIT_ASSERT( b >= wxUniChar(CYRILLIC_SMALL_LETTER_YU) ); | |
331 | ||
332 | CPPUNIT_ASSERT( b >= b ); | |
333 | CPPUNIT_ASSERT( b >= ARABIC_LETTER_NOON ); | |
334 | CPPUNIT_ASSERT( b >= wxUniChar(ARABIC_LETTER_NOON) ); | |
335 | ||
336 | CPPUNIT_ASSERT( b - a == 504 ); | |
337 | CPPUNIT_ASSERT( a - b == -504 ); | |
338 | } | |
339 | ||
340 | void UniCharTestCase::StringCompare() | |
341 | { | |
342 | // test string comparison with chars | |
343 | wxString sa = "a"; | |
344 | const wxString sb = "b"; | |
345 | char c1 = 'a'; | |
9a83f860 | 346 | wchar_t c2 = wxT('a'); |
c9f78968 VS |
347 | wxUniChar c3 = 'a'; |
348 | ||
349 | CPPUNIT_ASSERT( sa == 'a'); | |
350 | CPPUNIT_ASSERT( 'a' == sa); | |
351 | CPPUNIT_ASSERT( sb != 'a'); | |
352 | CPPUNIT_ASSERT( 'a' != sb); | |
353 | ||
354 | CPPUNIT_ASSERT( sa == c1); | |
355 | CPPUNIT_ASSERT( c1 == sa); | |
356 | CPPUNIT_ASSERT( sb != c1); | |
357 | CPPUNIT_ASSERT( c1 != sb); | |
358 | ||
359 | CPPUNIT_ASSERT( sa == c2); | |
360 | CPPUNIT_ASSERT( c2 == sa); | |
361 | CPPUNIT_ASSERT( sb != c2); | |
362 | CPPUNIT_ASSERT( c2 != sb); | |
363 | ||
364 | CPPUNIT_ASSERT( sa == c3); | |
365 | CPPUNIT_ASSERT( c3 == sa); | |
366 | CPPUNIT_ASSERT( sb != c3); | |
367 | CPPUNIT_ASSERT( c3 != sb); | |
368 | ||
369 | // test wxUniCharRef: | |
370 | CPPUNIT_ASSERT( sa == sa[0]); | |
371 | CPPUNIT_ASSERT( sa[0] == sa); | |
372 | CPPUNIT_ASSERT( sb != sa[0]); | |
373 | CPPUNIT_ASSERT( sa[0] != sb); | |
374 | ||
375 | // test const version of operator[] (returns wxUniChar, not wxUniCharRef): | |
376 | CPPUNIT_ASSERT( sb == sb[0]); | |
377 | CPPUNIT_ASSERT( sb[0] == sb); | |
378 | CPPUNIT_ASSERT( sa != sb[0]); | |
379 | CPPUNIT_ASSERT( sb[0] != sa); | |
380 | } | |
381 | ||
87f528f1 | 382 | #if wxUSE_UNICODE |
c9f78968 VS |
383 | void UniCharTestCase::StringCompareIntl() |
384 | { | |
385 | // test string comparison with chars | |
386 | wxString sa = CYRILLIC_SMALL_LETTER_YU; | |
387 | const wxString sb = ARABIC_LETTER_NOON; | |
388 | wchar_t c2 = CYRILLIC_SMALL_LETTER_YU; | |
389 | wxUniChar c3 = CYRILLIC_SMALL_LETTER_YU; | |
390 | ||
391 | CPPUNIT_ASSERT( sa == CYRILLIC_SMALL_LETTER_YU); | |
392 | CPPUNIT_ASSERT( CYRILLIC_SMALL_LETTER_YU == sa); | |
393 | CPPUNIT_ASSERT( sb != CYRILLIC_SMALL_LETTER_YU); | |
394 | CPPUNIT_ASSERT( CYRILLIC_SMALL_LETTER_YU != sb); | |
395 | ||
396 | CPPUNIT_ASSERT( sa == c2); | |
397 | CPPUNIT_ASSERT( c2 == sa); | |
398 | CPPUNIT_ASSERT( sb != c2); | |
399 | CPPUNIT_ASSERT( c2 != sb); | |
400 | ||
401 | CPPUNIT_ASSERT( sa == c3); | |
402 | CPPUNIT_ASSERT( c3 == sa); | |
403 | CPPUNIT_ASSERT( sb != c3); | |
404 | CPPUNIT_ASSERT( c3 != sb); | |
405 | ||
406 | // test wxUniCharRef: | |
407 | CPPUNIT_ASSERT( sa == sa[0]); | |
408 | CPPUNIT_ASSERT( sa[0] == sa); | |
409 | CPPUNIT_ASSERT( sb != sa[0]); | |
410 | CPPUNIT_ASSERT( sa[0] != sb); | |
411 | ||
412 | // test const version of operator[] (returns wxUniChar, not wxUniCharRef): | |
413 | CPPUNIT_ASSERT( sb == sb[0]); | |
414 | CPPUNIT_ASSERT( sb[0] == sb); | |
415 | CPPUNIT_ASSERT( sa != sb[0]); | |
416 | CPPUNIT_ASSERT( sb[0] != sa); | |
417 | } | |
87f528f1 | 418 | #endif // wxUSE_UNICODE |
622bc15f VZ |
419 | |
420 | #define wxUNICHAR_TEST_INT_COMPARE \ | |
421 | wxUniChar a(aVal); \ | |
422 | CPPUNIT_ASSERT( a == aVal ); \ | |
423 | CPPUNIT_ASSERT( a != bVal ); \ | |
424 | CPPUNIT_ASSERT( a < bVal ); \ | |
425 | CPPUNIT_ASSERT( a <= bVal ); \ | |
426 | CPPUNIT_ASSERT( a > cVal ); \ | |
427 | CPPUNIT_ASSERT( a >= cVal ); | |
428 | ||
429 | ||
430 | void UniCharTestCase::ShortCompare() | |
431 | { | |
432 | short aVal = 2; | |
433 | short bVal = 3; | |
434 | short cVal = 1; | |
435 | ||
436 | wxUNICHAR_TEST_INT_COMPARE | |
437 | } | |
438 | ||
439 | void UniCharTestCase::UnsignedShortCompare() | |
440 | { | |
441 | unsigned short aVal = 2; | |
442 | unsigned short bVal = 3; | |
443 | unsigned short cVal = 1; | |
444 | ||
445 | wxUNICHAR_TEST_INT_COMPARE | |
446 | } | |
447 | ||
448 | void UniCharTestCase::IntCompare() | |
449 | { | |
450 | int aVal = 2; | |
451 | int bVal = 3; | |
452 | int cVal = 1; | |
453 | ||
454 | wxUNICHAR_TEST_INT_COMPARE | |
455 | } | |
456 | ||
457 | void UniCharTestCase::UnsignedIntCompare() | |
458 | { | |
459 | unsigned int aVal = 2; | |
460 | unsigned int bVal = 3; | |
461 | unsigned int cVal = 1; | |
462 | ||
463 | wxUNICHAR_TEST_INT_COMPARE | |
464 | } | |
465 | ||
466 | void UniCharTestCase::LongCompare() | |
467 | { | |
468 | long aVal = 2; | |
469 | long bVal = 3; | |
470 | long cVal = 1; | |
471 | ||
472 | wxUNICHAR_TEST_INT_COMPARE | |
473 | } | |
474 | ||
475 | void UniCharTestCase::UnsignedLongCompare() | |
476 | { | |
477 | unsigned long aVal = 2; | |
478 | unsigned long bVal = 3; | |
479 | unsigned long cVal = 1; | |
480 | ||
481 | wxUNICHAR_TEST_INT_COMPARE | |
482 | } | |
483 | ||
484 | #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG | |
485 | ||
486 | void UniCharTestCase::wxLongLongCompare() | |
487 | { | |
488 | wxLongLong_t aVal = 2; | |
489 | wxLongLong_t bVal = 3; | |
490 | wxLongLong_t cVal = 1; | |
491 | ||
492 | wxUNICHAR_TEST_INT_COMPARE | |
493 | } | |
494 | ||
495 | void UniCharTestCase::wxULongLongCompare() | |
496 | { | |
497 | wxULongLong_t aVal = 2; | |
498 | wxULongLong_t bVal = 3; | |
499 | wxULongLong_t cVal = 1; | |
500 | ||
501 | wxUNICHAR_TEST_INT_COMPARE | |
502 | } | |
503 | ||
504 | #endif | |
505 | ||
506 | #if wxWCHAR_T_IS_REAL_TYPE | |
507 | ||
508 | void UniCharTestCase::WideCharCompare() | |
509 | { | |
510 | wchar_t aVal = 2; | |
511 | wchar_t bVal = 3; | |
512 | wchar_t cVal = 1; | |
513 | ||
514 | wxUNICHAR_TEST_INT_COMPARE | |
515 | } | |
516 | ||
517 | #endif | |
518 | ||
519 | #undef wxUNICHAR_TEST_INT_COMPARE | |
520 | ||
521 | #define wxUNICHAR_TEST_ASSIGNMENT_OPERATOR \ | |
522 | wxUniChar a; \ | |
523 | wxUniChar b(bVal); \ | |
524 | a = b; \ | |
525 | CPPUNIT_ASSERT(a == b); | |
526 | ||
527 | void UniCharTestCase::UniCharAssignmentOperator() | |
528 | { | |
529 | wxUniChar a; | |
530 | wxUniChar b('b'); | |
531 | a = b; | |
532 | CPPUNIT_ASSERT(a == b); | |
533 | } | |
534 | ||
535 | void UniCharTestCase::UniCharRefAssignmentOperator() | |
536 | { | |
537 | wxUniChar a; | |
538 | wxUniChar b('b'); | |
539 | wxString bStr('b'); | |
540 | wxUniCharRef bRef = bStr[0]; | |
541 | a = bRef; | |
542 | CPPUNIT_ASSERT(a == b); | |
543 | } | |
544 | ||
545 | void UniCharTestCase::CharAssignmentOperator() | |
546 | { | |
547 | char bVal = 'b'; | |
548 | ||
549 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
550 | } | |
551 | ||
552 | void UniCharTestCase::UnsignedCharAssignmentOperator() | |
553 | { | |
554 | unsigned char bVal = 2; | |
555 | ||
556 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
557 | } | |
558 | ||
559 | void UniCharTestCase::ShortAssignmentOperator() | |
560 | { | |
561 | short bVal = 2; | |
562 | ||
563 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
564 | } | |
565 | ||
566 | void UniCharTestCase::UnsignedShortAssignmentOperator() | |
567 | { | |
568 | unsigned short bVal = 2; | |
569 | ||
570 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
571 | } | |
572 | ||
573 | void UniCharTestCase::IntAssignmentOperator() | |
574 | { | |
575 | int bVal = 2; | |
576 | ||
577 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
578 | } | |
579 | ||
580 | void UniCharTestCase::UnsignedIntAssignmentOperator() | |
581 | { | |
582 | unsigned int bVal = 2; | |
583 | ||
584 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
585 | } | |
586 | ||
587 | void UniCharTestCase::LongAssignmentOperator() | |
588 | { | |
589 | long bVal = 2; | |
590 | ||
591 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
592 | } | |
593 | ||
594 | void UniCharTestCase::UnsignedLongAssignmentOperator() | |
595 | { | |
596 | unsigned long bVal = 2; | |
597 | ||
598 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
599 | } | |
600 | ||
601 | #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG | |
602 | ||
603 | void UniCharTestCase::wxLongLongAssignmentOperator() | |
604 | { | |
605 | wxLongLong_t bVal = 2; | |
606 | ||
607 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
608 | } | |
609 | ||
610 | void UniCharTestCase::wxULongLongAssignmentOperator() | |
611 | { | |
612 | wxULongLong_t bVal = 2; | |
613 | ||
614 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
615 | } | |
616 | ||
617 | #endif | |
618 | ||
619 | #if wxWCHAR_T_IS_REAL_TYPE | |
620 | ||
621 | void UniCharTestCase::WideCharAssignmentOperator() | |
622 | { | |
623 | wchar_t bVal = 2; | |
624 | ||
625 | wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
626 | } | |
627 | ||
628 | #endif | |
629 | ||
630 | #undef wxUNICHAR_TEST_ASSIGNMENT_OPERATOR | |
631 | ||
632 | void UniCharTestCase::CharParenOperator() | |
633 | { | |
634 | char aVal; | |
635 | char bVal = 'b'; | |
636 | wxUniChar b(bVal); | |
637 | ||
638 | aVal = (char) b; | |
639 | CPPUNIT_ASSERT(aVal == bVal); | |
640 | } | |
641 | ||
642 | void UniCharTestCase::UnsignedCharParenOperator() | |
643 | { | |
644 | unsigned char aVal; | |
645 | unsigned char bVal = 'b'; | |
646 | wxUniChar b(bVal); | |
647 | ||
648 | aVal = (unsigned char) b; | |
649 | CPPUNIT_ASSERT(aVal == bVal); | |
650 | } | |
651 | ||
652 | void UniCharTestCase::ShortParenOperator() | |
653 | { | |
654 | short aVal; | |
655 | short bVal = 2; | |
656 | wxUniChar b(bVal); | |
657 | ||
658 | aVal = (short) b; | |
659 | CPPUNIT_ASSERT(aVal == bVal); | |
660 | } | |
661 | ||
662 | void UniCharTestCase::UnsignedShortParenOperator() | |
663 | { | |
664 | unsigned short aVal; | |
665 | unsigned short bVal = 2; | |
666 | wxUniChar b(bVal); | |
667 | ||
668 | aVal = (unsigned short) b; | |
669 | CPPUNIT_ASSERT(aVal == bVal); | |
670 | } | |
671 | ||
672 | void UniCharTestCase::IntParenOperator() | |
673 | { | |
674 | int aVal; | |
675 | int bVal = 2; | |
676 | wxUniChar b(bVal); | |
677 | ||
678 | aVal = (int) b; | |
679 | CPPUNIT_ASSERT(aVal == bVal); | |
680 | ||
681 | } | |
682 | ||
683 | void UniCharTestCase::UnsignedIntParenOperator() | |
684 | { | |
685 | unsigned int aVal; | |
686 | unsigned int bVal = 2; | |
687 | wxUniChar b(bVal); | |
688 | ||
689 | aVal = (unsigned int) b; | |
690 | CPPUNIT_ASSERT(aVal == bVal); | |
691 | } | |
692 | ||
693 | void UniCharTestCase::LongParenOperator() | |
694 | { | |
695 | long aVal; | |
696 | long bVal = 2; | |
697 | wxUniChar b(bVal); | |
698 | ||
699 | aVal = (long) b; | |
700 | CPPUNIT_ASSERT(aVal == bVal); | |
701 | } | |
702 | ||
703 | void UniCharTestCase::UnsignedLongParenOperator() | |
704 | { | |
705 | unsigned long aVal; | |
706 | unsigned long bVal = 2; | |
707 | wxUniChar b(bVal); | |
708 | ||
709 | aVal = (unsigned long) b; | |
710 | CPPUNIT_ASSERT(aVal == bVal); | |
711 | } | |
712 | ||
713 | #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG | |
714 | ||
715 | void UniCharTestCase::wxLongLongParenOperator() | |
716 | { | |
717 | wxLongLong_t aVal; | |
718 | wxLongLong_t bVal = 2; | |
719 | wxUniChar b(bVal); | |
720 | ||
721 | aVal = (wxLongLong_t) b; | |
722 | CPPUNIT_ASSERT(aVal == bVal); | |
723 | } | |
724 | ||
725 | void UniCharTestCase::wxULongLongParenOperator() | |
726 | { | |
727 | wxULongLong_t aVal; | |
728 | wxULongLong_t bVal = 2; | |
729 | wxUniChar b(bVal); | |
730 | ||
731 | aVal = (wxULongLong_t) b; | |
732 | CPPUNIT_ASSERT(aVal == bVal); | |
733 | } | |
734 | ||
735 | #endif | |
736 | ||
737 | #if wxWCHAR_T_IS_REAL_TYPE | |
738 | ||
739 | void UniCharTestCase::WideCharParenOperator() | |
740 | { | |
741 | wchar_t aVal; | |
742 | wchar_t bVal = 2; | |
743 | wxUniChar b(bVal); | |
744 | ||
745 | aVal = (wchar_t) b; | |
746 | CPPUNIT_ASSERT(aVal == bVal); | |
747 | } | |
748 | ||
749 | #endif | |
750 | ||
751 | void UniCharTestCase::RefUniCharAssignmentOperator() | |
752 | { | |
753 | wxString dummyStr('0'); | |
754 | wxUniCharRef bRef = dummyStr[0]; | |
755 | ||
756 | wxChar b = 'b'; | |
757 | wxUniChar bVal(b); | |
758 | bRef = bVal; | |
759 | ||
760 | CPPUNIT_ASSERT(bRef == b); | |
761 | } | |
762 | ||
763 | void UniCharTestCase::RefUniCharRefAssignmentOperator() | |
764 | { | |
765 | wxChar b = 'b'; | |
766 | wxString testStr(b); | |
767 | wxUniCharRef testRef = testStr[0]; | |
768 | ||
769 | wxString dummyStr('0'); | |
770 | wxUniCharRef bRef = dummyStr[0]; | |
771 | ||
772 | bRef = testRef; | |
773 | ||
774 | CPPUNIT_ASSERT(bRef == testRef); | |
775 | } | |
776 | ||
777 | void UniCharTestCase::RefCharAssignmentOperator() | |
778 | { | |
779 | wxString dummyStr('0'); | |
780 | wxUniCharRef bRef = dummyStr[0]; | |
781 | ||
782 | char b = 'b'; | |
783 | bRef = b; | |
784 | ||
785 | CPPUNIT_ASSERT(bRef == b); | |
786 | } | |
787 | ||
788 | void UniCharTestCase::RefUnsignedCharAssignmentOperator() | |
789 | { | |
790 | wxString dummyStr('0'); | |
791 | wxUniCharRef bRef = dummyStr[0]; | |
792 | ||
793 | unsigned char b = 'b'; | |
794 | bRef = b; | |
795 | ||
796 | CPPUNIT_ASSERT(bRef == b); | |
797 | } | |
798 | ||
799 | void UniCharTestCase::RefShortAssignmentOperator() | |
800 | { | |
801 | wxString dummyStr('0'); | |
802 | wxUniCharRef bRef = dummyStr[0]; | |
803 | ||
804 | short b = 2; | |
805 | bRef = b; | |
806 | ||
807 | CPPUNIT_ASSERT(bRef == b); | |
808 | } | |
809 | ||
810 | void UniCharTestCase::RefUnsignedShortAssignmentOperator() | |
811 | { | |
812 | wxString dummyStr('0'); | |
813 | wxUniCharRef bRef = dummyStr[0]; | |
814 | ||
815 | unsigned short b = 2; | |
816 | bRef = b; | |
817 | ||
818 | CPPUNIT_ASSERT(bRef == b); | |
819 | } | |
820 | ||
821 | void UniCharTestCase::RefIntAssignmentOperator() | |
822 | { | |
823 | wxString dummyStr('0'); | |
824 | wxUniCharRef bRef = dummyStr[0]; | |
825 | ||
826 | int b = 2; | |
827 | bRef = b; | |
828 | ||
829 | CPPUNIT_ASSERT(bRef == b); | |
830 | } | |
831 | ||
832 | void UniCharTestCase::RefUnsignedIntAssignmentOperator() | |
833 | { | |
834 | wxString dummyStr('0'); | |
835 | wxUniCharRef bRef = dummyStr[0]; | |
836 | ||
837 | unsigned int b = 2; | |
838 | bRef = b; | |
839 | ||
840 | CPPUNIT_ASSERT(bRef == b); | |
841 | } | |
842 | ||
843 | void UniCharTestCase::RefLongAssignmentOperator() | |
844 | { | |
845 | wxString dummyStr('0'); | |
846 | wxUniCharRef bRef = dummyStr[0]; | |
847 | ||
848 | long b = 2; | |
849 | bRef = b; | |
850 | ||
851 | CPPUNIT_ASSERT(bRef == b); | |
852 | } | |
853 | ||
854 | void UniCharTestCase::RefUnsignedLongAssignmentOperator() | |
855 | { | |
856 | wxString dummyStr('0'); | |
857 | wxUniCharRef bRef = dummyStr[0]; | |
858 | ||
859 | unsigned long b = 2; | |
860 | bRef = b; | |
861 | ||
862 | CPPUNIT_ASSERT(bRef == b); | |
863 | } | |
864 | ||
865 | #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG | |
866 | ||
867 | void UniCharTestCase::RefwxLongLongAssignmentOperator() | |
868 | { | |
869 | wxString dummyStr('0'); | |
870 | wxUniCharRef bRef = dummyStr[0]; | |
871 | ||
872 | wxLongLong_t b = 2; | |
873 | bRef = b; | |
874 | ||
875 | CPPUNIT_ASSERT(bRef == b); | |
876 | } | |
877 | void UniCharTestCase::RefwxULongLongAssignmentOperator() | |
878 | { | |
879 | wxString dummyStr('0'); | |
880 | wxUniCharRef bRef = dummyStr[0]; | |
881 | ||
882 | unsigned long b = 2; | |
883 | bRef = b; | |
884 | ||
885 | CPPUNIT_ASSERT(bRef == b); | |
886 | } | |
887 | ||
888 | #endif | |
889 | ||
890 | #if wxWCHAR_T_IS_REAL_TYPE | |
891 | ||
892 | void UniCharTestCase::RefWideCharAssignmentOperator() | |
893 | { | |
894 | wxString dummyStr('0'); | |
895 | wxUniCharRef bRef = dummyStr[0]; | |
896 | ||
897 | wchar_t b = 2; | |
898 | bRef = b; | |
899 | ||
900 | CPPUNIT_ASSERT(bRef == b); | |
901 | } | |
902 | ||
903 | #endif | |
904 | ||
905 | void UniCharTestCase::RefCharParenOperator() | |
906 | { | |
907 | char aVal; | |
908 | char bVal = 'b'; | |
909 | wxString testStr(bVal); | |
910 | wxUniCharRef bRef = testStr[0]; | |
911 | ||
912 | aVal = (char) bRef; | |
913 | CPPUNIT_ASSERT(aVal == bVal); | |
914 | } | |
915 | ||
916 | void UniCharTestCase::RefUnsignedCharParenOperator() | |
917 | { | |
918 | unsigned char aVal; | |
919 | unsigned char bVal = 'b'; | |
920 | wxString testStr = wxString::Format(wxT("%u"), bVal); | |
921 | wxUniCharRef bRef = testStr[0]; | |
922 | ||
923 | aVal = (unsigned char) bRef; | |
924 | CPPUNIT_ASSERT(aVal == bVal); | |
925 | } | |
926 | ||
927 | void UniCharTestCase::RefShortParenOperator() | |
928 | { | |
929 | short aVal; | |
930 | short bVal = 2; | |
931 | wxUniChar b(bVal); | |
932 | ||
933 | wxString dummyStr("0"); | |
934 | wxUniCharRef bRef = dummyStr[0]; | |
935 | bRef = b; | |
936 | ||
937 | aVal = (short) bRef; | |
938 | CPPUNIT_ASSERT(aVal == bVal); | |
939 | } | |
940 | ||
941 | void UniCharTestCase::RefUnsignedShortParenOperator() | |
942 | { | |
943 | unsigned short aVal; | |
944 | unsigned short bVal = 2; | |
945 | wxUniChar b(bVal); | |
946 | ||
947 | wxString dummyStr("0"); | |
948 | wxUniCharRef bRef = dummyStr[0]; | |
949 | bRef = b; | |
950 | ||
951 | aVal = (unsigned short) bRef; | |
952 | CPPUNIT_ASSERT(aVal == bVal); | |
953 | } | |
954 | ||
955 | void UniCharTestCase::RefIntParenOperator() | |
956 | { | |
957 | int aVal; | |
958 | int bVal = 2; | |
959 | wxUniChar b(bVal); | |
960 | ||
961 | wxString dummyStr("0"); | |
962 | wxUniCharRef bRef = dummyStr[0]; | |
963 | bRef = b; | |
964 | ||
965 | aVal = (int) bRef; | |
966 | CPPUNIT_ASSERT(aVal == bVal); | |
967 | } | |
968 | ||
969 | void UniCharTestCase::RefUnsignedIntParenOperator() | |
970 | { | |
971 | unsigned int aVal; | |
972 | unsigned int bVal = 2; | |
973 | wxUniChar b(bVal); | |
974 | ||
975 | wxString dummyStr("0"); | |
976 | wxUniCharRef bRef = dummyStr[0]; | |
977 | bRef = b; | |
978 | ||
979 | aVal = (unsigned int) bRef; | |
980 | CPPUNIT_ASSERT(aVal == bVal); | |
981 | } | |
982 | ||
983 | void UniCharTestCase::RefLongParenOperator() | |
984 | { | |
985 | long aVal; | |
986 | long bVal = 2; | |
987 | wxUniChar b(bVal); | |
988 | ||
989 | wxString dummyStr("0"); | |
990 | wxUniCharRef bRef = dummyStr[0]; | |
991 | bRef = b; | |
992 | ||
993 | aVal = (long) bRef; | |
994 | CPPUNIT_ASSERT(aVal == bVal); | |
995 | } | |
996 | ||
997 | void UniCharTestCase::RefUnsignedLongParenOperator() | |
998 | { | |
999 | unsigned long aVal; | |
1000 | unsigned long bVal = 2; | |
1001 | wxUniChar b(bVal); | |
1002 | ||
1003 | wxString dummyStr("0"); | |
1004 | wxUniCharRef bRef = dummyStr[0]; | |
1005 | bRef = b; | |
1006 | ||
1007 | aVal = (unsigned long) bRef; | |
1008 | CPPUNIT_ASSERT(aVal == bVal); | |
1009 | } | |
1010 | ||
1011 | #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG | |
1012 | ||
1013 | void UniCharTestCase::RefwxLongLongParenOperator() | |
1014 | { | |
1015 | wxLongLong_t aVal; | |
1016 | wxLongLong_t bVal = 2; | |
1017 | wxUniChar b(bVal); | |
1018 | ||
1019 | wxString dummyStr("0"); | |
1020 | wxUniCharRef bRef = dummyStr[0]; | |
1021 | bRef = b; | |
1022 | ||
1023 | aVal = (wxLongLong_t) bRef; | |
1024 | CPPUNIT_ASSERT(aVal == bVal); | |
1025 | } | |
1026 | ||
1027 | void UniCharTestCase::RefwxULongLongParenOperator() | |
1028 | { | |
1029 | wxULongLong_t aVal; | |
1030 | wxULongLong_t bVal = 2; | |
1031 | wxUniChar b(bVal); | |
1032 | ||
1033 | wxString dummyStr("0"); | |
1034 | wxUniCharRef bRef = dummyStr[0]; | |
1035 | bRef = b; | |
1036 | ||
1037 | aVal = (wxULongLong_t) bRef; | |
1038 | CPPUNIT_ASSERT(aVal == bVal); | |
1039 | } | |
1040 | ||
1041 | #endif | |
1042 | ||
1043 | #if wxWCHAR_T_IS_REAL_TYPE | |
1044 | ||
1045 | void UniCharTestCase::RefWideCharParenOperator() | |
1046 | { | |
1047 | wchar_t aVal; | |
1048 | wchar_t bVal = 2; | |
1049 | wxUniChar b(bVal); | |
1050 | ||
1051 | wxString dummyStr("0"); | |
1052 | wxUniCharRef bRef = dummyStr[0]; | |
1053 | bRef = b; | |
1054 | ||
1055 | aVal = (wxLongLong_t) bRef; | |
1056 | CPPUNIT_ASSERT(aVal == bVal); | |
1057 | } | |
1058 | ||
1059 | #endif | |
1060 | ||
1061 | #define wxUNICHARREF_TEST_INT_COMPARE \ | |
1062 | wxUniChar a(aVal); \ | |
1063 | wxString dummyStr("0"); \ | |
1064 | wxUniCharRef aRef = dummyStr[0]; \ | |
1065 | aRef = a; \ | |
1066 | CPPUNIT_ASSERT( aRef == aVal ); \ | |
1067 | CPPUNIT_ASSERT( aRef != bVal ); \ | |
1068 | CPPUNIT_ASSERT( aRef < bVal ); \ | |
1069 | CPPUNIT_ASSERT( aRef <= bVal ); \ | |
1070 | CPPUNIT_ASSERT( aRef > cVal ); \ | |
1071 | CPPUNIT_ASSERT( aRef >= cVal ); | |
1072 | ||
1073 | void UniCharTestCase::RefShortCompare() | |
1074 | { | |
1075 | short aVal = 2; | |
1076 | short bVal = 3; | |
1077 | short cVal = 1; | |
1078 | ||
1079 | wxUNICHARREF_TEST_INT_COMPARE | |
1080 | } | |
1081 | ||
1082 | void UniCharTestCase::RefUnsignedShortCompare() | |
1083 | { | |
1084 | unsigned short aVal = 2; | |
1085 | unsigned short bVal = 3; | |
1086 | unsigned short cVal = 1; | |
1087 | ||
1088 | wxUNICHARREF_TEST_INT_COMPARE | |
1089 | } | |
1090 | ||
1091 | void UniCharTestCase::RefIntCompare() | |
1092 | { | |
1093 | int aVal = 2; | |
1094 | int bVal = 3; | |
1095 | int cVal = 1; | |
1096 | ||
1097 | wxUNICHARREF_TEST_INT_COMPARE | |
1098 | } | |
1099 | ||
1100 | void UniCharTestCase::RefUnsignedIntCompare() | |
1101 | { | |
1102 | unsigned int aVal = 2; | |
1103 | unsigned int bVal = 3; | |
1104 | unsigned int cVal = 1; | |
1105 | ||
1106 | wxUNICHARREF_TEST_INT_COMPARE | |
1107 | } | |
1108 | ||
1109 | void UniCharTestCase::RefLongCompare() | |
1110 | { | |
1111 | long aVal = 2; | |
1112 | long bVal = 3; | |
1113 | long cVal = 1; | |
1114 | ||
1115 | wxUNICHARREF_TEST_INT_COMPARE | |
1116 | } | |
1117 | ||
1118 | void UniCharTestCase::RefUnsignedLongCompare() | |
1119 | { | |
1120 | unsigned long aVal = 2; | |
1121 | unsigned long bVal = 3; | |
1122 | unsigned long cVal = 1; | |
1123 | ||
1124 | wxUNICHARREF_TEST_INT_COMPARE | |
1125 | } | |
1126 | ||
1127 | #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG | |
1128 | ||
1129 | void UniCharTestCase::RefwxLongLongCompare() | |
1130 | { | |
1131 | wxLongLong_t aVal = 2; | |
1132 | wxLongLong_t bVal = 3; | |
1133 | wxLongLong_t cVal = 1; | |
1134 | ||
1135 | wxUNICHARREF_TEST_INT_COMPARE | |
1136 | } | |
1137 | ||
1138 | void UniCharTestCase::RefwxULongLongCompare() | |
1139 | { | |
1140 | wxULongLong_t aVal = 2; | |
1141 | wxULongLong_t bVal = 3; | |
1142 | wxULongLong_t cVal = 1; | |
1143 | ||
1144 | wxUNICHARREF_TEST_INT_COMPARE | |
1145 | } | |
1146 | ||
1147 | #endif | |
1148 | ||
1149 | #if wxWCHAR_T_IS_REAL_TYPE | |
1150 | ||
1151 | void UniCharTestCase::RefWideCharCompare() | |
1152 | { | |
1153 | wchar_t aVal = 2; | |
1154 | wchar_t bVal = 3; | |
1155 | wchar_t cVal = 1; | |
1156 | ||
1157 | wxUNICHARREF_TEST_INT_COMPARE | |
1158 | } | |
1159 | ||
1160 | #endif |