OLD | NEW |
1 /* | 1 /* |
2 ********************************************************************** | 2 ********************************************************************** |
3 * Copyright (c) 2002-2009, International Business Machines | 3 * Copyright (c) 2002-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ********************************************************************** | 5 ********************************************************************** |
6 */ | 6 */ |
7 #include "unicode/uset.h" | 7 #include "unicode/uset.h" |
8 #include "unicode/ustring.h" | 8 #include "unicode/ustring.h" |
9 #include "cintltst.h" | 9 #include "cintltst.h" |
| 10 #include "cmemory.h" |
10 #include <stdlib.h> | 11 #include <stdlib.h> |
11 #include <string.h> | 12 #include <string.h> |
12 | 13 |
13 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
14 | |
15 #define TEST(x) addTest(root, &x, "uset/" # x) | 14 #define TEST(x) addTest(root, &x, "uset/" # x) |
16 | 15 |
17 static void TestAPI(void); | 16 static void TestAPI(void); |
18 static void Testj2269(void); | 17 static void Testj2269(void); |
19 static void TestSerialized(void); | 18 static void TestSerialized(void); |
20 static void TestNonInvariantPattern(void); | 19 static void TestNonInvariantPattern(void); |
21 static void TestBadPattern(void); | 20 static void TestBadPattern(void); |
22 static void TestFreezable(void); | 21 static void TestFreezable(void); |
23 static void TestSpan(void); | 22 static void TestSpan(void); |
24 | 23 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 U_STRING_DECL(pattern, "[:Cf:]", 6); | 484 U_STRING_DECL(pattern, "[:Cf:]", 6); |
486 U_STRING_INIT(pattern, "[:Cf:]", 6); | 485 U_STRING_INIT(pattern, "[:Cf:]", 6); |
487 | 486 |
488 errorCode=U_ZERO_ERROR; | 487 errorCode=U_ZERO_ERROR; |
489 set=uset_openPattern(pattern, -1, &errorCode); | 488 set=uset_openPattern(pattern, -1, &errorCode); |
490 if(U_FAILURE(errorCode)) { | 489 if(U_FAILURE(errorCode)) { |
491 log_data_err("uset_openPattern([:Cf:]) failed - %s (Are you missing data
?)\n", u_errorName(errorCode)); | 490 log_data_err("uset_openPattern([:Cf:]) failed - %s (Are you missing data
?)\n", u_errorName(errorCode)); |
492 return; | 491 return; |
493 } | 492 } |
494 | 493 |
495 length=uset_serialize(set, buffer, LENGTHOF(buffer), &errorCode); | 494 length=uset_serialize(set, buffer, UPRV_LENGTHOF(buffer), &errorCode); |
496 if(U_FAILURE(errorCode)) { | 495 if(U_FAILURE(errorCode)) { |
497 log_err("unable to uset_serialize([:Cf:]) - %s\n", u_errorName(errorCode
)); | 496 log_err("unable to uset_serialize([:Cf:]) - %s\n", u_errorName(errorCode
)); |
498 uset_close(set); | 497 uset_close(set); |
499 return; | 498 return; |
500 } | 499 } |
501 | 500 |
502 uset_getSerializedSet(&sset, buffer, length); | 501 uset_getSerializedSet(&sset, buffer, length); |
503 for(c=0; c<=0x10ffff; ++c) { | 502 for(c=0; c<=0x10ffff; ++c) { |
504 if(uset_contains(set, c)!=uset_serializedContains(&sset, c)) { | 503 if(uset_contains(set, c)!=uset_serializedContains(&sset, c)) { |
505 log_err("uset_contains(U+%04x)!=uset_serializedContains(U+%04x)\n",
c); | 504 log_err("uset_contains(U+%04x)!=uset_serializedContains(U+%04x)\n",
c); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 6!=uset_spanBackUTF8(idSet, s8, 6, USET_SPAN_CONTAINED) || | 644 6!=uset_spanBackUTF8(idSet, s8, 6, USET_SPAN_CONTAINED) || |
646 3!=uset_spanBackUTF8(idSet, s8, 6, USET_SPAN_NOT_CONTAINED) | 645 3!=uset_spanBackUTF8(idSet, s8, 6, USET_SPAN_NOT_CONTAINED) |
647 ) { | 646 ) { |
648 log_err("uset_spanUTF8(frozen) or uset_spanBackUTF8(frozen) does not wor
k\n"); | 647 log_err("uset_spanUTF8(frozen) or uset_spanBackUTF8(frozen) does not wor
k\n"); |
649 } | 648 } |
650 | 649 |
651 uset_close(idSet); | 650 uset_close(idSet); |
652 } | 651 } |
653 | 652 |
654 /*eof*/ | 653 /*eof*/ |
OLD | NEW |