OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * Copyright (c) 1997-2013, International Business Machines | 2 * Copyright (c) 1997-2014, International Business Machines |
3 * Corporation and others. All Rights Reserved. | 3 * Corporation and others. All Rights Reserved. |
4 ********************************************************************/ | 4 ********************************************************************/ |
5 | 5 |
6 #include <string.h> | 6 #include <string.h> |
7 #include "unicode/utypes.h" | 7 #include "unicode/utypes.h" |
8 #include "unicode/uscript.h" | 8 #include "unicode/uscript.h" |
9 #include "unicode/uchar.h" | 9 #include "unicode/uchar.h" |
10 #include "cintltst.h" | 10 #include "cintltst.h" |
11 #include "cucdapi.h" | 11 #include "cucdapi.h" |
| 12 #include "cmemory.h" |
12 | 13 |
13 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof(array[0])) | 14 static void scriptsToString(const UScriptCode scripts[], int32_t length, char s[
]) { |
| 15 int32_t i; |
| 16 if(length == 0) { |
| 17 strcpy(s, "(no scripts)"); |
| 18 return; |
| 19 } |
| 20 s[0] = 0; |
| 21 for(i = 0; i < length; ++i) { |
| 22 if(i > 0) { |
| 23 strcat(s, " "); |
| 24 } |
| 25 strcat(s, uscript_getShortName(scripts[i])); |
| 26 } |
| 27 } |
| 28 |
| 29 static void assertEqualScripts(const char *msg, |
| 30 const UScriptCode scripts1[], int32_t length1, |
| 31 const UScriptCode scripts2[], int32_t length2, |
| 32 UErrorCode errorCode) { |
| 33 char s1[80]; |
| 34 char s2[80]; |
| 35 if(U_FAILURE(errorCode)) { |
| 36 log_err("Failed: %s - %s\n", msg, u_errorName(errorCode)); |
| 37 return; |
| 38 } |
| 39 scriptsToString(scripts1, length1, s1); |
| 40 scriptsToString(scripts2, length2, s2); |
| 41 if(0!=strcmp(s1, s2)) { |
| 42 log_data_err("Failed: %s: expected %s but got %s\n", msg, s1, s2); |
| 43 } |
| 44 } |
14 | 45 |
15 void TestUScriptCodeAPI(){ | 46 void TestUScriptCodeAPI(){ |
16 int i =0; | 47 int i =0; |
17 int numErrors =0; | 48 int numErrors =0; |
18 { | 49 { |
19 const char* testNames[]={ | 50 const char* testNames[]={ |
20 /* test locale */ | 51 /* test locale */ |
21 "en", "en_US", "sr", "ta" , "te_IN", | 52 "en", "en_US", "sr", "ta" , "te_IN", |
22 "hi", "he", "ar", | 53 "hi", "he", "ar", |
23 /* test abbr */ | 54 /* test abbr */ |
24 "Hani", "Hang","Hebr","Hira", | 55 "Hani", "Hang","Hebr","Hira", |
25 "Knda","Kana","Khmr","Lao", | 56 "Knda","Kana","Khmr","Lao", |
26 "Latn",/*"Latf","Latg",*/ | 57 "Latn",/*"Latf","Latg",*/ |
27 "Mlym", "Mong", | 58 "Mlym", "Mong", |
28 | 59 |
29 /* test names */ | 60 /* test names */ |
30 "CYRILLIC","DESERET","DEVANAGARI","ETHIOPIC","GEORGIAN", | 61 "CYRILLIC","DESERET","DEVANAGARI","ETHIOPIC","GEORGIAN", |
31 "GOTHIC", "GREEK", "GUJARATI", "COMMON", "INHERITED", | 62 "GOTHIC", "GREEK", "GUJARATI", "COMMON", "INHERITED", |
32 /* test lower case names */ | 63 /* test lower case names */ |
33 "malayalam", "mongolian", "myanmar", "ogham", "old-italic", | 64 "malayalam", "mongolian", "myanmar", "ogham", "old-italic", |
34 "oriya", "runic", "sinhala", "syriac","tamil", | 65 "oriya", "runic", "sinhala", "syriac","tamil", |
35 "telugu", "thaana", "thai", "tibetan", | 66 "telugu", "thaana", "thai", "tibetan", |
36 /* test the bounds*/ | 67 /* test the bounds*/ |
37 "tagb", "arabic", | 68 "tagb", "arabic", |
38 /* test bogus */ | 69 /* test bogus */ |
39 "asfdasd", "5464", "12235", | 70 "asfdasd", "5464", "12235", |
40 /* test the last index */ | 71 /* test the last index */ |
41 "zyyy", "YI", | 72 "zyyy", "YI", |
42 '\0' | 73 NULL |
43 }; | 74 }; |
44 UScriptCode expected[] ={ | 75 UScriptCode expected[] ={ |
45 /* locales should return */ | 76 /* locales should return */ |
46 USCRIPT_LATIN, USCRIPT_LATIN, USCRIPT_CYRILLIC, USCRIPT_TAMIL, USCRI
PT_TELUGU, | 77 USCRIPT_LATIN, USCRIPT_LATIN, USCRIPT_CYRILLIC, USCRIPT_TAMIL, USCRI
PT_TELUGU, |
47 USCRIPT_DEVANAGARI, USCRIPT_HEBREW, USCRIPT_ARABIC, | 78 USCRIPT_DEVANAGARI, USCRIPT_HEBREW, USCRIPT_ARABIC, |
48 /* abbr should return */ | 79 /* abbr should return */ |
49 USCRIPT_HAN, USCRIPT_HANGUL, USCRIPT_HEBREW, USCRIPT_HIRAGANA, | 80 USCRIPT_HAN, USCRIPT_HANGUL, USCRIPT_HEBREW, USCRIPT_HIRAGANA, |
50 USCRIPT_KANNADA, USCRIPT_KATAKANA, USCRIPT_KHMER, USCRIPT_LAO, | 81 USCRIPT_KANNADA, USCRIPT_KATAKANA, USCRIPT_KHMER, USCRIPT_LAO, |
51 USCRIPT_LATIN,/* USCRIPT_LATIN, USCRIPT_LATIN,*/ | 82 USCRIPT_LATIN,/* USCRIPT_LATIN, USCRIPT_LATIN,*/ |
52 USCRIPT_MALAYALAM, USCRIPT_MONGOLIAN, | 83 USCRIPT_MALAYALAM, USCRIPT_MONGOLIAN, |
53 /* names should return */ | 84 /* names should return */ |
54 USCRIPT_CYRILLIC, USCRIPT_DESERET, USCRIPT_DEVANAGARI, USCRIPT_ETHIO
PIC, USCRIPT_GEORGIAN, | 85 USCRIPT_CYRILLIC, USCRIPT_DESERET, USCRIPT_DEVANAGARI, USCRIPT_ETHIO
PIC, USCRIPT_GEORGIAN, |
55 USCRIPT_GOTHIC, USCRIPT_GREEK, USCRIPT_GUJARATI, USCRIPT_COMMON, USC
RIPT_INHERITED, | 86 USCRIPT_GOTHIC, USCRIPT_GREEK, USCRIPT_GUJARATI, USCRIPT_COMMON, USC
RIPT_INHERITED, |
56 /* lower case names should return */ | 87 /* lower case names should return */ |
57 USCRIPT_MALAYALAM, USCRIPT_MONGOLIAN, USCRIPT_MYANMAR, USCRIPT_OGHAM
, USCRIPT_OLD_ITALIC, | 88 USCRIPT_MALAYALAM, USCRIPT_MONGOLIAN, USCRIPT_MYANMAR, USCRIPT_OGHAM
, USCRIPT_OLD_ITALIC, |
58 USCRIPT_ORIYA, USCRIPT_RUNIC, USCRIPT_SINHALA, USCRIPT_SYRIAC, USCRI
PT_TAMIL, | 89 USCRIPT_ORIYA, USCRIPT_RUNIC, USCRIPT_SINHALA, USCRIPT_SYRIAC, USCRI
PT_TAMIL, |
59 USCRIPT_TELUGU, USCRIPT_THAANA, USCRIPT_THAI, USCRIPT_TIBETAN, | 90 USCRIPT_TELUGU, USCRIPT_THAANA, USCRIPT_THAI, USCRIPT_TIBETAN, |
60 /* bounds */ | 91 /* bounds */ |
61 USCRIPT_TAGBANWA, USCRIPT_ARABIC, | 92 USCRIPT_TAGBANWA, USCRIPT_ARABIC, |
62 /* bogus names should return invalid code */ | 93 /* bogus names should return invalid code */ |
63 USCRIPT_INVALID_CODE, USCRIPT_INVALID_CODE, USCRIPT_INVALID_CODE, | 94 USCRIPT_INVALID_CODE, USCRIPT_INVALID_CODE, USCRIPT_INVALID_CODE, |
64 USCRIPT_COMMON, USCRIPT_YI, | 95 USCRIPT_COMMON, USCRIPT_YI, |
65 }; | 96 }; |
66 | 97 |
67 UErrorCode err = U_ZERO_ERROR; | 98 UErrorCode err = U_ZERO_ERROR; |
68 | 99 |
69 const int32_t capacity = 10; | 100 const int32_t capacity = 10; |
70 | 101 |
71 for( ; testNames[i]!='\0'; i++){ | 102 for( ; testNames[i]!=NULL; i++){ |
72 UScriptCode script[10]={USCRIPT_INVALID_CODE}; | 103 UScriptCode script[10]={USCRIPT_INVALID_CODE}; |
73 uscript_getCode(testNames[i],script,capacity, &err); | 104 uscript_getCode(testNames[i],script,capacity, &err); |
74 if( script[0] != expected[i]){ | 105 if( script[0] != expected[i]){ |
75 log_data_err("Error getting script code Got: %i Expected: %i
for name %s (Error code does not propagate if data is not present. Are you miss
ing data?)\n", | 106 log_data_err("Error getting script code Got: %i Expected: %i
for name %s (Error code does not propagate if data is not present. Are you miss
ing data?)\n", |
76 script[0],expected[i],testNames[i]); | 107 script[0],expected[i],testNames[i]); |
77 numErrors++; | 108 numErrors++; |
78 } | 109 } |
79 } | 110 } |
80 if(numErrors >0 ){ | 111 if(numErrors >0 ){ |
81 log_data_err("Errors uchar_getScriptCode() : %i \n",numErrors); | 112 log_data_err("Errors uchar_getScriptCode() : %i \n",numErrors); |
(...skipping 24 matching lines...) Expand all Loading... |
106 | 137 |
107 } | 138 } |
108 } | 139 } |
109 }else{ | 140 }else{ |
110 log_data_err("Errors in uscript_getScriptCode() expected error : %s
got: %s \n", | 141 log_data_err("Errors in uscript_getScriptCode() expected error : %s
got: %s \n", |
111 "U_BUFFER_OVERFLOW_ERROR", | 142 "U_BUFFER_OVERFLOW_ERROR", |
112 u_errorName(err)); | 143 u_errorName(err)); |
113 } | 144 } |
114 | 145 |
115 } | 146 } |
| 147 { |
| 148 static const UScriptCode LATIN[1] = { USCRIPT_LATIN }; |
| 149 static const UScriptCode CYRILLIC[1] = { USCRIPT_CYRILLIC }; |
| 150 static const UScriptCode DEVANAGARI[1] = { USCRIPT_DEVANAGARI }; |
| 151 static const UScriptCode HAN[1] = { USCRIPT_HAN }; |
| 152 static const UScriptCode JAPANESE[3] = { USCRIPT_KATAKANA, USCRIPT_HIRAG
ANA, USCRIPT_HAN }; |
| 153 static const UScriptCode KOREAN[2] = { USCRIPT_HANGUL, USCRIPT_HAN }; |
| 154 static const UScriptCode HAN_BOPO[2] = { USCRIPT_HAN, USCRIPT_BOPOMOFO }
; |
| 155 UScriptCode scripts[5]; |
| 156 UErrorCode err; |
| 157 int32_t num; |
| 158 |
| 159 // Should work regardless of whether we have locale data for the languag
e. |
| 160 err = U_ZERO_ERROR; |
| 161 num = uscript_getCode("tg", scripts, UPRV_LENGTHOF(scripts), &err); |
| 162 assertEqualScripts("tg script: Cyrl", CYRILLIC, 1, scripts, num, err);
// Tajik |
| 163 err = U_ZERO_ERROR; |
| 164 num = uscript_getCode("xsr", scripts, UPRV_LENGTHOF(scripts), &err); |
| 165 assertEqualScripts("xsr script: Deva", DEVANAGARI, 1, scripts, num, err)
; // Sherpa |
| 166 |
| 167 // Multi-script languages. |
| 168 err = U_ZERO_ERROR; |
| 169 num = uscript_getCode("ja", scripts, UPRV_LENGTHOF(scripts), &err); |
| 170 assertEqualScripts("ja scripts: Kana Hira Hani", |
| 171 JAPANESE, UPRV_LENGTHOF(JAPANESE), scripts, num, err)
; |
| 172 err = U_ZERO_ERROR; |
| 173 num = uscript_getCode("ko", scripts, UPRV_LENGTHOF(scripts), &err); |
| 174 assertEqualScripts("ko scripts: Hang Hani", |
| 175 KOREAN, UPRV_LENGTHOF(KOREAN), scripts, num, err); |
| 176 err = U_ZERO_ERROR; |
| 177 num = uscript_getCode("zh", scripts, UPRV_LENGTHOF(scripts), &err); |
| 178 assertEqualScripts("zh script: Hani", HAN, 1, scripts, num, err); |
| 179 err = U_ZERO_ERROR; |
| 180 num = uscript_getCode("zh-Hant", scripts, UPRV_LENGTHOF(scripts), &err); |
| 181 assertEqualScripts("zh-Hant scripts: Hani Bopo", HAN_BOPO, 2, scripts, n
um, err); |
| 182 err = U_ZERO_ERROR; |
| 183 num = uscript_getCode("zh-TW", scripts, UPRV_LENGTHOF(scripts), &err); |
| 184 assertEqualScripts("zh-TW scripts: Hani Bopo", HAN_BOPO, 2, scripts, num
, err); |
| 185 |
| 186 // Ambiguous API, but this probably wants to return Latin rather than Ro
ngorongo (Roro). |
| 187 err = U_ZERO_ERROR; |
| 188 num = uscript_getCode("ro-RO", scripts, UPRV_LENGTHOF(scripts), &err); |
| 189 assertEqualScripts("ro-RO script: Latn", LATIN, 1, scripts, num, err); |
| 190 } |
116 | 191 |
117 { | 192 { |
118 UScriptCode testAbbr[]={ | 193 UScriptCode testAbbr[]={ |
119 /* names should return */ | 194 /* names should return */ |
120 USCRIPT_CYRILLIC, USCRIPT_DESERET, USCRIPT_DEVANAGARI, USCRIPT_ETHIO
PIC, USCRIPT_GEORGIAN, | 195 USCRIPT_CYRILLIC, USCRIPT_DESERET, USCRIPT_DEVANAGARI, USCRIPT_ETHIO
PIC, USCRIPT_GEORGIAN, |
121 USCRIPT_GOTHIC, USCRIPT_GREEK, USCRIPT_GUJARATI, | 196 USCRIPT_GOTHIC, USCRIPT_GREEK, USCRIPT_GUJARATI, |
122 }; | 197 }; |
123 | 198 |
124 const char* expectedNames[]={ | 199 const char* expectedNames[]={ |
125 | 200 |
126 /* test names */ | 201 /* test names */ |
127 "Cyrillic","Deseret","Devanagari","Ethiopic","Georgian", | 202 "Cyrillic","Deseret","Devanagari","Ethiopic","Georgian", |
128 "Gothic", "Greek", "Gujarati", | 203 "Gothic", "Greek", "Gujarati", |
129 '\0' | 204 NULL |
130 }; | 205 }; |
131 i=0; | 206 i=0; |
132 while(i<sizeof(testAbbr)/sizeof(UScriptCode)){ | 207 while(i<sizeof(testAbbr)/sizeof(UScriptCode)){ |
133 const char* name = uscript_getName(testAbbr[i]); | 208 const char* name = uscript_getName(testAbbr[i]); |
134 if(name == NULL) { | 209 if(name == NULL) { |
135 log_data_err("Couldn't get script name\n"); | 210 log_data_err("Couldn't get script name\n"); |
136 return; | 211 return; |
137 } | 212 } |
138 numErrors=0; | 213 numErrors=0; |
139 if(strcmp(expectedNames[i],name)!=0){ | 214 if(strcmp(expectedNames[i],name)!=0){ |
(...skipping 18 matching lines...) Expand all Loading... |
158 USCRIPT_LATIN, | 233 USCRIPT_LATIN, |
159 USCRIPT_MALAYALAM, USCRIPT_MONGOLIAN, | 234 USCRIPT_MALAYALAM, USCRIPT_MONGOLIAN, |
160 }; | 235 }; |
161 | 236 |
162 const char* expectedAbbr[]={ | 237 const char* expectedAbbr[]={ |
163 /* test abbr */ | 238 /* test abbr */ |
164 "Hani", "Hang","Hebr","Hira", | 239 "Hani", "Hang","Hebr","Hira", |
165 "Knda","Kana","Khmr","Laoo", | 240 "Knda","Kana","Khmr","Laoo", |
166 "Latn", | 241 "Latn", |
167 "Mlym", "Mong", | 242 "Mlym", "Mong", |
168 '\0' | 243 NULL |
169 }; | 244 }; |
170 i=0; | 245 i=0; |
171 while(i<sizeof(testAbbr)/sizeof(UScriptCode)){ | 246 while(i<sizeof(testAbbr)/sizeof(UScriptCode)){ |
172 const char* name = uscript_getShortName(testAbbr[i]); | 247 const char* name = uscript_getShortName(testAbbr[i]); |
173 numErrors=0; | 248 numErrors=0; |
174 if(strcmp(expectedAbbr[i],name)!=0){ | 249 if(strcmp(expectedAbbr[i],name)!=0){ |
175 log_err("Error getting abbreviations Got: %s Expected: %s\n",nam
e,expectedAbbr[i]); | 250 log_err("Error getting abbreviations Got: %s Expected: %s\n",nam
e,expectedAbbr[i]); |
176 numErrors++; | 251 numErrors++; |
177 } | 252 } |
178 if(numErrors > 0){ | 253 if(numErrors > 0){ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 USCRIPT_COMMON, | 309 USCRIPT_COMMON, |
235 USCRIPT_INHERITED , | 310 USCRIPT_INHERITED , |
236 USCRIPT_INHERITED , | 311 USCRIPT_INHERITED , |
237 USCRIPT_INHERITED , | 312 USCRIPT_INHERITED , |
238 USCRIPT_INHERITED , | 313 USCRIPT_INHERITED , |
239 }; | 314 }; |
240 UScriptCode code = USCRIPT_INVALID_CODE; | 315 UScriptCode code = USCRIPT_INVALID_CODE; |
241 UErrorCode status = U_ZERO_ERROR; | 316 UErrorCode status = U_ZERO_ERROR; |
242 UBool passed = TRUE; | 317 UBool passed = TRUE; |
243 | 318 |
244 for(i=0; i<LENGTHOF(codepoints); ++i){ | 319 for(i=0; i<UPRV_LENGTHOF(codepoints); ++i){ |
245 code = uscript_getScript(codepoints[i],&status); | 320 code = uscript_getScript(codepoints[i],&status); |
246 if(U_SUCCESS(status)){ | 321 if(U_SUCCESS(status)){ |
247 if( code != expected[i] || | 322 if( code != expected[i] || |
248 code != (UScriptCode)u_getIntPropertyValue(codepoints[i], UC
HAR_SCRIPT) | 323 code != (UScriptCode)u_getIntPropertyValue(codepoints[i], UC
HAR_SCRIPT) |
249 ) { | 324 ) { |
250 log_err("uscript_getScript for codepoint \\U%08X failed\n",c
odepoints[i]); | 325 log_err("uscript_getScript for codepoint \\U%08X failed\n",c
odepoints[i]); |
251 passed = FALSE; | 326 passed = FALSE; |
252 } | 327 } |
253 }else{ | 328 }else{ |
254 log_err("uscript_getScript for codepoint \\U%08X failed. Error:
%s\n", | 329 log_err("uscript_getScript for codepoint \\U%08X failed. Error:
%s\n", |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 { | 372 { |
298 /* | 373 /* |
299 * These script codes were originally added to ICU pre-3.6, so that ICU
would | 374 * These script codes were originally added to ICU pre-3.6, so that ICU
would |
300 * have all ISO 15924 script codes. ICU was then based on Unicode 4.1. | 375 * have all ISO 15924 script codes. ICU was then based on Unicode 4.1. |
301 * These script codes were added with only short names because we don't | 376 * These script codes were added with only short names because we don't |
302 * want to invent long names ourselves. | 377 * want to invent long names ourselves. |
303 * Unicode 5 and later encode some of these scripts and give them long n
ames. | 378 * Unicode 5 and later encode some of these scripts and give them long n
ames. |
304 * Whenever this happens, the long script names here need to be updated. | 379 * Whenever this happens, the long script names here need to be updated. |
305 */ | 380 */ |
306 static const char* expectedLong[] = { | 381 static const char* expectedLong[] = { |
307 "Balinese", "Batak", "Blis", "Brahmi", "Cham", "Cirt", "Cyrs", "Egyd
", "Egyh", "Egyptian_Hieroglyphs", | 382 "Balinese", "Batak", "Blis", "Brahmi", "Cham", "Cirt", "Cyrs", |
308 "Geok", "Hans", "Hant", "Hmng", "Hung", "Inds", "Javanese", "Kayah_L
i", "Latf", "Latg", | 383 "Egyd", "Egyh", "Egyptian_Hieroglyphs", |
309 "Lepcha", "Lina", "Mandaic", "Maya", "Meroitic_Hieroglyphs", "Nko",
"Old_Turkic", "Perm", "Phags_Pa", "Phoenician", | 384 "Geok", "Hans", "Hant", "Pahawh_Hmong", "Hung", "Inds", |
| 385 "Javanese", "Kayah_Li", "Latf", "Latg", |
| 386 "Lepcha", "Linear_A", "Mandaic", "Maya", "Meroitic_Hieroglyphs", |
| 387 "Nko", "Old_Turkic", "Old_Permic", "Phags_Pa", "Phoenician", |
310 "Miao", "Roro", "Sara", "Syre", "Syrj", "Syrn", "Teng", "Vai", "Visp
", "Cuneiform", | 388 "Miao", "Roro", "Sara", "Syre", "Syrj", "Syrn", "Teng", "Vai", "Visp
", "Cuneiform", |
311 "Zxxx", "Unknown", | 389 "Zxxx", "Unknown", |
312 "Carian", "Jpan", "Tai_Tham", "Lycian", "Lydian", "Ol_Chiki", "Rejan
g", "Saurashtra", "Sgnw", "Sundanese", | 390 "Carian", "Jpan", "Tai_Tham", "Lycian", "Lydian", "Ol_Chiki", "Rejan
g", "Saurashtra", "Sgnw", "Sundanese", |
313 "Moon", "Meetei_Mayek", | 391 "Moon", "Meetei_Mayek", |
314 /* new in ICU 4.0 */ | 392 /* new in ICU 4.0 */ |
315 "Imperial_Aramaic", "Avestan", "Chakma", "Kore", | 393 "Imperial_Aramaic", "Avestan", "Chakma", "Kore", |
316 "Kaithi", "Mani", "Inscriptional_Pahlavi", "Phlp", "Phlv", "Inscript
ional_Parthian", "Samaritan", "Tai_Viet", | 394 "Kaithi", "Manichaean", "Inscriptional_Pahlavi", "Psalter_Pahlavi",
"Phlv", |
| 395 "Inscriptional_Parthian", "Samaritan", "Tai_Viet", |
317 "Zmth", "Zsym", | 396 "Zmth", "Zsym", |
318 /* new in ICU 4.4 */ | 397 /* new in ICU 4.4 */ |
319 "Bamum", "Lisu", "Nkgb", "Old_South_Arabian", | 398 "Bamum", "Lisu", "Nkgb", "Old_South_Arabian", |
320 /* new in ICU 4.6 */ | 399 /* new in ICU 4.6 */ |
321 "Bass", "Dupl", "Elba", "Gran", "Kpel", "Loma", "Mend", "Meroitic_Cu
rsive", | 400 "Bassa_Vah", "Duployan", "Elbasan", "Grantha", "Kpel", |
322 "Narb", "Nbat", "Palm", "Sind", "Wara", | 401 "Loma", "Mende_Kikakui", "Meroitic_Cursive", |
| 402 "Old_North_Arabian", "Nabataean", "Palmyrene", "Khudawadi", "Warang_
Citi", |
323 /* new in ICU 4.8 */ | 403 /* new in ICU 4.8 */ |
324 "Afak", "Jurc", "Mroo", "Nshu", "Sharada", "Sora_Sompeng", "Takri",
"Tang", "Wole", | 404 "Afak", "Jurc", "Mro", "Nshu", "Sharada", "Sora_Sompeng", "Takri", "
Tang", "Wole", |
325 /* new in ICU 49 */ | 405 /* new in ICU 49 */ |
326 "Hluw", "Khoj", "Tirh", | 406 "Hluw", "Khojki", "Tirhuta", |
327 /* new in ICU 52 */ | 407 /* new in ICU 52 */ |
328 "Aghb", "Mahj" | 408 "Caucasian_Albanian", "Mahajani", |
| 409 /* new in ICU 54 */ |
| 410 "Ahom", "Hatr", "Modi", "Mult", "Pau_Cin_Hau", "Siddham" |
329 }; | 411 }; |
330 static const char* expectedShort[] = { | 412 static const char* expectedShort[] = { |
331 "Bali", "Batk", "Blis", "Brah", "Cham", "Cirt", "Cyrs", "Egyd", "Egy
h", "Egyp", | 413 "Bali", "Batk", "Blis", "Brah", "Cham", "Cirt", "Cyrs", "Egyd", "Egy
h", "Egyp", |
332 "Geok", "Hans", "Hant", "Hmng", "Hung", "Inds", "Java", "Kali", "Lat
f", "Latg", | 414 "Geok", "Hans", "Hant", "Hmng", "Hung", "Inds", "Java", "Kali", "Lat
f", "Latg", |
333 "Lepc", "Lina", "Mand", "Maya", "Mero", "Nkoo", "Orkh", "Perm", "Pha
g", "Phnx", | 415 "Lepc", "Lina", "Mand", "Maya", "Mero", "Nkoo", "Orkh", "Perm", "Pha
g", "Phnx", |
334 "Plrd", "Roro", "Sara", "Syre", "Syrj", "Syrn", "Teng", "Vaii", "Vis
p", "Xsux", | 416 "Plrd", "Roro", "Sara", "Syre", "Syrj", "Syrn", "Teng", "Vaii", "Vis
p", "Xsux", |
335 "Zxxx", "Zzzz", | 417 "Zxxx", "Zzzz", |
336 "Cari", "Jpan", "Lana", "Lyci", "Lydi", "Olck", "Rjng", "Saur", "Sgn
w", "Sund", | 418 "Cari", "Jpan", "Lana", "Lyci", "Lydi", "Olck", "Rjng", "Saur", "Sgn
w", "Sund", |
337 "Moon", "Mtei", | 419 "Moon", "Mtei", |
338 /* new in ICU 4.0 */ | 420 /* new in ICU 4.0 */ |
339 "Armi", "Avst", "Cakm", "Kore", | 421 "Armi", "Avst", "Cakm", "Kore", |
340 "Kthi", "Mani", "Phli", "Phlp", "Phlv", "Prti", "Samr", "Tavt", | 422 "Kthi", "Mani", "Phli", "Phlp", "Phlv", "Prti", "Samr", "Tavt", |
341 "Zmth", "Zsym", | 423 "Zmth", "Zsym", |
342 /* new in ICU 4.4 */ | 424 /* new in ICU 4.4 */ |
343 "Bamu", "Lisu", "Nkgb", "Sarb", | 425 "Bamu", "Lisu", "Nkgb", "Sarb", |
344 /* new in ICU 4.6 */ | 426 /* new in ICU 4.6 */ |
345 "Bass", "Dupl", "Elba", "Gran", "Kpel", "Loma", "Mend", "Merc", | 427 "Bass", "Dupl", "Elba", "Gran", "Kpel", "Loma", "Mend", "Merc", |
346 "Narb", "Nbat", "Palm", "Sind", "Wara", | 428 "Narb", "Nbat", "Palm", "Sind", "Wara", |
347 /* new in ICU 4.8 */ | 429 /* new in ICU 4.8 */ |
348 "Afak", "Jurc", "Mroo", "Nshu", "Shrd", "Sora", "Takr", "Tang", "Wol
e", | 430 "Afak", "Jurc", "Mroo", "Nshu", "Shrd", "Sora", "Takr", "Tang", "Wol
e", |
349 /* new in ICU 49 */ | 431 /* new in ICU 49 */ |
350 "Hluw", "Khoj", "Tirh", | 432 "Hluw", "Khoj", "Tirh", |
351 /* new in ICU 52 */ | 433 /* new in ICU 52 */ |
352 "Aghb", "Mahj" | 434 "Aghb", "Mahj", |
| 435 /* new in ICU 54 */ |
| 436 "Ahom", "Hatr", "Modi", "Mult", "Pauc", "Sidd" |
353 }; | 437 }; |
354 int32_t j = 0; | 438 int32_t j = 0; |
355 if(LENGTHOF(expectedLong)!=(USCRIPT_CODE_LIMIT-USCRIPT_BALINESE)) { | 439 if(UPRV_LENGTHOF(expectedLong)!=(USCRIPT_CODE_LIMIT-USCRIPT_BALINESE)) { |
356 log_err("need to add new script codes in cucdapi.c!\n"); | 440 log_err("need to add new script codes in cucdapi.c!\n"); |
357 return; | 441 return; |
358 } | 442 } |
359 for(i=USCRIPT_BALINESE; (UScriptCode)i<USCRIPT_CODE_LIMIT; i++, j++){ | 443 for(i=USCRIPT_BALINESE; (UScriptCode)i<USCRIPT_CODE_LIMIT; i++, j++){ |
360 const char* name = uscript_getName((UScriptCode)i); | 444 const char* name = uscript_getName((UScriptCode)i); |
361 if(name==NULL || strcmp(name,expectedLong[j])!=0){ | 445 if(name==NULL || strcmp(name,expectedLong[j])!=0){ |
362 log_err("uscript_getName failed for code %i: %s!=%s\n", i, name,
expectedLong[j]); | 446 log_err("uscript_getName failed for code %i: %s!=%s\n", i, name,
expectedLong[j]); |
363 } | 447 } |
364 name = uscript_getShortName((UScriptCode)i); | 448 name = uscript_getShortName((UScriptCode)i); |
365 if(name==NULL || strcmp(name,expectedShort[j])!=0){ | 449 if(name==NULL || strcmp(name,expectedShort[j])!=0){ |
366 log_err("uscript_getShortName failed for code %i: %s!=%s\n", i,
name, expectedShort[j]); | 450 log_err("uscript_getShortName failed for code %i: %s!=%s\n", i,
name, expectedShort[j]); |
367 } | 451 } |
368 } | 452 } |
369 for(i=0; i<LENGTHOF(expectedLong); i++){ | 453 for(i=0; i<UPRV_LENGTHOF(expectedLong); i++){ |
370 UScriptCode fillIn[5] = {USCRIPT_INVALID_CODE}; | 454 UScriptCode fillIn[5] = {USCRIPT_INVALID_CODE}; |
371 UErrorCode status = U_ZERO_ERROR; | 455 UErrorCode status = U_ZERO_ERROR; |
372 int32_t len = 0; | 456 int32_t len = 0; |
373 len = uscript_getCode(expectedShort[i], fillIn, LENGTHOF(fillIn), &s
tatus); | 457 len = uscript_getCode(expectedShort[i], fillIn, UPRV_LENGTHOF(fillIn
), &status); |
374 if(U_FAILURE(status)){ | 458 if(U_FAILURE(status)){ |
375 log_err("uscript_getCode failed for script name %s. Error: %s\n"
,expectedShort[i], u_errorName(status)); | 459 log_err("uscript_getCode failed for script name %s. Error: %s\n"
,expectedShort[i], u_errorName(status)); |
376 } | 460 } |
377 if(len>1){ | 461 if(len>1){ |
378 log_err("uscript_getCode did not return expected number of codes
for script %s. EXPECTED: 1 GOT: %i\n", expectedShort[i], len); | 462 log_err("uscript_getCode did not return expected number of codes
for script %s. EXPECTED: 1 GOT: %i\n", expectedShort[i], len); |
379 } | 463 } |
380 if(fillIn[0]!= (UScriptCode)(USCRIPT_BALINESE+i)){ | 464 if(fillIn[0]!= (UScriptCode)(USCRIPT_BALINESE+i)){ |
381 log_err("uscript_getCode did not return expected code for script
%s. EXPECTED: %i GOT: %i\n", expectedShort[i], (USCRIPT_BALINESE+i), fillIn[0]
); | 465 log_err("uscript_getCode did not return expected code for script
%s. EXPECTED: %i GOT: %i\n", expectedShort[i], (USCRIPT_BALINESE+i), fillIn[0]
); |
382 } | 466 } |
383 } | 467 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 uscript_hasScript(0xfdf2, USCRIPT_THAANA)) | 521 uscript_hasScript(0xfdf2, USCRIPT_THAANA)) |
438 ) { | 522 ) { |
439 log_err("uscript_hasScript(U+FDF2, ...) is wrong\n"); | 523 log_err("uscript_hasScript(U+FDF2, ...) is wrong\n"); |
440 } | 524 } |
441 if(uscript_hasScript(0x0640, 0xaffe)) { | 525 if(uscript_hasScript(0x0640, 0xaffe)) { |
442 /* An unguarded implementation might go into an infinite loop. */ | 526 /* An unguarded implementation might go into an infinite loop. */ |
443 log_err("uscript_hasScript(U+0640, bogus 0xaffe) is wrong\n"); | 527 log_err("uscript_hasScript(U+0640, bogus 0xaffe) is wrong\n"); |
444 } | 528 } |
445 } | 529 } |
446 | 530 |
| 531 static UBool scriptsContain(int32_t scripts[], int32_t length, int32_t script) { |
| 532 UBool contain=FALSE; |
| 533 int32_t prev=-1, i; |
| 534 for(i=0; i<length; ++i) { |
| 535 int32_t s=scripts[i]; |
| 536 if(s<=prev) { |
| 537 log_err("uscript_getScriptExtensions() not in sorted order: %d %d\n"
, (int)prev, (int)s); |
| 538 } |
| 539 if(s==script) { contain=TRUE; } |
| 540 } |
| 541 return contain; |
| 542 } |
| 543 |
447 void TestGetScriptExtensions() { | 544 void TestGetScriptExtensions() { |
448 UScriptCode scripts[20]; | 545 UScriptCode scripts[20]; |
449 int32_t length; | 546 int32_t length; |
450 UErrorCode errorCode; | 547 UErrorCode errorCode; |
451 | 548 |
452 /* errors and overflows */ | 549 /* errors and overflows */ |
453 errorCode=U_PARSE_ERROR; | 550 errorCode=U_PARSE_ERROR; |
454 length=uscript_getScriptExtensions(0x0640, scripts, LENGTHOF(scripts), &erro
rCode); | 551 length=uscript_getScriptExtensions(0x0640, scripts, UPRV_LENGTHOF(scripts),
&errorCode); |
455 if(errorCode!=U_PARSE_ERROR) { | 552 if(errorCode!=U_PARSE_ERROR) { |
456 log_err("uscript_getScriptExtensions(U+0640, U_PARSE_ERROR) did not pres
erve the UErrorCode - %s\n", | 553 log_err("uscript_getScriptExtensions(U+0640, U_PARSE_ERROR) did not pres
erve the UErrorCode - %s\n", |
457 u_errorName(errorCode)); | 554 u_errorName(errorCode)); |
458 } | 555 } |
459 errorCode=U_ZERO_ERROR; | 556 errorCode=U_ZERO_ERROR; |
460 length=uscript_getScriptExtensions(0x0640, NULL, LENGTHOF(scripts), &errorCo
de); | 557 length=uscript_getScriptExtensions(0x0640, NULL, UPRV_LENGTHOF(scripts), &er
rorCode); |
461 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { | 558 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { |
462 log_err("uscript_getScriptExtensions(U+0640, NULL) did not set U_ILLEGAL
_ARGUMENT_ERROR - %s\n", | 559 log_err("uscript_getScriptExtensions(U+0640, NULL) did not set U_ILLEGAL
_ARGUMENT_ERROR - %s\n", |
463 u_errorName(errorCode)); | 560 u_errorName(errorCode)); |
464 } | 561 } |
465 errorCode=U_ZERO_ERROR; | 562 errorCode=U_ZERO_ERROR; |
466 length=uscript_getScriptExtensions(0x0640, scripts, -1, &errorCode); | 563 length=uscript_getScriptExtensions(0x0640, scripts, -1, &errorCode); |
467 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { | 564 if(errorCode!=U_ILLEGAL_ARGUMENT_ERROR) { |
468 log_err("uscript_getScriptExtensions(U+0640, capacity<0) did not set U_I
LLEGAL_ARGUMENT_ERROR - %s\n", | 565 log_err("uscript_getScriptExtensions(U+0640, capacity<0) did not set U_I
LLEGAL_ARGUMENT_ERROR - %s\n", |
469 u_errorName(errorCode)); | 566 u_errorName(errorCode)); |
470 } | 567 } |
471 errorCode=U_ZERO_ERROR; | 568 errorCode=U_ZERO_ERROR; |
472 length=uscript_getScriptExtensions(0x0640, scripts, 0, &errorCode); | 569 length=uscript_getScriptExtensions(0x0640, scripts, 0, &errorCode); |
473 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=3) { | 570 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length<3) { |
474 log_err("uscript_getScriptExtensions(U+0640, capacity=0: pure preflighti
ng)=%d != 3 - %s\n", | 571 log_err("uscript_getScriptExtensions(U+0640, capacity=0: pure preflighti
ng)=%d < 3 - %s\n", |
475 (int)length, u_errorName(errorCode)); | 572 (int)length, u_errorName(errorCode)); |
476 } | 573 } |
477 errorCode=U_ZERO_ERROR; | 574 errorCode=U_ZERO_ERROR; |
478 length=uscript_getScriptExtensions(0x0640, scripts, 1, &errorCode); | 575 length=uscript_getScriptExtensions(0x0640, scripts, 1, &errorCode); |
479 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=3) { | 576 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length<3) { |
480 log_err("uscript_getScriptExtensions(U+0640, capacity=1: preflighting)=%
d != 3 - %s\n", | 577 log_err("uscript_getScriptExtensions(U+0640, capacity=1: preflighting)=%
d < 3 - %s\n", |
481 (int)length, u_errorName(errorCode)); | 578 (int)length, u_errorName(errorCode)); |
482 } | 579 } |
483 /* U+063F has only a Script code, no Script_Extensions. */ | 580 /* U+063F has only a Script code, no Script_Extensions. */ |
484 errorCode=U_ZERO_ERROR; | 581 errorCode=U_ZERO_ERROR; |
485 length=uscript_getScriptExtensions(0x063f, scripts, 0, &errorCode); | 582 length=uscript_getScriptExtensions(0x063f, scripts, 0, &errorCode); |
486 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=1) { | 583 if(errorCode!=U_BUFFER_OVERFLOW_ERROR || length!=1) { |
487 log_err("uscript_getScriptExtensions(U+063F, capacity=0)=%d != 1 - %s\n"
, | 584 log_err("uscript_getScriptExtensions(U+063F, capacity=0)=%d != 1 - %s\n"
, |
488 (int)length, u_errorName(errorCode)); | 585 (int)length, u_errorName(errorCode)); |
489 } | 586 } |
490 | 587 |
491 /* invalid code points */ | 588 /* invalid code points */ |
492 errorCode=U_ZERO_ERROR; | 589 errorCode=U_ZERO_ERROR; |
493 length=uscript_getScriptExtensions(-1, scripts, LENGTHOF(scripts), &errorCod
e); | 590 length=uscript_getScriptExtensions(-1, scripts, UPRV_LENGTHOF(scripts), &err
orCode); |
494 if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_UNKNOWN) { | 591 if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_UNKNOWN) { |
495 log_err("uscript_getScriptExtensions(-1)=%d does not return {UNKNOWN} -
%s\n", | 592 log_err("uscript_getScriptExtensions(-1)=%d does not return {UNKNOWN} -
%s\n", |
496 (int)length, u_errorName(errorCode)); | 593 (int)length, u_errorName(errorCode)); |
497 } | 594 } |
498 errorCode=U_ZERO_ERROR; | 595 errorCode=U_ZERO_ERROR; |
499 length=uscript_getScriptExtensions(0x110000, scripts, LENGTHOF(scripts), &er
rorCode); | 596 length=uscript_getScriptExtensions(0x110000, scripts, UPRV_LENGTHOF(scripts)
, &errorCode); |
500 if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_UNKNOWN) { | 597 if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_UNKNOWN) { |
501 log_err("uscript_getScriptExtensions(0x110000)=%d does not return {UNKNO
WN} - %s\n", | 598 log_err("uscript_getScriptExtensions(0x110000)=%d does not return {UNKNO
WN} - %s\n", |
502 (int)length, u_errorName(errorCode)); | 599 (int)length, u_errorName(errorCode)); |
503 } | 600 } |
504 | 601 |
505 /* normal usage */ | 602 /* normal usage */ |
506 errorCode=U_ZERO_ERROR; | 603 errorCode=U_ZERO_ERROR; |
507 length=uscript_getScriptExtensions(0x063f, scripts, 1, &errorCode); | 604 length=uscript_getScriptExtensions(0x063f, scripts, 1, &errorCode); |
508 if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_ARABIC) { | 605 if(U_FAILURE(errorCode) || length!=1 || scripts[0]!=USCRIPT_ARABIC) { |
509 log_err("uscript_getScriptExtensions(U+063F, capacity=1)=%d does not ret
urn {ARABIC} - %s\n", | 606 log_err("uscript_getScriptExtensions(U+063F, capacity=1)=%d does not ret
urn {ARABIC} - %s\n", |
510 (int)length, u_errorName(errorCode)); | 607 (int)length, u_errorName(errorCode)); |
511 } | 608 } |
512 errorCode=U_ZERO_ERROR; | 609 errorCode=U_ZERO_ERROR; |
513 length=uscript_getScriptExtensions(0x0640, scripts, LENGTHOF(scripts), &erro
rCode); | 610 length=uscript_getScriptExtensions(0x0640, scripts, UPRV_LENGTHOF(scripts),
&errorCode); |
514 if(U_FAILURE(errorCode) || length!=3 || | 611 if(U_FAILURE(errorCode) || length<3 || |
515 scripts[0]!=USCRIPT_ARABIC || scripts[1]!=USCRIPT_SYRIAC || scripts[2]!=U
SCRIPT_MANDAIC | 612 !scriptsContain(scripts, length, USCRIPT_ARABIC) || |
516 ) { | 613 !scriptsContain(scripts, length, USCRIPT_SYRIAC) || |
| 614 !scriptsContain(scripts, length, USCRIPT_MANDAIC)) { |
517 log_err("uscript_getScriptExtensions(U+0640)=%d failed - %s\n", | 615 log_err("uscript_getScriptExtensions(U+0640)=%d failed - %s\n", |
518 (int)length, u_errorName(errorCode)); | 616 (int)length, u_errorName(errorCode)); |
519 } | 617 } |
520 errorCode=U_ZERO_ERROR; | 618 errorCode=U_ZERO_ERROR; |
521 length=uscript_getScriptExtensions(0xfdf2, scripts, LENGTHOF(scripts), &erro
rCode); | 619 length=uscript_getScriptExtensions(0xfdf2, scripts, UPRV_LENGTHOF(scripts),
&errorCode); |
522 if(U_FAILURE(errorCode) || length!=2 || scripts[0]!=USCRIPT_ARABIC || script
s[1]!=USCRIPT_THAANA) { | 620 if(U_FAILURE(errorCode) || length!=2 || scripts[0]!=USCRIPT_ARABIC || script
s[1]!=USCRIPT_THAANA) { |
523 log_err("uscript_getScriptExtensions(U+FDF2)=%d failed - %s\n", | 621 log_err("uscript_getScriptExtensions(U+FDF2)=%d failed - %s\n", |
524 (int)length, u_errorName(errorCode)); | 622 (int)length, u_errorName(errorCode)); |
525 } | 623 } |
526 errorCode=U_ZERO_ERROR; | 624 errorCode=U_ZERO_ERROR; |
527 length=uscript_getScriptExtensions(0xff65, scripts, LENGTHOF(scripts), &erro
rCode); | 625 length=uscript_getScriptExtensions(0xff65, scripts, UPRV_LENGTHOF(scripts),
&errorCode); |
528 if(U_FAILURE(errorCode) || length!=6 || scripts[0]!=USCRIPT_BOPOMOFO || scri
pts[5]!=USCRIPT_YI) { | 626 if(U_FAILURE(errorCode) || length!=6 || scripts[0]!=USCRIPT_BOPOMOFO || scri
pts[5]!=USCRIPT_YI) { |
529 log_err("uscript_getScriptExtensions(U+FF65)=%d failed - %s\n", | 627 log_err("uscript_getScriptExtensions(U+FF65)=%d failed - %s\n", |
530 (int)length, u_errorName(errorCode)); | 628 (int)length, u_errorName(errorCode)); |
531 } | 629 } |
532 } | 630 } |
533 | 631 |
534 void TestScriptMetadataAPI() { | 632 void TestScriptMetadataAPI() { |
535 /* API & code coverage. More testing in intltest/ucdtest.cpp. */ | 633 /* API & code coverage. More testing in intltest/ucdtest.cpp. */ |
536 UErrorCode errorCode=U_ZERO_ERROR; | 634 UErrorCode errorCode=U_ZERO_ERROR; |
537 UChar sample[8]; | 635 UChar sample[8]; |
538 | 636 |
539 if(uscript_getSampleString(USCRIPT_LATIN, sample, LENGTHOF(sample), &errorCo
de)!=1 || | 637 if(uscript_getSampleString(USCRIPT_LATIN, sample, UPRV_LENGTHOF(sample), &er
rorCode)!=1 || |
540 U_FAILURE(errorCode) || | 638 U_FAILURE(errorCode) || |
541 uscript_getScript(sample[0], &errorCode)!=USCRIPT_LATIN || | 639 uscript_getScript(sample[0], &errorCode)!=USCRIPT_LATIN || |
542 sample[1]!=0) { | 640 sample[1]!=0) { |
543 log_err("uscript_getSampleString(Latn) failed - %s\n", u_errorName(error
Code)); | 641 log_err("uscript_getSampleString(Latn) failed - %s\n", u_errorName(error
Code)); |
544 } | 642 } |
545 sample[0]=0xfffe; | 643 sample[0]=0xfffe; |
546 if(uscript_getSampleString(USCRIPT_LATIN, sample, 0, &errorCode)!=1 || | 644 if(uscript_getSampleString(USCRIPT_LATIN, sample, 0, &errorCode)!=1 || |
547 errorCode!=U_BUFFER_OVERFLOW_ERROR || | 645 errorCode!=U_BUFFER_OVERFLOW_ERROR || |
548 sample[0]!=0xfffe) { | 646 sample[0]!=0xfffe) { |
549 log_err("uscript_getSampleString(Latn, capacity=0) failed - %s\n", u_err
orName(errorCode)); | 647 log_err("uscript_getSampleString(Latn, capacity=0) failed - %s\n", u_err
orName(errorCode)); |
550 } | 648 } |
551 errorCode=U_ZERO_ERROR; | 649 errorCode=U_ZERO_ERROR; |
552 if(uscript_getSampleString(USCRIPT_INVALID_CODE, sample, LENGTHOF(sample), &
errorCode)!=0 || | 650 if(uscript_getSampleString(USCRIPT_INVALID_CODE, sample, UPRV_LENGTHOF(sampl
e), &errorCode)!=0 || |
553 U_FAILURE(errorCode) || | 651 U_FAILURE(errorCode) || |
554 sample[0]!=0) { | 652 sample[0]!=0) { |
555 log_err("uscript_getSampleString(invalid) failed - %s\n", u_errorName(er
rorCode)); | 653 log_err("uscript_getSampleString(invalid) failed - %s\n", u_errorName(er
rorCode)); |
556 } | 654 } |
557 sample[0]=0xfffe; | 655 sample[0]=0xfffe; |
558 if(uscript_getSampleString(USCRIPT_CODE_LIMIT, sample, 0, &errorCode)!=0 || | 656 if(uscript_getSampleString(USCRIPT_CODE_LIMIT, sample, 0, &errorCode)!=0 || |
559 errorCode!=U_STRING_NOT_TERMINATED_WARNING || | 657 errorCode!=U_STRING_NOT_TERMINATED_WARNING || |
560 sample[0]!=0xfffe) { | 658 sample[0]!=0xfffe) { |
561 log_err("uscript_getSampleString(limit, capacity=0) failed - %s\n", u_er
rorName(errorCode)); | 659 log_err("uscript_getSampleString(limit, capacity=0) failed - %s\n", u_er
rorName(errorCode)); |
562 } | 660 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 } | 692 } |
595 | 693 |
596 void TestBinaryValues() { | 694 void TestBinaryValues() { |
597 /* | 695 /* |
598 * Unicode 5.1 explicitly defines binary property value aliases. | 696 * Unicode 5.1 explicitly defines binary property value aliases. |
599 * Verify that they are all recognized. | 697 * Verify that they are all recognized. |
600 */ | 698 */ |
601 static const char *const falseValues[]={ "N", "No", "F", "False" }; | 699 static const char *const falseValues[]={ "N", "No", "F", "False" }; |
602 static const char *const trueValues[]={ "Y", "Yes", "T", "True" }; | 700 static const char *const trueValues[]={ "Y", "Yes", "T", "True" }; |
603 int32_t i; | 701 int32_t i; |
604 for(i=0; i<LENGTHOF(falseValues); ++i) { | 702 for(i=0; i<UPRV_LENGTHOF(falseValues); ++i) { |
605 if(FALSE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, falseValues[i])) { | 703 if(FALSE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, falseValues[i])) { |
606 log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, \"%s\")!=FALS
E (Are you missing data?)\n", falseValues[i]); | 704 log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, \"%s\")!=FALS
E (Are you missing data?)\n", falseValues[i]); |
607 } | 705 } |
608 } | 706 } |
609 for(i=0; i<LENGTHOF(trueValues); ++i) { | 707 for(i=0; i<UPRV_LENGTHOF(trueValues); ++i) { |
610 if(TRUE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, trueValues[i])) { | 708 if(TRUE!=u_getPropertyValueEnum(UCHAR_ALPHABETIC, trueValues[i])) { |
611 log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, \"%s\")!=TRUE
(Are you missing data?)\n", trueValues[i]); | 709 log_data_err("u_getPropertyValueEnum(UCHAR_ALPHABETIC, \"%s\")!=TRUE
(Are you missing data?)\n", trueValues[i]); |
612 } | 710 } |
613 } | 711 } |
614 } | 712 } |
OLD | NEW |