1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/unichar.cpp
3 // Purpose: Test for wxUniChar class
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2007 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ----------------------------------------------------------------------------
13 // ----------------------------------------------------------------------------
25 #include "wx/string.h"
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class UniCharTestCase
: public CppUnit::TestCase
37 CPPUNIT_TEST_SUITE( UniCharTestCase
);
38 CPPUNIT_TEST( CharCompare
);
39 CPPUNIT_TEST( CharCompareIntl
);
40 CPPUNIT_TEST( StringCompare
);
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
); )
106 CPPUNIT_TEST( StringCompareIntl
);
107 #endif // wxUSE_UNICODE
108 CPPUNIT_TEST_SUITE_END();
111 void CharCompareIntl();
112 void StringCompare();
113 void StringCompareIntl();
115 void UnsignedShortCompare();
117 void UnsignedIntCompare();
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(); )
181 DECLARE_NO_COPY_CLASS(UniCharTestCase
)
184 // register in the unnamed registry so that these tests are run by default
185 CPPUNIT_TEST_SUITE_REGISTRATION( UniCharTestCase
);
187 // also include in its own registry so that these tests can be run alone
188 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UniCharTestCase
, "UniCharTestCase" );
190 void UniCharTestCase::CharCompare()
195 CPPUNIT_ASSERT( a
== a
);
196 CPPUNIT_ASSERT( a
== 'a' );
197 CPPUNIT_ASSERT( a
== wxT('a') );
198 CPPUNIT_ASSERT( a
== wxUniChar('a') );
199 CPPUNIT_ASSERT( a
== wxUniChar(wxT('a')) );
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
);
207 CPPUNIT_ASSERT( a
!= b
);
208 CPPUNIT_ASSERT( a
!= 'b' );
209 CPPUNIT_ASSERT( a
!= wxT('b') );
210 CPPUNIT_ASSERT( a
!= wxUniChar('b') );
211 CPPUNIT_ASSERT( a
!= wxUniChar(wxT('b')) );
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
);
219 CPPUNIT_ASSERT( a
< b
);
220 CPPUNIT_ASSERT( a
< 'b' );
221 CPPUNIT_ASSERT( a
< wxT('b') );
222 CPPUNIT_ASSERT( a
< wxUniChar('b') );
223 CPPUNIT_ASSERT( a
< wxUniChar(wxT('b')) );
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
);
231 CPPUNIT_ASSERT( a
<= b
);
232 CPPUNIT_ASSERT( a
<= 'b' );
233 CPPUNIT_ASSERT( a
<= wxT('b') );
234 CPPUNIT_ASSERT( a
<= wxUniChar('b') );
235 CPPUNIT_ASSERT( a
<= wxUniChar(wxT('b')) );
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
);
243 CPPUNIT_ASSERT( a
<= a
);
244 CPPUNIT_ASSERT( a
<= 'a' );
245 CPPUNIT_ASSERT( a
<= wxT('a') );
246 CPPUNIT_ASSERT( a
<= wxUniChar('a') );
247 CPPUNIT_ASSERT( a
<= wxUniChar(wxT('a')) );
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
);
255 CPPUNIT_ASSERT( b
> a
);
256 CPPUNIT_ASSERT( b
> 'a' );
257 CPPUNIT_ASSERT( b
> wxT('a') );
258 CPPUNIT_ASSERT( b
> wxUniChar('a') );
259 CPPUNIT_ASSERT( b
> wxUniChar(wxT('a')) );
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
);
267 CPPUNIT_ASSERT( b
>= a
);
268 CPPUNIT_ASSERT( b
>= 'a' );
269 CPPUNIT_ASSERT( b
>= wxT('a') );
270 CPPUNIT_ASSERT( b
>= wxUniChar('a') );
271 CPPUNIT_ASSERT( b
>= wxUniChar(wxT('a')) );
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
);
279 CPPUNIT_ASSERT( b
>= b
);
280 CPPUNIT_ASSERT( b
>= 'b' );
281 CPPUNIT_ASSERT( b
>= wxT('b') );
282 CPPUNIT_ASSERT( b
>= wxUniChar('b') );
283 CPPUNIT_ASSERT( b
>= wxUniChar(wxT('b')) );
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
);
291 CPPUNIT_ASSERT( b
- a
== 1 );
292 CPPUNIT_ASSERT( a
- b
== -1 );
296 #define CYRILLIC_SMALL_LETTER_YU ((wchar_t)0x044E)
297 #define ARABIC_LETTER_NOON ((wchar_t)0x0646)
299 void UniCharTestCase::CharCompareIntl()
301 wxUniChar
a(CYRILLIC_SMALL_LETTER_YU
);
302 wxUniChar
b(ARABIC_LETTER_NOON
);
304 CPPUNIT_ASSERT( a
== a
);
305 CPPUNIT_ASSERT( a
== CYRILLIC_SMALL_LETTER_YU
);
306 CPPUNIT_ASSERT( a
== wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
308 CPPUNIT_ASSERT( a
!= b
);
309 CPPUNIT_ASSERT( a
!= ARABIC_LETTER_NOON
);
310 CPPUNIT_ASSERT( a
!= wxUniChar(ARABIC_LETTER_NOON
) );
312 CPPUNIT_ASSERT( a
< b
);
313 CPPUNIT_ASSERT( a
< ARABIC_LETTER_NOON
);
314 CPPUNIT_ASSERT( a
< wxUniChar(ARABIC_LETTER_NOON
) );
316 CPPUNIT_ASSERT( a
<= b
);
317 CPPUNIT_ASSERT( a
<= ARABIC_LETTER_NOON
);
318 CPPUNIT_ASSERT( a
<= wxUniChar(ARABIC_LETTER_NOON
) );
320 CPPUNIT_ASSERT( a
<= a
);
321 CPPUNIT_ASSERT( a
<= CYRILLIC_SMALL_LETTER_YU
);
322 CPPUNIT_ASSERT( a
<= wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
324 CPPUNIT_ASSERT( b
> a
);
325 CPPUNIT_ASSERT( b
> CYRILLIC_SMALL_LETTER_YU
);
326 CPPUNIT_ASSERT( b
> wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
328 CPPUNIT_ASSERT( b
>= a
);
329 CPPUNIT_ASSERT( b
>= CYRILLIC_SMALL_LETTER_YU
);
330 CPPUNIT_ASSERT( b
>= wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
332 CPPUNIT_ASSERT( b
>= b
);
333 CPPUNIT_ASSERT( b
>= ARABIC_LETTER_NOON
);
334 CPPUNIT_ASSERT( b
>= wxUniChar(ARABIC_LETTER_NOON
) );
336 CPPUNIT_ASSERT( b
- a
== 504 );
337 CPPUNIT_ASSERT( a
- b
== -504 );
340 void UniCharTestCase::StringCompare()
342 // test string comparison with chars
344 const wxString sb
= "b";
346 wchar_t c2
= wxT('a');
349 CPPUNIT_ASSERT( sa
== 'a');
350 CPPUNIT_ASSERT( 'a' == sa
);
351 CPPUNIT_ASSERT( sb
!= 'a');
352 CPPUNIT_ASSERT( 'a' != sb
);
354 CPPUNIT_ASSERT( sa
== c1
);
355 CPPUNIT_ASSERT( c1
== sa
);
356 CPPUNIT_ASSERT( sb
!= c1
);
357 CPPUNIT_ASSERT( c1
!= sb
);
359 CPPUNIT_ASSERT( sa
== c2
);
360 CPPUNIT_ASSERT( c2
== sa
);
361 CPPUNIT_ASSERT( sb
!= c2
);
362 CPPUNIT_ASSERT( c2
!= sb
);
364 CPPUNIT_ASSERT( sa
== c3
);
365 CPPUNIT_ASSERT( c3
== sa
);
366 CPPUNIT_ASSERT( sb
!= c3
);
367 CPPUNIT_ASSERT( c3
!= sb
);
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
);
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
);
383 void UniCharTestCase::StringCompareIntl()
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
;
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
);
396 CPPUNIT_ASSERT( sa
== c2
);
397 CPPUNIT_ASSERT( c2
== sa
);
398 CPPUNIT_ASSERT( sb
!= c2
);
399 CPPUNIT_ASSERT( c2
!= sb
);
401 CPPUNIT_ASSERT( sa
== c3
);
402 CPPUNIT_ASSERT( c3
== sa
);
403 CPPUNIT_ASSERT( sb
!= c3
);
404 CPPUNIT_ASSERT( c3
!= sb
);
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
);
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
);
418 #endif // wxUSE_UNICODE
420 #define wxUNICHAR_TEST_INT_COMPARE \
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 );
430 void UniCharTestCase::ShortCompare()
436 wxUNICHAR_TEST_INT_COMPARE
439 void UniCharTestCase::UnsignedShortCompare()
441 unsigned short aVal
= 2;
442 unsigned short bVal
= 3;
443 unsigned short cVal
= 1;
445 wxUNICHAR_TEST_INT_COMPARE
448 void UniCharTestCase::IntCompare()
454 wxUNICHAR_TEST_INT_COMPARE
457 void UniCharTestCase::UnsignedIntCompare()
459 unsigned int aVal
= 2;
460 unsigned int bVal
= 3;
461 unsigned int cVal
= 1;
463 wxUNICHAR_TEST_INT_COMPARE
466 void UniCharTestCase::LongCompare()
472 wxUNICHAR_TEST_INT_COMPARE
475 void UniCharTestCase::UnsignedLongCompare()
477 unsigned long aVal
= 2;
478 unsigned long bVal
= 3;
479 unsigned long cVal
= 1;
481 wxUNICHAR_TEST_INT_COMPARE
484 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
486 void UniCharTestCase::wxLongLongCompare()
488 wxLongLong_t aVal
= 2;
489 wxLongLong_t bVal
= 3;
490 wxLongLong_t cVal
= 1;
492 wxUNICHAR_TEST_INT_COMPARE
495 void UniCharTestCase::wxULongLongCompare()
497 wxULongLong_t aVal
= 2;
498 wxULongLong_t bVal
= 3;
499 wxULongLong_t cVal
= 1;
501 wxUNICHAR_TEST_INT_COMPARE
506 #if wxWCHAR_T_IS_REAL_TYPE
508 void UniCharTestCase::WideCharCompare()
514 wxUNICHAR_TEST_INT_COMPARE
519 #undef wxUNICHAR_TEST_INT_COMPARE
521 #define wxUNICHAR_TEST_ASSIGNMENT_OPERATOR \
525 CPPUNIT_ASSERT(a == b);
527 void UniCharTestCase::UniCharAssignmentOperator()
532 CPPUNIT_ASSERT(a
== b
);
535 void UniCharTestCase::UniCharRefAssignmentOperator()
540 wxUniCharRef bRef
= bStr
[0];
542 CPPUNIT_ASSERT(a
== b
);
545 void UniCharTestCase::CharAssignmentOperator()
549 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
552 void UniCharTestCase::UnsignedCharAssignmentOperator()
554 unsigned char bVal
= 2;
556 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
559 void UniCharTestCase::ShortAssignmentOperator()
563 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
566 void UniCharTestCase::UnsignedShortAssignmentOperator()
568 unsigned short bVal
= 2;
570 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
573 void UniCharTestCase::IntAssignmentOperator()
577 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
580 void UniCharTestCase::UnsignedIntAssignmentOperator()
582 unsigned int bVal
= 2;
584 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
587 void UniCharTestCase::LongAssignmentOperator()
591 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
594 void UniCharTestCase::UnsignedLongAssignmentOperator()
596 unsigned long bVal
= 2;
598 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
601 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
603 void UniCharTestCase::wxLongLongAssignmentOperator()
605 wxLongLong_t bVal
= 2;
607 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
610 void UniCharTestCase::wxULongLongAssignmentOperator()
612 wxULongLong_t bVal
= 2;
614 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
619 #if wxWCHAR_T_IS_REAL_TYPE
621 void UniCharTestCase::WideCharAssignmentOperator()
625 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
630 #undef wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
632 void UniCharTestCase::CharParenOperator()
639 CPPUNIT_ASSERT(aVal
== bVal
);
642 void UniCharTestCase::UnsignedCharParenOperator()
645 unsigned char bVal
= 'b';
648 aVal
= (unsigned char) b
;
649 CPPUNIT_ASSERT(aVal
== bVal
);
652 void UniCharTestCase::ShortParenOperator()
659 CPPUNIT_ASSERT(aVal
== bVal
);
662 void UniCharTestCase::UnsignedShortParenOperator()
665 unsigned short bVal
= 2;
668 aVal
= (unsigned short) b
;
669 CPPUNIT_ASSERT(aVal
== bVal
);
672 void UniCharTestCase::IntParenOperator()
679 CPPUNIT_ASSERT(aVal
== bVal
);
683 void UniCharTestCase::UnsignedIntParenOperator()
686 unsigned int bVal
= 2;
689 aVal
= (unsigned int) b
;
690 CPPUNIT_ASSERT(aVal
== bVal
);
693 void UniCharTestCase::LongParenOperator()
700 CPPUNIT_ASSERT(aVal
== bVal
);
703 void UniCharTestCase::UnsignedLongParenOperator()
706 unsigned long bVal
= 2;
709 aVal
= (unsigned long) b
;
710 CPPUNIT_ASSERT(aVal
== bVal
);
713 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
715 void UniCharTestCase::wxLongLongParenOperator()
718 wxLongLong_t bVal
= 2;
721 aVal
= (wxLongLong_t
) b
;
722 CPPUNIT_ASSERT(aVal
== bVal
);
725 void UniCharTestCase::wxULongLongParenOperator()
728 wxULongLong_t bVal
= 2;
731 aVal
= (wxULongLong_t
) b
;
732 CPPUNIT_ASSERT(aVal
== bVal
);
737 #if wxWCHAR_T_IS_REAL_TYPE
739 void UniCharTestCase::WideCharParenOperator()
746 CPPUNIT_ASSERT(aVal
== bVal
);
751 void UniCharTestCase::RefUniCharAssignmentOperator()
753 wxString
dummyStr('0');
754 wxUniCharRef bRef
= dummyStr
[0];
760 CPPUNIT_ASSERT(bRef
== b
);
763 void UniCharTestCase::RefUniCharRefAssignmentOperator()
767 wxUniCharRef testRef
= testStr
[0];
769 wxString
dummyStr('0');
770 wxUniCharRef bRef
= dummyStr
[0];
774 CPPUNIT_ASSERT(bRef
== testRef
);
777 void UniCharTestCase::RefCharAssignmentOperator()
779 wxString
dummyStr('0');
780 wxUniCharRef bRef
= dummyStr
[0];
785 CPPUNIT_ASSERT(bRef
== b
);
788 void UniCharTestCase::RefUnsignedCharAssignmentOperator()
790 wxString
dummyStr('0');
791 wxUniCharRef bRef
= dummyStr
[0];
793 unsigned char b
= 'b';
796 CPPUNIT_ASSERT(bRef
== b
);
799 void UniCharTestCase::RefShortAssignmentOperator()
801 wxString
dummyStr('0');
802 wxUniCharRef bRef
= dummyStr
[0];
807 CPPUNIT_ASSERT(bRef
== b
);
810 void UniCharTestCase::RefUnsignedShortAssignmentOperator()
812 wxString
dummyStr('0');
813 wxUniCharRef bRef
= dummyStr
[0];
815 unsigned short b
= 2;
818 CPPUNIT_ASSERT(bRef
== b
);
821 void UniCharTestCase::RefIntAssignmentOperator()
823 wxString
dummyStr('0');
824 wxUniCharRef bRef
= dummyStr
[0];
829 CPPUNIT_ASSERT(bRef
== b
);
832 void UniCharTestCase::RefUnsignedIntAssignmentOperator()
834 wxString
dummyStr('0');
835 wxUniCharRef bRef
= dummyStr
[0];
840 CPPUNIT_ASSERT(bRef
== b
);
843 void UniCharTestCase::RefLongAssignmentOperator()
845 wxString
dummyStr('0');
846 wxUniCharRef bRef
= dummyStr
[0];
851 CPPUNIT_ASSERT(bRef
== b
);
854 void UniCharTestCase::RefUnsignedLongAssignmentOperator()
856 wxString
dummyStr('0');
857 wxUniCharRef bRef
= dummyStr
[0];
862 CPPUNIT_ASSERT(bRef
== b
);
865 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
867 void UniCharTestCase::RefwxLongLongAssignmentOperator()
869 wxString
dummyStr('0');
870 wxUniCharRef bRef
= dummyStr
[0];
875 CPPUNIT_ASSERT(bRef
== b
);
877 void UniCharTestCase::RefwxULongLongAssignmentOperator()
879 wxString
dummyStr('0');
880 wxUniCharRef bRef
= dummyStr
[0];
885 CPPUNIT_ASSERT(bRef
== b
);
890 #if wxWCHAR_T_IS_REAL_TYPE
892 void UniCharTestCase::RefWideCharAssignmentOperator()
894 wxString
dummyStr('0');
895 wxUniCharRef bRef
= dummyStr
[0];
900 CPPUNIT_ASSERT(bRef
== b
);
905 void UniCharTestCase::RefCharParenOperator()
909 wxString
testStr(bVal
);
910 wxUniCharRef bRef
= testStr
[0];
913 CPPUNIT_ASSERT(aVal
== bVal
);
916 void UniCharTestCase::RefUnsignedCharParenOperator()
919 unsigned char bVal
= 'b';
920 wxString testStr
= wxString::Format(wxT("%u"), bVal
);
921 wxUniCharRef bRef
= testStr
[0];
923 aVal
= (unsigned char) bRef
;
924 CPPUNIT_ASSERT(aVal
== bVal
);
927 void UniCharTestCase::RefShortParenOperator()
933 wxString
dummyStr("0");
934 wxUniCharRef bRef
= dummyStr
[0];
938 CPPUNIT_ASSERT(aVal
== bVal
);
941 void UniCharTestCase::RefUnsignedShortParenOperator()
944 unsigned short bVal
= 2;
947 wxString
dummyStr("0");
948 wxUniCharRef bRef
= dummyStr
[0];
951 aVal
= (unsigned short) bRef
;
952 CPPUNIT_ASSERT(aVal
== bVal
);
955 void UniCharTestCase::RefIntParenOperator()
961 wxString
dummyStr("0");
962 wxUniCharRef bRef
= dummyStr
[0];
966 CPPUNIT_ASSERT(aVal
== bVal
);
969 void UniCharTestCase::RefUnsignedIntParenOperator()
972 unsigned int bVal
= 2;
975 wxString
dummyStr("0");
976 wxUniCharRef bRef
= dummyStr
[0];
979 aVal
= (unsigned int) bRef
;
980 CPPUNIT_ASSERT(aVal
== bVal
);
983 void UniCharTestCase::RefLongParenOperator()
989 wxString
dummyStr("0");
990 wxUniCharRef bRef
= dummyStr
[0];
994 CPPUNIT_ASSERT(aVal
== bVal
);
997 void UniCharTestCase::RefUnsignedLongParenOperator()
1000 unsigned long bVal
= 2;
1003 wxString
dummyStr("0");
1004 wxUniCharRef bRef
= dummyStr
[0];
1007 aVal
= (unsigned long) bRef
;
1008 CPPUNIT_ASSERT(aVal
== bVal
);
1011 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
1013 void UniCharTestCase::RefwxLongLongParenOperator()
1016 wxLongLong_t bVal
= 2;
1019 wxString
dummyStr("0");
1020 wxUniCharRef bRef
= dummyStr
[0];
1023 aVal
= (wxLongLong_t
) bRef
;
1024 CPPUNIT_ASSERT(aVal
== bVal
);
1027 void UniCharTestCase::RefwxULongLongParenOperator()
1030 wxULongLong_t bVal
= 2;
1033 wxString
dummyStr("0");
1034 wxUniCharRef bRef
= dummyStr
[0];
1037 aVal
= (wxULongLong_t
) bRef
;
1038 CPPUNIT_ASSERT(aVal
== bVal
);
1043 #if wxWCHAR_T_IS_REAL_TYPE
1045 void UniCharTestCase::RefWideCharParenOperator()
1051 wxString
dummyStr("0");
1052 wxUniCharRef bRef
= dummyStr
[0];
1055 aVal
= (wxLongLong_t
) bRef
;
1056 CPPUNIT_ASSERT(aVal
== bVal
);
1061 #define wxUNICHARREF_TEST_INT_COMPARE \
1062 wxUniChar a(aVal); \
1063 wxString dummyStr("0"); \
1064 wxUniCharRef aRef = dummyStr[0]; \
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 );
1073 void UniCharTestCase::RefShortCompare()
1079 wxUNICHARREF_TEST_INT_COMPARE
1082 void UniCharTestCase::RefUnsignedShortCompare()
1084 unsigned short aVal
= 2;
1085 unsigned short bVal
= 3;
1086 unsigned short cVal
= 1;
1088 wxUNICHARREF_TEST_INT_COMPARE
1091 void UniCharTestCase::RefIntCompare()
1097 wxUNICHARREF_TEST_INT_COMPARE
1100 void UniCharTestCase::RefUnsignedIntCompare()
1102 unsigned int aVal
= 2;
1103 unsigned int bVal
= 3;
1104 unsigned int cVal
= 1;
1106 wxUNICHARREF_TEST_INT_COMPARE
1109 void UniCharTestCase::RefLongCompare()
1115 wxUNICHARREF_TEST_INT_COMPARE
1118 void UniCharTestCase::RefUnsignedLongCompare()
1120 unsigned long aVal
= 2;
1121 unsigned long bVal
= 3;
1122 unsigned long cVal
= 1;
1124 wxUNICHARREF_TEST_INT_COMPARE
1127 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
1129 void UniCharTestCase::RefwxLongLongCompare()
1131 wxLongLong_t aVal
= 2;
1132 wxLongLong_t bVal
= 3;
1133 wxLongLong_t cVal
= 1;
1135 wxUNICHARREF_TEST_INT_COMPARE
1138 void UniCharTestCase::RefwxULongLongCompare()
1140 wxULongLong_t aVal
= 2;
1141 wxULongLong_t bVal
= 3;
1142 wxULongLong_t cVal
= 1;
1144 wxUNICHARREF_TEST_INT_COMPARE
1149 #if wxWCHAR_T_IS_REAL_TYPE
1151 void UniCharTestCase::RefWideCharCompare()
1157 wxUNICHARREF_TEST_INT_COMPARE