1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/strings/unichar.cpp
3 // Purpose: Test for wxUniChar class
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2007 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
24 #include "wx/string.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class UniCharTestCase
: public CppUnit::TestCase
36 CPPUNIT_TEST_SUITE( UniCharTestCase
);
37 CPPUNIT_TEST( CharCompare
);
38 CPPUNIT_TEST( CharCompareIntl
);
39 CPPUNIT_TEST( StringCompare
);
40 CPPUNIT_TEST( ShortCompare
);
41 CPPUNIT_TEST( UnsignedShortCompare
);
42 CPPUNIT_TEST( IntCompare
);
43 CPPUNIT_TEST( UnsignedIntCompare
);
44 CPPUNIT_TEST( LongCompare
);
45 CPPUNIT_TEST( UnsignedLongCompare
);
46 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongCompare
); )
47 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongCompare
); )
48 wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharCompare
); )
49 CPPUNIT_TEST( UniCharAssignmentOperator
);
50 CPPUNIT_TEST( UniCharRefAssignmentOperator
);
51 CPPUNIT_TEST( CharAssignmentOperator
);
52 CPPUNIT_TEST( UnsignedCharAssignmentOperator
);
53 CPPUNIT_TEST( ShortAssignmentOperator
);
54 CPPUNIT_TEST( UnsignedShortAssignmentOperator
);
55 CPPUNIT_TEST( IntAssignmentOperator
);
56 CPPUNIT_TEST( UnsignedIntAssignmentOperator
);
57 CPPUNIT_TEST( LongAssignmentOperator
);
58 CPPUNIT_TEST( UnsignedLongAssignmentOperator
);
59 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongAssignmentOperator
); )
60 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongAssignmentOperator
); )
61 wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharAssignmentOperator
); )
62 CPPUNIT_TEST( CharParenOperator
);
63 CPPUNIT_TEST( UnsignedCharParenOperator
);
64 CPPUNIT_TEST( ShortParenOperator
);
65 CPPUNIT_TEST( UnsignedShortParenOperator
);
66 CPPUNIT_TEST( IntParenOperator
);
67 CPPUNIT_TEST( UnsignedIntParenOperator
);
68 CPPUNIT_TEST( LongParenOperator
);
69 CPPUNIT_TEST( UnsignedLongParenOperator
);
70 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxLongLongParenOperator
); )
71 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( wxULongLongParenOperator
); )
72 wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( WideCharParenOperator
); )
73 CPPUNIT_TEST(RefUniCharAssignmentOperator
);
74 CPPUNIT_TEST(RefUniCharRefAssignmentOperator
);
75 CPPUNIT_TEST(RefCharAssignmentOperator
);
76 CPPUNIT_TEST( RefShortAssignmentOperator
);
77 CPPUNIT_TEST( RefUnsignedShortAssignmentOperator
);
78 CPPUNIT_TEST( RefIntAssignmentOperator
);
79 CPPUNIT_TEST( RefUnsignedIntAssignmentOperator
);
80 CPPUNIT_TEST( RefLongAssignmentOperator
);
81 CPPUNIT_TEST( RefUnsignedLongAssignmentOperator
);
82 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongAssignmentOperator
); )
83 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongAssignmentOperator
); )
84 wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharAssignmentOperator
); )
85 CPPUNIT_TEST(RefCharParenOperator
);
86 CPPUNIT_TEST( RefShortParenOperator
);
87 CPPUNIT_TEST( RefUnsignedShortParenOperator
);
88 CPPUNIT_TEST( RefIntParenOperator
);
89 CPPUNIT_TEST( RefUnsignedIntParenOperator
);
90 CPPUNIT_TEST( RefLongParenOperator
);
91 CPPUNIT_TEST( RefUnsignedLongParenOperator
);
92 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongParenOperator
); )
93 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongParenOperator
); )
94 wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharParenOperator
); )
95 CPPUNIT_TEST( RefShortCompare
);
96 CPPUNIT_TEST( RefUnsignedShortCompare
);
97 CPPUNIT_TEST( RefIntCompare
);
98 CPPUNIT_TEST( RefUnsignedIntCompare
);
99 CPPUNIT_TEST( RefLongCompare
);
100 CPPUNIT_TEST( RefUnsignedLongCompare
);
101 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxLongLongCompare
); )
102 wxIF_LONG_LONG_TYPE( CPPUNIT_TEST( RefwxULongLongCompare
); )
103 wxIF_WCHAR_T_TYPE( CPPUNIT_TEST( RefWideCharCompare
); )
105 CPPUNIT_TEST( StringCompareIntl
);
106 #endif // wxUSE_UNICODE
107 CPPUNIT_TEST_SUITE_END();
110 void CharCompareIntl();
111 void StringCompare();
112 void StringCompareIntl();
114 void UnsignedShortCompare();
116 void UnsignedIntCompare();
118 void UnsignedLongCompare();
119 wxIF_LONG_LONG_TYPE( void wxLongLongCompare(); )
120 wxIF_LONG_LONG_TYPE( void wxULongLongCompare(); )
121 wxIF_WCHAR_T_TYPE( void WideCharCompare(); )
122 void UniCharAssignmentOperator();
123 void UniCharRefAssignmentOperator();
124 void CharAssignmentOperator();
125 void UnsignedCharAssignmentOperator();
126 void ShortAssignmentOperator();
127 void UnsignedShortAssignmentOperator();
128 void IntAssignmentOperator();
129 void UnsignedIntAssignmentOperator();
130 void LongAssignmentOperator();
131 void UnsignedLongAssignmentOperator();
132 wxIF_LONG_LONG_TYPE( void wxLongLongAssignmentOperator(); )
133 wxIF_LONG_LONG_TYPE( void wxULongLongAssignmentOperator(); )
134 wxIF_WCHAR_T_TYPE( void WideCharAssignmentOperator(); )
135 void CharParenOperator();
136 void UnsignedCharParenOperator();
137 void ShortParenOperator();
138 void UnsignedShortParenOperator();
139 void IntParenOperator();
140 void UnsignedIntParenOperator();
141 void LongParenOperator();
142 void UnsignedLongParenOperator();
143 wxIF_LONG_LONG_TYPE( void wxLongLongParenOperator(); )
144 wxIF_LONG_LONG_TYPE( void wxULongLongParenOperator(); )
145 wxIF_WCHAR_T_TYPE( void WideCharParenOperator(); )
146 void RefUniCharAssignmentOperator();
147 void RefUniCharRefAssignmentOperator();
148 void RefCharAssignmentOperator();
149 void RefUnsignedCharAssignmentOperator();
150 void RefShortAssignmentOperator();
151 void RefUnsignedShortAssignmentOperator();
152 void RefIntAssignmentOperator();
153 void RefUnsignedIntAssignmentOperator();
154 void RefLongAssignmentOperator();
155 void RefUnsignedLongAssignmentOperator();
156 wxIF_LONG_LONG_TYPE( void RefwxLongLongAssignmentOperator(); )
157 wxIF_LONG_LONG_TYPE( void RefwxULongLongAssignmentOperator(); )
158 wxIF_WCHAR_T_TYPE( void RefWideCharAssignmentOperator(); )
159 void RefCharParenOperator();
160 void RefUnsignedCharParenOperator();
161 void RefShortParenOperator();
162 void RefUnsignedShortParenOperator();
163 void RefIntParenOperator();
164 void RefUnsignedIntParenOperator();
165 void RefLongParenOperator();
166 void RefUnsignedLongParenOperator();
167 wxIF_LONG_LONG_TYPE( void RefwxLongLongParenOperator(); )
168 wxIF_LONG_LONG_TYPE( void RefwxULongLongParenOperator(); )
169 wxIF_WCHAR_T_TYPE( void RefWideCharParenOperator(); )
170 void RefShortCompare();
171 void RefUnsignedShortCompare();
172 void RefIntCompare();
173 void RefUnsignedIntCompare();
174 void RefLongCompare();
175 void RefUnsignedLongCompare();
176 wxIF_LONG_LONG_TYPE( void RefwxLongLongCompare(); )
177 wxIF_LONG_LONG_TYPE( void RefwxULongLongCompare(); )
178 wxIF_WCHAR_T_TYPE( void RefWideCharCompare(); )
180 DECLARE_NO_COPY_CLASS(UniCharTestCase
)
183 // register in the unnamed registry so that these tests are run by default
184 CPPUNIT_TEST_SUITE_REGISTRATION( UniCharTestCase
);
186 // also include in its own registry so that these tests can be run alone
187 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( UniCharTestCase
, "UniCharTestCase" );
189 void UniCharTestCase::CharCompare()
194 CPPUNIT_ASSERT( a
== a
);
195 CPPUNIT_ASSERT( a
== 'a' );
196 CPPUNIT_ASSERT( a
== wxT('a') );
197 CPPUNIT_ASSERT( a
== wxUniChar('a') );
198 CPPUNIT_ASSERT( a
== wxUniChar(wxT('a')) );
200 CPPUNIT_ASSERT( a
== a
);
201 CPPUNIT_ASSERT( 'a' == a
);
202 CPPUNIT_ASSERT( wxT('a') == a
);
203 CPPUNIT_ASSERT( wxUniChar('a') == a
);
204 CPPUNIT_ASSERT( wxUniChar(wxT('a')) == a
);
206 CPPUNIT_ASSERT( a
!= b
);
207 CPPUNIT_ASSERT( a
!= 'b' );
208 CPPUNIT_ASSERT( a
!= wxT('b') );
209 CPPUNIT_ASSERT( a
!= wxUniChar('b') );
210 CPPUNIT_ASSERT( a
!= wxUniChar(wxT('b')) );
212 CPPUNIT_ASSERT( b
!= a
);
213 CPPUNIT_ASSERT( 'b' != a
);
214 CPPUNIT_ASSERT( wxT('b') != a
);
215 CPPUNIT_ASSERT( wxUniChar('b') != a
);
216 CPPUNIT_ASSERT( wxUniChar(wxT('b')) != a
);
218 CPPUNIT_ASSERT( a
< b
);
219 CPPUNIT_ASSERT( a
< 'b' );
220 CPPUNIT_ASSERT( a
< wxT('b') );
221 CPPUNIT_ASSERT( a
< wxUniChar('b') );
222 CPPUNIT_ASSERT( a
< wxUniChar(wxT('b')) );
224 CPPUNIT_ASSERT( b
> a
);
225 CPPUNIT_ASSERT( 'b' > a
);
226 CPPUNIT_ASSERT( wxT('b') > a
);
227 CPPUNIT_ASSERT( wxUniChar('b') > a
);
228 CPPUNIT_ASSERT( wxUniChar(wxT('b')) > a
);
230 CPPUNIT_ASSERT( a
<= b
);
231 CPPUNIT_ASSERT( a
<= 'b' );
232 CPPUNIT_ASSERT( a
<= wxT('b') );
233 CPPUNIT_ASSERT( a
<= wxUniChar('b') );
234 CPPUNIT_ASSERT( a
<= wxUniChar(wxT('b')) );
236 CPPUNIT_ASSERT( b
>= a
);
237 CPPUNIT_ASSERT( 'b' >= a
);
238 CPPUNIT_ASSERT( wxT('b') >= a
);
239 CPPUNIT_ASSERT( wxUniChar('b') >= a
);
240 CPPUNIT_ASSERT( wxUniChar(wxT('b')) >= a
);
242 CPPUNIT_ASSERT( a
<= a
);
243 CPPUNIT_ASSERT( a
<= 'a' );
244 CPPUNIT_ASSERT( a
<= wxT('a') );
245 CPPUNIT_ASSERT( a
<= wxUniChar('a') );
246 CPPUNIT_ASSERT( a
<= wxUniChar(wxT('a')) );
248 CPPUNIT_ASSERT( a
>= a
);
249 CPPUNIT_ASSERT( 'a' >= a
);
250 CPPUNIT_ASSERT( wxT('a') >= a
);
251 CPPUNIT_ASSERT( wxUniChar('a') >= a
);
252 CPPUNIT_ASSERT( wxUniChar(wxT('a')) >= a
);
254 CPPUNIT_ASSERT( b
> a
);
255 CPPUNIT_ASSERT( b
> 'a' );
256 CPPUNIT_ASSERT( b
> wxT('a') );
257 CPPUNIT_ASSERT( b
> wxUniChar('a') );
258 CPPUNIT_ASSERT( b
> wxUniChar(wxT('a')) );
260 CPPUNIT_ASSERT( a
< b
);
261 CPPUNIT_ASSERT( 'a' < b
);
262 CPPUNIT_ASSERT( wxT('a') < b
);
263 CPPUNIT_ASSERT( wxUniChar('a') < b
);
264 CPPUNIT_ASSERT( wxUniChar(wxT('a')) < b
);
266 CPPUNIT_ASSERT( b
>= a
);
267 CPPUNIT_ASSERT( b
>= 'a' );
268 CPPUNIT_ASSERT( b
>= wxT('a') );
269 CPPUNIT_ASSERT( b
>= wxUniChar('a') );
270 CPPUNIT_ASSERT( b
>= wxUniChar(wxT('a')) );
272 CPPUNIT_ASSERT( a
<= b
);
273 CPPUNIT_ASSERT( 'a' <= b
);
274 CPPUNIT_ASSERT( wxT('a') <= b
);
275 CPPUNIT_ASSERT( wxUniChar('a') <= b
);
276 CPPUNIT_ASSERT( wxUniChar(wxT('a')) <= b
);
278 CPPUNIT_ASSERT( b
>= b
);
279 CPPUNIT_ASSERT( b
>= 'b' );
280 CPPUNIT_ASSERT( b
>= wxT('b') );
281 CPPUNIT_ASSERT( b
>= wxUniChar('b') );
282 CPPUNIT_ASSERT( b
>= wxUniChar(wxT('b')) );
284 CPPUNIT_ASSERT( b
<= b
);
285 CPPUNIT_ASSERT( 'b' <= b
);
286 CPPUNIT_ASSERT( wxT('b') <= b
);
287 CPPUNIT_ASSERT( wxUniChar('b') <= b
);
288 CPPUNIT_ASSERT( wxUniChar(wxT('b')) <= b
);
290 CPPUNIT_ASSERT( b
- a
== 1 );
291 CPPUNIT_ASSERT( a
- b
== -1 );
295 #define CYRILLIC_SMALL_LETTER_YU ((wchar_t)0x044E)
296 #define ARABIC_LETTER_NOON ((wchar_t)0x0646)
298 void UniCharTestCase::CharCompareIntl()
300 wxUniChar
a(CYRILLIC_SMALL_LETTER_YU
);
301 wxUniChar
b(ARABIC_LETTER_NOON
);
303 CPPUNIT_ASSERT( a
== a
);
304 CPPUNIT_ASSERT( a
== CYRILLIC_SMALL_LETTER_YU
);
305 CPPUNIT_ASSERT( a
== wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
307 CPPUNIT_ASSERT( a
!= b
);
308 CPPUNIT_ASSERT( a
!= ARABIC_LETTER_NOON
);
309 CPPUNIT_ASSERT( a
!= wxUniChar(ARABIC_LETTER_NOON
) );
311 CPPUNIT_ASSERT( a
< b
);
312 CPPUNIT_ASSERT( a
< ARABIC_LETTER_NOON
);
313 CPPUNIT_ASSERT( a
< wxUniChar(ARABIC_LETTER_NOON
) );
315 CPPUNIT_ASSERT( a
<= b
);
316 CPPUNIT_ASSERT( a
<= ARABIC_LETTER_NOON
);
317 CPPUNIT_ASSERT( a
<= wxUniChar(ARABIC_LETTER_NOON
) );
319 CPPUNIT_ASSERT( a
<= a
);
320 CPPUNIT_ASSERT( a
<= CYRILLIC_SMALL_LETTER_YU
);
321 CPPUNIT_ASSERT( a
<= wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
323 CPPUNIT_ASSERT( b
> a
);
324 CPPUNIT_ASSERT( b
> CYRILLIC_SMALL_LETTER_YU
);
325 CPPUNIT_ASSERT( b
> wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
327 CPPUNIT_ASSERT( b
>= a
);
328 CPPUNIT_ASSERT( b
>= CYRILLIC_SMALL_LETTER_YU
);
329 CPPUNIT_ASSERT( b
>= wxUniChar(CYRILLIC_SMALL_LETTER_YU
) );
331 CPPUNIT_ASSERT( b
>= b
);
332 CPPUNIT_ASSERT( b
>= ARABIC_LETTER_NOON
);
333 CPPUNIT_ASSERT( b
>= wxUniChar(ARABIC_LETTER_NOON
) );
335 CPPUNIT_ASSERT( b
- a
== 504 );
336 CPPUNIT_ASSERT( a
- b
== -504 );
339 void UniCharTestCase::StringCompare()
341 // test string comparison with chars
343 const wxString sb
= "b";
345 wchar_t c2
= wxT('a');
348 CPPUNIT_ASSERT( sa
== 'a');
349 CPPUNIT_ASSERT( 'a' == sa
);
350 CPPUNIT_ASSERT( sb
!= 'a');
351 CPPUNIT_ASSERT( 'a' != sb
);
353 CPPUNIT_ASSERT( sa
== c1
);
354 CPPUNIT_ASSERT( c1
== sa
);
355 CPPUNIT_ASSERT( sb
!= c1
);
356 CPPUNIT_ASSERT( c1
!= sb
);
358 CPPUNIT_ASSERT( sa
== c2
);
359 CPPUNIT_ASSERT( c2
== sa
);
360 CPPUNIT_ASSERT( sb
!= c2
);
361 CPPUNIT_ASSERT( c2
!= sb
);
363 CPPUNIT_ASSERT( sa
== c3
);
364 CPPUNIT_ASSERT( c3
== sa
);
365 CPPUNIT_ASSERT( sb
!= c3
);
366 CPPUNIT_ASSERT( c3
!= sb
);
368 // test wxUniCharRef:
369 CPPUNIT_ASSERT( sa
== sa
[0]);
370 CPPUNIT_ASSERT( sa
[0] == sa
);
371 CPPUNIT_ASSERT( sb
!= sa
[0]);
372 CPPUNIT_ASSERT( sa
[0] != sb
);
374 // test const version of operator[] (returns wxUniChar, not wxUniCharRef):
375 CPPUNIT_ASSERT( sb
== sb
[0]);
376 CPPUNIT_ASSERT( sb
[0] == sb
);
377 CPPUNIT_ASSERT( sa
!= sb
[0]);
378 CPPUNIT_ASSERT( sb
[0] != sa
);
382 void UniCharTestCase::StringCompareIntl()
384 // test string comparison with chars
385 wxString sa
= CYRILLIC_SMALL_LETTER_YU
;
386 const wxString sb
= ARABIC_LETTER_NOON
;
387 wchar_t c2
= CYRILLIC_SMALL_LETTER_YU
;
388 wxUniChar c3
= CYRILLIC_SMALL_LETTER_YU
;
390 CPPUNIT_ASSERT( sa
== CYRILLIC_SMALL_LETTER_YU
);
391 CPPUNIT_ASSERT( CYRILLIC_SMALL_LETTER_YU
== sa
);
392 CPPUNIT_ASSERT( sb
!= CYRILLIC_SMALL_LETTER_YU
);
393 CPPUNIT_ASSERT( CYRILLIC_SMALL_LETTER_YU
!= sb
);
395 CPPUNIT_ASSERT( sa
== c2
);
396 CPPUNIT_ASSERT( c2
== sa
);
397 CPPUNIT_ASSERT( sb
!= c2
);
398 CPPUNIT_ASSERT( c2
!= sb
);
400 CPPUNIT_ASSERT( sa
== c3
);
401 CPPUNIT_ASSERT( c3
== sa
);
402 CPPUNIT_ASSERT( sb
!= c3
);
403 CPPUNIT_ASSERT( c3
!= sb
);
405 // test wxUniCharRef:
406 CPPUNIT_ASSERT( sa
== sa
[0]);
407 CPPUNIT_ASSERT( sa
[0] == sa
);
408 CPPUNIT_ASSERT( sb
!= sa
[0]);
409 CPPUNIT_ASSERT( sa
[0] != sb
);
411 // test const version of operator[] (returns wxUniChar, not wxUniCharRef):
412 CPPUNIT_ASSERT( sb
== sb
[0]);
413 CPPUNIT_ASSERT( sb
[0] == sb
);
414 CPPUNIT_ASSERT( sa
!= sb
[0]);
415 CPPUNIT_ASSERT( sb
[0] != sa
);
417 #endif // wxUSE_UNICODE
419 #define wxUNICHAR_TEST_INT_COMPARE \
421 CPPUNIT_ASSERT( a == aVal ); \
422 CPPUNIT_ASSERT( a != bVal ); \
423 CPPUNIT_ASSERT( a < bVal ); \
424 CPPUNIT_ASSERT( a <= bVal ); \
425 CPPUNIT_ASSERT( a > cVal ); \
426 CPPUNIT_ASSERT( a >= cVal );
429 void UniCharTestCase::ShortCompare()
435 wxUNICHAR_TEST_INT_COMPARE
438 void UniCharTestCase::UnsignedShortCompare()
440 unsigned short aVal
= 2;
441 unsigned short bVal
= 3;
442 unsigned short cVal
= 1;
444 wxUNICHAR_TEST_INT_COMPARE
447 void UniCharTestCase::IntCompare()
453 wxUNICHAR_TEST_INT_COMPARE
456 void UniCharTestCase::UnsignedIntCompare()
458 unsigned int aVal
= 2;
459 unsigned int bVal
= 3;
460 unsigned int cVal
= 1;
462 wxUNICHAR_TEST_INT_COMPARE
465 void UniCharTestCase::LongCompare()
471 wxUNICHAR_TEST_INT_COMPARE
474 void UniCharTestCase::UnsignedLongCompare()
476 unsigned long aVal
= 2;
477 unsigned long bVal
= 3;
478 unsigned long cVal
= 1;
480 wxUNICHAR_TEST_INT_COMPARE
483 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
485 void UniCharTestCase::wxLongLongCompare()
487 wxLongLong_t aVal
= 2;
488 wxLongLong_t bVal
= 3;
489 wxLongLong_t cVal
= 1;
491 wxUNICHAR_TEST_INT_COMPARE
494 void UniCharTestCase::wxULongLongCompare()
496 wxULongLong_t aVal
= 2;
497 wxULongLong_t bVal
= 3;
498 wxULongLong_t cVal
= 1;
500 wxUNICHAR_TEST_INT_COMPARE
505 #if wxWCHAR_T_IS_REAL_TYPE
507 void UniCharTestCase::WideCharCompare()
513 wxUNICHAR_TEST_INT_COMPARE
518 #undef wxUNICHAR_TEST_INT_COMPARE
520 #define wxUNICHAR_TEST_ASSIGNMENT_OPERATOR \
524 CPPUNIT_ASSERT(a == b);
526 void UniCharTestCase::UniCharAssignmentOperator()
531 CPPUNIT_ASSERT(a
== b
);
534 void UniCharTestCase::UniCharRefAssignmentOperator()
539 wxUniCharRef bRef
= bStr
[0];
541 CPPUNIT_ASSERT(a
== b
);
544 void UniCharTestCase::CharAssignmentOperator()
548 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
551 void UniCharTestCase::UnsignedCharAssignmentOperator()
553 unsigned char bVal
= 2;
555 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
558 void UniCharTestCase::ShortAssignmentOperator()
562 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
565 void UniCharTestCase::UnsignedShortAssignmentOperator()
567 unsigned short bVal
= 2;
569 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
572 void UniCharTestCase::IntAssignmentOperator()
576 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
579 void UniCharTestCase::UnsignedIntAssignmentOperator()
581 unsigned int bVal
= 2;
583 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
586 void UniCharTestCase::LongAssignmentOperator()
590 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
593 void UniCharTestCase::UnsignedLongAssignmentOperator()
595 unsigned long bVal
= 2;
597 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
600 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
602 void UniCharTestCase::wxLongLongAssignmentOperator()
604 wxLongLong_t bVal
= 2;
606 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
609 void UniCharTestCase::wxULongLongAssignmentOperator()
611 wxULongLong_t bVal
= 2;
613 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
618 #if wxWCHAR_T_IS_REAL_TYPE
620 void UniCharTestCase::WideCharAssignmentOperator()
624 wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
629 #undef wxUNICHAR_TEST_ASSIGNMENT_OPERATOR
631 void UniCharTestCase::CharParenOperator()
638 CPPUNIT_ASSERT(aVal
== bVal
);
641 void UniCharTestCase::UnsignedCharParenOperator()
644 unsigned char bVal
= 'b';
647 aVal
= (unsigned char) b
;
648 CPPUNIT_ASSERT(aVal
== bVal
);
651 void UniCharTestCase::ShortParenOperator()
658 CPPUNIT_ASSERT(aVal
== bVal
);
661 void UniCharTestCase::UnsignedShortParenOperator()
664 unsigned short bVal
= 2;
667 aVal
= (unsigned short) b
;
668 CPPUNIT_ASSERT(aVal
== bVal
);
671 void UniCharTestCase::IntParenOperator()
678 CPPUNIT_ASSERT(aVal
== bVal
);
682 void UniCharTestCase::UnsignedIntParenOperator()
685 unsigned int bVal
= 2;
688 aVal
= (unsigned int) b
;
689 CPPUNIT_ASSERT(aVal
== bVal
);
692 void UniCharTestCase::LongParenOperator()
699 CPPUNIT_ASSERT(aVal
== bVal
);
702 void UniCharTestCase::UnsignedLongParenOperator()
705 unsigned long bVal
= 2;
708 aVal
= (unsigned long) b
;
709 CPPUNIT_ASSERT(aVal
== bVal
);
712 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
714 void UniCharTestCase::wxLongLongParenOperator()
717 wxLongLong_t bVal
= 2;
720 aVal
= (wxLongLong_t
) b
;
721 CPPUNIT_ASSERT(aVal
== bVal
);
724 void UniCharTestCase::wxULongLongParenOperator()
727 wxULongLong_t bVal
= 2;
730 aVal
= (wxULongLong_t
) b
;
731 CPPUNIT_ASSERT(aVal
== bVal
);
736 #if wxWCHAR_T_IS_REAL_TYPE
738 void UniCharTestCase::WideCharParenOperator()
745 CPPUNIT_ASSERT(aVal
== bVal
);
750 void UniCharTestCase::RefUniCharAssignmentOperator()
752 wxString
dummyStr('0');
753 wxUniCharRef bRef
= dummyStr
[0];
759 CPPUNIT_ASSERT(bRef
== b
);
762 void UniCharTestCase::RefUniCharRefAssignmentOperator()
766 wxUniCharRef testRef
= testStr
[0];
768 wxString
dummyStr('0');
769 wxUniCharRef bRef
= dummyStr
[0];
773 CPPUNIT_ASSERT(bRef
== testRef
);
776 void UniCharTestCase::RefCharAssignmentOperator()
778 wxString
dummyStr('0');
779 wxUniCharRef bRef
= dummyStr
[0];
784 CPPUNIT_ASSERT(bRef
== b
);
787 void UniCharTestCase::RefUnsignedCharAssignmentOperator()
789 wxString
dummyStr('0');
790 wxUniCharRef bRef
= dummyStr
[0];
792 unsigned char b
= 'b';
795 CPPUNIT_ASSERT(bRef
== b
);
798 void UniCharTestCase::RefShortAssignmentOperator()
800 wxString
dummyStr('0');
801 wxUniCharRef bRef
= dummyStr
[0];
806 CPPUNIT_ASSERT(bRef
== b
);
809 void UniCharTestCase::RefUnsignedShortAssignmentOperator()
811 wxString
dummyStr('0');
812 wxUniCharRef bRef
= dummyStr
[0];
814 unsigned short b
= 2;
817 CPPUNIT_ASSERT(bRef
== b
);
820 void UniCharTestCase::RefIntAssignmentOperator()
822 wxString
dummyStr('0');
823 wxUniCharRef bRef
= dummyStr
[0];
828 CPPUNIT_ASSERT(bRef
== b
);
831 void UniCharTestCase::RefUnsignedIntAssignmentOperator()
833 wxString
dummyStr('0');
834 wxUniCharRef bRef
= dummyStr
[0];
839 CPPUNIT_ASSERT(bRef
== b
);
842 void UniCharTestCase::RefLongAssignmentOperator()
844 wxString
dummyStr('0');
845 wxUniCharRef bRef
= dummyStr
[0];
850 CPPUNIT_ASSERT(bRef
== b
);
853 void UniCharTestCase::RefUnsignedLongAssignmentOperator()
855 wxString
dummyStr('0');
856 wxUniCharRef bRef
= dummyStr
[0];
861 CPPUNIT_ASSERT(bRef
== b
);
864 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
866 void UniCharTestCase::RefwxLongLongAssignmentOperator()
868 wxString
dummyStr('0');
869 wxUniCharRef bRef
= dummyStr
[0];
874 CPPUNIT_ASSERT(bRef
== b
);
876 void UniCharTestCase::RefwxULongLongAssignmentOperator()
878 wxString
dummyStr('0');
879 wxUniCharRef bRef
= dummyStr
[0];
884 CPPUNIT_ASSERT(bRef
== b
);
889 #if wxWCHAR_T_IS_REAL_TYPE
891 void UniCharTestCase::RefWideCharAssignmentOperator()
893 wxString
dummyStr('0');
894 wxUniCharRef bRef
= dummyStr
[0];
899 CPPUNIT_ASSERT(bRef
== b
);
904 void UniCharTestCase::RefCharParenOperator()
908 wxString
testStr(bVal
);
909 wxUniCharRef bRef
= testStr
[0];
912 CPPUNIT_ASSERT(aVal
== bVal
);
915 void UniCharTestCase::RefUnsignedCharParenOperator()
918 unsigned char bVal
= 'b';
919 wxString testStr
= wxString::Format(wxT("%u"), bVal
);
920 wxUniCharRef bRef
= testStr
[0];
922 aVal
= (unsigned char) bRef
;
923 CPPUNIT_ASSERT(aVal
== bVal
);
926 void UniCharTestCase::RefShortParenOperator()
932 wxString
dummyStr("0");
933 wxUniCharRef bRef
= dummyStr
[0];
937 CPPUNIT_ASSERT(aVal
== bVal
);
940 void UniCharTestCase::RefUnsignedShortParenOperator()
943 unsigned short bVal
= 2;
946 wxString
dummyStr("0");
947 wxUniCharRef bRef
= dummyStr
[0];
950 aVal
= (unsigned short) bRef
;
951 CPPUNIT_ASSERT(aVal
== bVal
);
954 void UniCharTestCase::RefIntParenOperator()
960 wxString
dummyStr("0");
961 wxUniCharRef bRef
= dummyStr
[0];
965 CPPUNIT_ASSERT(aVal
== bVal
);
968 void UniCharTestCase::RefUnsignedIntParenOperator()
971 unsigned int bVal
= 2;
974 wxString
dummyStr("0");
975 wxUniCharRef bRef
= dummyStr
[0];
978 aVal
= (unsigned int) bRef
;
979 CPPUNIT_ASSERT(aVal
== bVal
);
982 void UniCharTestCase::RefLongParenOperator()
988 wxString
dummyStr("0");
989 wxUniCharRef bRef
= dummyStr
[0];
993 CPPUNIT_ASSERT(aVal
== bVal
);
996 void UniCharTestCase::RefUnsignedLongParenOperator()
999 unsigned long bVal
= 2;
1002 wxString
dummyStr("0");
1003 wxUniCharRef bRef
= dummyStr
[0];
1006 aVal
= (unsigned long) bRef
;
1007 CPPUNIT_ASSERT(aVal
== bVal
);
1010 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
1012 void UniCharTestCase::RefwxLongLongParenOperator()
1015 wxLongLong_t bVal
= 2;
1018 wxString
dummyStr("0");
1019 wxUniCharRef bRef
= dummyStr
[0];
1022 aVal
= (wxLongLong_t
) bRef
;
1023 CPPUNIT_ASSERT(aVal
== bVal
);
1026 void UniCharTestCase::RefwxULongLongParenOperator()
1029 wxULongLong_t bVal
= 2;
1032 wxString
dummyStr("0");
1033 wxUniCharRef bRef
= dummyStr
[0];
1036 aVal
= (wxULongLong_t
) bRef
;
1037 CPPUNIT_ASSERT(aVal
== bVal
);
1042 #if wxWCHAR_T_IS_REAL_TYPE
1044 void UniCharTestCase::RefWideCharParenOperator()
1050 wxString
dummyStr("0");
1051 wxUniCharRef bRef
= dummyStr
[0];
1054 aVal
= (wxLongLong_t
) bRef
;
1055 CPPUNIT_ASSERT(aVal
== bVal
);
1060 #define wxUNICHARREF_TEST_INT_COMPARE \
1061 wxUniChar a(aVal); \
1062 wxString dummyStr("0"); \
1063 wxUniCharRef aRef = dummyStr[0]; \
1065 CPPUNIT_ASSERT( aRef == aVal ); \
1066 CPPUNIT_ASSERT( aRef != bVal ); \
1067 CPPUNIT_ASSERT( aRef < bVal ); \
1068 CPPUNIT_ASSERT( aRef <= bVal ); \
1069 CPPUNIT_ASSERT( aRef > cVal ); \
1070 CPPUNIT_ASSERT( aRef >= cVal );
1072 void UniCharTestCase::RefShortCompare()
1078 wxUNICHARREF_TEST_INT_COMPARE
1081 void UniCharTestCase::RefUnsignedShortCompare()
1083 unsigned short aVal
= 2;
1084 unsigned short bVal
= 3;
1085 unsigned short cVal
= 1;
1087 wxUNICHARREF_TEST_INT_COMPARE
1090 void UniCharTestCase::RefIntCompare()
1096 wxUNICHARREF_TEST_INT_COMPARE
1099 void UniCharTestCase::RefUnsignedIntCompare()
1101 unsigned int aVal
= 2;
1102 unsigned int bVal
= 3;
1103 unsigned int cVal
= 1;
1105 wxUNICHARREF_TEST_INT_COMPARE
1108 void UniCharTestCase::RefLongCompare()
1114 wxUNICHARREF_TEST_INT_COMPARE
1117 void UniCharTestCase::RefUnsignedLongCompare()
1119 unsigned long aVal
= 2;
1120 unsigned long bVal
= 3;
1121 unsigned long cVal
= 1;
1123 wxUNICHARREF_TEST_INT_COMPARE
1126 #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
1128 void UniCharTestCase::RefwxLongLongCompare()
1130 wxLongLong_t aVal
= 2;
1131 wxLongLong_t bVal
= 3;
1132 wxLongLong_t cVal
= 1;
1134 wxUNICHARREF_TEST_INT_COMPARE
1137 void UniCharTestCase::RefwxULongLongCompare()
1139 wxULongLong_t aVal
= 2;
1140 wxULongLong_t bVal
= 3;
1141 wxULongLong_t cVal
= 1;
1143 wxUNICHARREF_TEST_INT_COMPARE
1148 #if wxWCHAR_T_IS_REAL_TYPE
1150 void UniCharTestCase::RefWideCharCompare()
1156 wxUNICHARREF_TEST_INT_COMPARE