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