OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2014, International Business Machines Corporation and | 3 * Copyright (c) 1997-2015, International Business Machines Corporation and |
4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
5 ********************************************************************/ | 5 ********************************************************************/ |
6 | 6 |
7 | 7 |
8 /** | 8 /** |
9 * IntlTestUtilities is the medium level test class for everything in the direct
ory "utility". | 9 * IntlTestUtilities is the medium level test class for everything in the direct
ory "utility". |
10 */ | 10 */ |
11 | 11 |
12 #include "unicode/utypes.h" | 12 #include "unicode/utypes.h" |
13 #include "unicode/errorcode.h" | 13 #include "unicode/errorcode.h" |
14 #include "unicode/localpointer.h" | 14 #include "unicode/localpointer.h" |
| 15 #include "charstr.h" |
15 #include "itutil.h" | 16 #include "itutil.h" |
16 #include "strtest.h" | 17 #include "strtest.h" |
17 #include "loctest.h" | 18 #include "loctest.h" |
18 #include "citrtest.h" | 19 #include "citrtest.h" |
19 #include "ustrtest.h" | 20 #include "ustrtest.h" |
20 #include "ucdtest.h" | 21 #include "ucdtest.h" |
21 #include "restest.h" | 22 #include "restest.h" |
22 #include "restsnew.h" | 23 #include "restsnew.h" |
23 #include "tsmthred.h" | 24 #include "tsmthred.h" |
24 #include "tsputil.h" | 25 #include "tsputil.h" |
25 #include "uobjtest.h" | 26 #include "uobjtest.h" |
26 #include "utxttest.h" | 27 #include "utxttest.h" |
27 #include "v32test.h" | 28 #include "v32test.h" |
28 #include "uvectest.h" | 29 #include "uvectest.h" |
29 #include "aliastst.h" | 30 #include "aliastst.h" |
30 #include "usettest.h" | 31 #include "usettest.h" |
31 | 32 |
32 extern IntlTest *createBytesTrieTest(); | 33 extern IntlTest *createBytesTrieTest(); |
33 static IntlTest *createLocalPointerTest(); | 34 static IntlTest *createLocalPointerTest(); |
34 extern IntlTest *createUCharsTrieTest(); | 35 extern IntlTest *createUCharsTrieTest(); |
35 static IntlTest *createEnumSetTest(); | 36 static IntlTest *createEnumSetTest(); |
36 extern IntlTest *createSimplePatternFormatterTest(); | 37 extern IntlTest *createSimplePatternFormatterTest(); |
37 extern IntlTest *createUnifiedCacheTest(); | 38 extern IntlTest *createUnifiedCacheTest(); |
38 extern IntlTest *createQuantityFormatterTest(); | 39 extern IntlTest *createQuantityFormatterTest(); |
| 40 extern IntlTest *createPluralMapTest(); |
| 41 |
39 | 42 |
40 #define CASE(id, test) case id: \ | 43 #define CASE(id, test) case id: \ |
41 name = #test; \ | 44 name = #test; \ |
42 if (exec) { \ | 45 if (exec) { \ |
43 logln(#test "---"); logln(); \ | 46 logln(#test "---"); logln(); \ |
44 test t; \ | 47 test t; \ |
45 callTest(t, par); \ | 48 callTest(t, par); \ |
46 } \ | 49 } \ |
47 break | 50 break |
48 | 51 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 callTest(*test, par); | 117 callTest(*test, par); |
115 } | 118 } |
116 break; | 119 break; |
117 case 22: | 120 case 22: |
118 name = "QuantityFormatterTest"; | 121 name = "QuantityFormatterTest"; |
119 if (exec) { | 122 if (exec) { |
120 logln("TestSuite QuantityFormatterTest---"); logln(); | 123 logln("TestSuite QuantityFormatterTest---"); logln(); |
121 LocalPointer<IntlTest> test(createQuantityFormatterTest()); | 124 LocalPointer<IntlTest> test(createQuantityFormatterTest()); |
122 callTest(*test, par); | 125 callTest(*test, par); |
123 } | 126 } |
| 127 case 23: |
| 128 name = "PluralMapTest"; |
| 129 if (exec) { |
| 130 logln("TestSuite PluralMapTest---"); logln(); |
| 131 LocalPointer<IntlTest> test(createPluralMapTest()); |
| 132 callTest(*test, par); |
| 133 } |
124 break; | 134 break; |
125 default: name = ""; break; //needed to end loop | 135 default: name = ""; break; //needed to end loop |
126 } | 136 } |
127 } | 137 } |
128 | 138 |
129 void ErrorCodeTest::runIndexedTest(int32_t index, UBool exec, const char* &name,
char* /*par*/) { | 139 void ErrorCodeTest::runIndexedTest(int32_t index, UBool exec, const char* &name,
char* /*par*/) { |
130 if (exec) logln("TestSuite Utilities: "); | 140 if (exec) logln("TestSuite Utilities: "); |
131 switch (index) { | 141 switch (index) { |
132 case 0: name = "TestErrorCode"; if (exec) TestErrorCode(); break; | 142 case 0: name = "TestErrorCode"; if (exec) TestErrorCode(); break; |
133 case 1: name = "TestSubclass"; if (exec) TestSubclass(); break; | 143 case 1: name = "TestSubclass"; if (exec) TestSubclass(); break; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 252 } |
243 } | 253 } |
244 | 254 |
245 class LocalPointerTest : public IntlTest { | 255 class LocalPointerTest : public IntlTest { |
246 public: | 256 public: |
247 LocalPointerTest() {} | 257 LocalPointerTest() {} |
248 | 258 |
249 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=
NULL); | 259 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=
NULL); |
250 | 260 |
251 void TestLocalPointer(); | 261 void TestLocalPointer(); |
| 262 void TestLocalPointerMoveSwap(); |
252 void TestLocalArray(); | 263 void TestLocalArray(); |
| 264 void TestLocalArrayMoveSwap(); |
253 void TestLocalXyzPointer(); | 265 void TestLocalXyzPointer(); |
| 266 void TestLocalXyzPointerMoveSwap(); |
254 void TestLocalXyzPointerNull(); | 267 void TestLocalXyzPointerNull(); |
255 }; | 268 }; |
256 | 269 |
257 static IntlTest *createLocalPointerTest() { | 270 static IntlTest *createLocalPointerTest() { |
258 return new LocalPointerTest(); | 271 return new LocalPointerTest(); |
259 } | 272 } |
260 | 273 |
261 void LocalPointerTest::runIndexedTest(int32_t index, UBool exec, const char *&na
me, char * /*par*/) { | 274 void LocalPointerTest::runIndexedTest(int32_t index, UBool exec, const char *&na
me, char * /*par*/) { |
262 if(exec) { | 275 if(exec) { |
263 logln("TestSuite LocalPointerTest: "); | 276 logln("TestSuite LocalPointerTest: "); |
264 } | 277 } |
265 switch (index) { | 278 TESTCASE_AUTO_BEGIN; |
266 TESTCASE(0, TestLocalPointer); | 279 TESTCASE_AUTO(TestLocalPointer); |
267 TESTCASE(1, TestLocalArray); | 280 TESTCASE_AUTO(TestLocalPointerMoveSwap); |
268 TESTCASE(2, TestLocalXyzPointer); | 281 TESTCASE_AUTO(TestLocalArray); |
269 TESTCASE(3, TestLocalXyzPointerNull); | 282 TESTCASE_AUTO(TestLocalArrayMoveSwap); |
270 default: | 283 TESTCASE_AUTO(TestLocalXyzPointer); |
271 name=""; | 284 TESTCASE_AUTO(TestLocalXyzPointerMoveSwap); |
272 break; // needed to end the loop | 285 TESTCASE_AUTO(TestLocalXyzPointerNull); |
273 } | 286 TESTCASE_AUTO_END; |
274 } | 287 } |
275 | 288 |
276 // Exercise every LocalPointer and LocalPointerBase method. | 289 // Exercise almost every LocalPointer and LocalPointerBase method. |
277 void LocalPointerTest::TestLocalPointer() { | 290 void LocalPointerTest::TestLocalPointer() { |
278 // constructor | 291 // constructor |
279 LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005)); | 292 LocalPointer<UnicodeString> s(new UnicodeString((UChar32)0x50005)); |
280 // isNULL(), isValid(), operator==(), operator!=() | 293 // isNULL(), isValid(), operator==(), operator!=() |
281 if(s.isNull() || !s.isValid() || s==NULL || !(s!=NULL)) { | 294 if(s.isNull() || !s.isValid() || s==NULL || !(s!=NULL)) { |
282 errln("LocalPointer constructor or NULL test failure"); | 295 errln("LocalPointer constructor or NULL test failure"); |
283 return; | 296 return; |
284 } | 297 } |
285 // getAlias(), operator->, operator* | 298 // getAlias(), operator->, operator* |
286 if(s.getAlias()->length()!=2 || s->length()!=2 || (*s).length()!=2) { | 299 if(s.getAlias()->length()!=2 || s->length()!=2 || (*s).length()!=2) { |
287 errln("LocalPointer access failure"); | 300 errln("LocalPointer access failure"); |
288 } | 301 } |
289 // adoptInstead(), orphan() | 302 // adoptInstead(), orphan() |
290 s.adoptInstead(new UnicodeString((UChar)0xfffc)); | 303 s.adoptInstead(new UnicodeString((UChar)0xfffc)); |
291 if(s->length()!=1) { | 304 if(s->length()!=1) { |
292 errln("LocalPointer adoptInstead(U+FFFC) failure"); | 305 errln("LocalPointer adoptInstead(U+FFFC) failure"); |
293 } | 306 } |
294 UnicodeString *orphan=s.orphan(); | 307 UnicodeString *orphan=s.orphan(); |
295 if(orphan==NULL || orphan->length()!=1 || s.isValid() || s!=NULL) { | 308 if(orphan==NULL || orphan->length()!=1 || s.isValid() || s!=NULL) { |
296 errln("LocalPointer orphan() failure"); | 309 errln("LocalPointer orphan() failure"); |
297 } | 310 } |
298 delete orphan; | 311 delete orphan; |
299 // destructor | |
300 s.adoptInstead(new UnicodeString()); | 312 s.adoptInstead(new UnicodeString()); |
301 if(s->length()!=0) { | 313 if(s->length()!=0) { |
302 errln("LocalPointer adoptInstead(empty) failure"); | 314 errln("LocalPointer adoptInstead(empty) failure"); |
303 } | 315 } |
| 316 |
| 317 // LocalPointer(p, errorCode) sets U_MEMORY_ALLOCATION_ERROR if p==NULL. |
| 318 UErrorCode errorCode = U_ZERO_ERROR; |
| 319 LocalPointer<CharString> cs(new CharString("some chars", errorCode), errorCo
de); |
| 320 if(cs.isNull() && U_SUCCESS(errorCode)) { |
| 321 errln("LocalPointer(p, errorCode) failure"); |
| 322 return; |
| 323 } |
| 324 errorCode = U_ZERO_ERROR; |
| 325 cs.adoptInsteadAndCheckErrorCode(new CharString("different chars", errorCode
), errorCode); |
| 326 if(cs.isNull() && U_SUCCESS(errorCode)) { |
| 327 errln("adoptInsteadAndCheckErrorCode(p, errorCode) failure"); |
| 328 return; |
| 329 } |
| 330 // Incoming failure: Keep the current object and delete the input object. |
| 331 errorCode = U_ILLEGAL_ARGUMENT_ERROR; |
| 332 cs.adoptInsteadAndCheckErrorCode(new CharString("unused", errorCode), errorC
ode); |
| 333 if(cs.isValid() && strcmp(cs->data(), "different chars") != 0) { |
| 334 errln("adoptInsteadAndCheckErrorCode(p, U_FAILURE) did not retain the ol
d object"); |
| 335 return; |
| 336 } |
| 337 errorCode = U_ZERO_ERROR; |
| 338 cs.adoptInsteadAndCheckErrorCode(NULL, errorCode); |
| 339 if(errorCode != U_MEMORY_ALLOCATION_ERROR) { |
| 340 errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) did not set U_MEMO
RY_ALLOCATION_ERROR"); |
| 341 return; |
| 342 } |
| 343 if(cs.isValid()) { |
| 344 errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) kept the object"); |
| 345 return; |
| 346 } |
| 347 errorCode = U_ZERO_ERROR; |
| 348 LocalPointer<CharString> null(NULL, errorCode); |
| 349 if(errorCode != U_MEMORY_ALLOCATION_ERROR) { |
| 350 errln("LocalPointer(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERR
OR"); |
| 351 return; |
| 352 } |
| 353 |
| 354 // destructor |
304 } | 355 } |
305 | 356 |
306 // Exercise every LocalArray method (but not LocalPointerBase). | 357 void LocalPointerTest::TestLocalPointerMoveSwap() { |
| 358 UnicodeString *p1 = new UnicodeString((UChar)0x61); |
| 359 UnicodeString *p2 = new UnicodeString((UChar)0x62); |
| 360 LocalPointer<UnicodeString> s1(p1); |
| 361 LocalPointer<UnicodeString> s2(p2); |
| 362 s1.swap(s2); |
| 363 if(s1.getAlias() != p2 || s2.getAlias() != p1) { |
| 364 errln("LocalPointer.swap() did not swap"); |
| 365 } |
| 366 swap(s1, s2); |
| 367 if(s1.getAlias() != p1 || s2.getAlias() != p2) { |
| 368 errln("swap(LocalPointer) did not swap back"); |
| 369 } |
| 370 LocalPointer<UnicodeString> s3; |
| 371 s3.moveFrom(s1); |
| 372 if(s3.getAlias() != p1 || s1.isValid()) { |
| 373 errln("LocalPointer.moveFrom() did not move"); |
| 374 } |
| 375 #if U_HAVE_RVALUE_REFERENCES |
| 376 infoln("TestLocalPointerMoveSwap() with rvalue references"); |
| 377 s1 = static_cast<LocalPointer<UnicodeString> &&>(s3); |
| 378 if(s1.getAlias() != p1 || s3.isValid()) { |
| 379 errln("LocalPointer move assignment operator did not move"); |
| 380 } |
| 381 LocalPointer<UnicodeString> s4(static_cast<LocalPointer<UnicodeString> &&>(s
2)); |
| 382 if(s4.getAlias() != p2 || s2.isValid()) { |
| 383 errln("LocalPointer move constructor did not move"); |
| 384 } |
| 385 #else |
| 386 infoln("TestLocalPointerMoveSwap() without rvalue references"); |
| 387 #endif |
| 388 |
| 389 // Move self assignment leaves the object valid but in an undefined state. |
| 390 // Do it to make sure there is no crash, |
| 391 // but do not check for any particular resulting value. |
| 392 s1.moveFrom(s1); |
| 393 s3.moveFrom(s3); |
| 394 } |
| 395 |
| 396 // Exercise almost every LocalArray method (but not LocalPointerBase). |
307 void LocalPointerTest::TestLocalArray() { | 397 void LocalPointerTest::TestLocalArray() { |
308 // constructor | 398 // constructor |
309 LocalArray<UnicodeString> a(new UnicodeString[2]); | 399 LocalArray<UnicodeString> a(new UnicodeString[2]); |
310 // operator[]() | 400 // operator[]() |
311 a[0].append((UChar)0x61); | 401 a[0].append((UChar)0x61); |
312 a[1].append((UChar32)0x60006); | 402 a[1].append((UChar32)0x60006); |
313 if(a[0].length()!=1 || a[1].length()!=2) { | 403 if(a[0].length()!=1 || a[1].length()!=2) { |
314 errln("LocalArray access failure"); | 404 errln("LocalArray access failure"); |
315 } | 405 } |
316 // adoptInstead() | 406 // adoptInstead() |
317 a.adoptInstead(new UnicodeString[4]); | 407 a.adoptInstead(new UnicodeString[4]); |
318 a[3].append((UChar)0x62).append((UChar)0x63).reverse(); | 408 a[3].append((UChar)0x62).append((UChar)0x63).reverse(); |
319 if(a[3].length()!=2 || a[3][1]!=0x62) { | 409 if(a[3].length()!=2 || a[3][1]!=0x62) { |
320 errln("LocalArray adoptInstead() failure"); | 410 errln("LocalArray adoptInstead() failure"); |
321 } | 411 } |
| 412 |
| 413 // LocalArray(p, errorCode) sets U_MEMORY_ALLOCATION_ERROR if p==NULL. |
| 414 UErrorCode errorCode = U_ZERO_ERROR; |
| 415 LocalArray<UnicodeString> ua(new UnicodeString[3], errorCode); |
| 416 if(ua.isNull() && U_SUCCESS(errorCode)) { |
| 417 errln("LocalArray(p, errorCode) failure"); |
| 418 return; |
| 419 } |
| 420 errorCode = U_ZERO_ERROR; |
| 421 UnicodeString *u4 = new UnicodeString[4]; |
| 422 ua.adoptInsteadAndCheckErrorCode(u4, errorCode); |
| 423 if(ua.isNull() && U_SUCCESS(errorCode)) { |
| 424 errln("adoptInsteadAndCheckErrorCode(p, errorCode) failure"); |
| 425 return; |
| 426 } |
| 427 // Incoming failure: Keep the current object and delete the input object. |
| 428 errorCode = U_ILLEGAL_ARGUMENT_ERROR; |
| 429 ua.adoptInsteadAndCheckErrorCode(new UnicodeString[5], errorCode); |
| 430 if(ua.isValid() && ua.getAlias() != u4) { |
| 431 errln("adoptInsteadAndCheckErrorCode(p, U_FAILURE) did not retain the ol
d array"); |
| 432 return; |
| 433 } |
| 434 errorCode = U_ZERO_ERROR; |
| 435 ua.adoptInsteadAndCheckErrorCode(NULL, errorCode); |
| 436 if(errorCode != U_MEMORY_ALLOCATION_ERROR) { |
| 437 errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) did not set U_MEMO
RY_ALLOCATION_ERROR"); |
| 438 return; |
| 439 } |
| 440 if(ua.isValid()) { |
| 441 errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) kept the array"); |
| 442 return; |
| 443 } |
| 444 errorCode = U_ZERO_ERROR; |
| 445 LocalArray<UnicodeString> null(NULL, errorCode); |
| 446 if(errorCode != U_MEMORY_ALLOCATION_ERROR) { |
| 447 errln("LocalArray(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR
"); |
| 448 return; |
| 449 } |
| 450 |
322 // destructor | 451 // destructor |
323 } | 452 } |
324 | 453 |
| 454 void LocalPointerTest::TestLocalArrayMoveSwap() { |
| 455 UnicodeString *p1 = new UnicodeString[2]; |
| 456 UnicodeString *p2 = new UnicodeString[3]; |
| 457 LocalArray<UnicodeString> a1(p1); |
| 458 LocalArray<UnicodeString> a2(p2); |
| 459 a1.swap(a2); |
| 460 if(a1.getAlias() != p2 || a2.getAlias() != p1) { |
| 461 errln("LocalArray.swap() did not swap"); |
| 462 } |
| 463 swap(a1, a2); |
| 464 if(a1.getAlias() != p1 || a2.getAlias() != p2) { |
| 465 errln("swap(LocalArray) did not swap back"); |
| 466 } |
| 467 LocalArray<UnicodeString> a3; |
| 468 a3.moveFrom(a1); |
| 469 if(a3.getAlias() != p1 || a1.isValid()) { |
| 470 errln("LocalArray.moveFrom() did not move"); |
| 471 } |
| 472 #if U_HAVE_RVALUE_REFERENCES |
| 473 infoln("TestLocalArrayMoveSwap() with rvalue references"); |
| 474 a1 = static_cast<LocalArray<UnicodeString> &&>(a3); |
| 475 if(a1.getAlias() != p1 || a3.isValid()) { |
| 476 errln("LocalArray move assignment operator did not move"); |
| 477 } |
| 478 LocalArray<UnicodeString> a4(static_cast<LocalArray<UnicodeString> &&>(a2)); |
| 479 if(a4.getAlias() != p2 || a2.isValid()) { |
| 480 errln("LocalArray move constructor did not move"); |
| 481 } |
| 482 #else |
| 483 infoln("TestLocalArrayMoveSwap() without rvalue references"); |
| 484 #endif |
| 485 |
| 486 // Move self assignment leaves the object valid but in an undefined state. |
| 487 // Do it to make sure there is no crash, |
| 488 // but do not check for any particular resulting value. |
| 489 a1.moveFrom(a1); |
| 490 a3.moveFrom(a3); |
| 491 } |
| 492 |
325 #include "unicode/ucnvsel.h" | 493 #include "unicode/ucnvsel.h" |
326 #include "unicode/ucal.h" | 494 #include "unicode/ucal.h" |
327 #include "unicode/udatpg.h" | 495 #include "unicode/udatpg.h" |
328 #include "unicode/uidna.h" | 496 #include "unicode/uidna.h" |
329 #include "unicode/uldnames.h" | 497 #include "unicode/uldnames.h" |
330 #include "unicode/umsg.h" | 498 #include "unicode/umsg.h" |
331 #include "unicode/unorm2.h" | 499 #include "unicode/unorm2.h" |
332 #include "unicode/uregex.h" | 500 #include "unicode/uregex.h" |
333 #include "unicode/utrans.h" | 501 #include "unicode/utrans.h" |
334 | 502 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 } | 601 } |
434 if(trans.isNull()) { | 602 if(trans.isNull()) { |
435 errln("LocalUTransliteratorPointer failure"); | 603 errln("LocalUTransliteratorPointer failure"); |
436 return; | 604 return; |
437 } | 605 } |
438 #endif /* !UCONFIG_NO_TRANSLITERATION */ | 606 #endif /* !UCONFIG_NO_TRANSLITERATION */ |
439 | 607 |
440 // destructors | 608 // destructors |
441 } | 609 } |
442 | 610 |
| 611 void LocalPointerTest::TestLocalXyzPointerMoveSwap() { |
| 612 #if !UCONFIG_NO_NORMALIZATION |
| 613 IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerMoveSwap"); |
| 614 const UNormalizer2 *nfc=unorm2_getNFCInstance(errorCode); |
| 615 const UNormalizer2 *nfd=unorm2_getNFDInstance(errorCode); |
| 616 if(errorCode.logIfFailureAndReset("unorm2_getNF[CD]Instance()")) { |
| 617 return; |
| 618 } |
| 619 UnicodeSet emptySet; |
| 620 UNormalizer2 *p1 = unorm2_openFiltered(nfc, emptySet.toUSet(), errorCode); |
| 621 UNormalizer2 *p2 = unorm2_openFiltered(nfd, emptySet.toUSet(), errorCode); |
| 622 LocalUNormalizer2Pointer f1(p1); |
| 623 LocalUNormalizer2Pointer f2(p2); |
| 624 if(errorCode.logIfFailureAndReset("unorm2_openFiltered()")) { |
| 625 return; |
| 626 } |
| 627 if(f1.isNull() || f2.isNull()) { |
| 628 errln("LocalUNormalizer2Pointer failure"); |
| 629 return; |
| 630 } |
| 631 f1.swap(f2); |
| 632 if(f1.getAlias() != p2 || f2.getAlias() != p1) { |
| 633 errln("LocalUNormalizer2Pointer.swap() did not swap"); |
| 634 } |
| 635 swap(f1, f2); |
| 636 if(f1.getAlias() != p1 || f2.getAlias() != p2) { |
| 637 errln("swap(LocalUNormalizer2Pointer) did not swap back"); |
| 638 } |
| 639 LocalUNormalizer2Pointer f3; |
| 640 f3.moveFrom(f1); |
| 641 if(f3.getAlias() != p1 || f1.isValid()) { |
| 642 errln("LocalUNormalizer2Pointer.moveFrom() did not move"); |
| 643 } |
| 644 #if U_HAVE_RVALUE_REFERENCES |
| 645 infoln("TestLocalXyzPointerMoveSwap() with rvalue references"); |
| 646 f1 = static_cast<LocalUNormalizer2Pointer &&>(f3); |
| 647 if(f1.getAlias() != p1 || f3.isValid()) { |
| 648 errln("LocalUNormalizer2Pointer move assignment operator did not move"); |
| 649 } |
| 650 LocalUNormalizer2Pointer f4(static_cast<LocalUNormalizer2Pointer &&>(f2)); |
| 651 if(f4.getAlias() != p2 || f2.isValid()) { |
| 652 errln("LocalUNormalizer2Pointer move constructor did not move"); |
| 653 } |
| 654 #else |
| 655 infoln("TestLocalXyzPointerMoveSwap() without rvalue references"); |
| 656 #endif |
| 657 // Move self assignment leaves the object valid but in an undefined state. |
| 658 // Do it to make sure there is no crash, |
| 659 // but do not check for any particular resulting value. |
| 660 f1.moveFrom(f1); |
| 661 f3.moveFrom(f3); |
| 662 #endif /* !UCONFIG_NO_NORMALIZATION */ |
| 663 } |
| 664 |
443 // Try LocalXyzPointer types with NULL pointers. | 665 // Try LocalXyzPointer types with NULL pointers. |
444 void LocalPointerTest::TestLocalXyzPointerNull() { | 666 void LocalPointerTest::TestLocalXyzPointerNull() { |
445 { | 667 { |
446 IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUConvert
erSelectorPointer"); | 668 IcuTestErrorCode errorCode(*this, "TestLocalXyzPointerNull/LocalUConvert
erSelectorPointer"); |
447 static const char *const encoding="ISO-8859-1"; | 669 static const char *const encoding="ISO-8859-1"; |
448 LocalUConverterSelectorPointer null; | 670 LocalUConverterSelectorPointer null; |
449 LocalUConverterSelectorPointer sel( | 671 LocalUConverterSelectorPointer sel( |
450 ucnvsel_open(&encoding, 1, NULL, UCNV_ROUNDTRIP_SET, errorCode)); | 672 ucnvsel_open(&encoding, 1, NULL, UCNV_ROUNDTRIP_SET, errorCode)); |
451 sel.adoptInstead(NULL); | 673 sel.adoptInstead(NULL); |
452 } | 674 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 logln("remove THING1 -Value now: %d\n", flags.getAll()); | 798 logln("remove THING1 -Value now: %d\n", flags.getAll()); |
577 logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get
(THING1), flags.get(THING2), flags.get(THING3)); | 799 logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get
(THING1), flags.get(THING2), flags.get(THING3)); |
578 | 800 |
579 flags.clear(); | 801 flags.clear(); |
580 logln("clear -Value now: %d\n", flags.getAll()); | 802 logln("clear -Value now: %d\n", flags.getAll()); |
581 logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get
(THING1), flags.get(THING2), flags.get(THING3)); | 803 logln("get(thing1)=%d, get(thing2)=%d, get(thing3)=%d\n", flags.get
(THING1), flags.get(THING2), flags.get(THING3)); |
582 TEST_ASSERT_TRUE(flags.get(THING1) == FALSE); | 804 TEST_ASSERT_TRUE(flags.get(THING1) == FALSE); |
583 TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); | 805 TEST_ASSERT_TRUE(flags.get(THING2) == FALSE); |
584 TEST_ASSERT_TRUE(flags.get(THING3) == FALSE); | 806 TEST_ASSERT_TRUE(flags.get(THING3) == FALSE); |
585 } | 807 } |
OLD | NEW |