1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4 * COPYRIGHT:
5 * Copyright (c) 1997-2016, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8
9 #include "cintltst.h"
10 #include "unicode/ures.h"
11 #include "unicode/ucurr.h"
12 #include "unicode/ustring.h"
13 #include "unicode/uset.h"
14 #include "unicode/udat.h"
15 #include "unicode/uscript.h"
16 #include "unicode/ulocdata.h"
17 #include "unicode/utf16.h"
18 #include "cmemory.h"
19 #include "cstring.h"
20 #include "locmap.h"
21 #include "uresimp.h"
22
23 /*
24 returns a new UnicodeSet that is a flattened form of the original
25 UnicodeSet.
26 */
27 static USet*
createFlattenSet(USet * origSet,UErrorCode * status)28 createFlattenSet(USet *origSet, UErrorCode *status) {
29
30
31 USet *newSet = NULL;
32 int32_t origItemCount = 0;
33 int32_t idx, graphmeSize;
34 UChar32 start, end;
35 UChar graphme[64];
36 if (U_FAILURE(*status)) {
37 log_err("createFlattenSet called with %s\n", u_errorName(*status));
38 return NULL;
39 }
40 newSet = uset_open(1, 0);
41 origItemCount = uset_getItemCount(origSet);
42 for (idx = 0; idx < origItemCount; idx++) {
43 graphmeSize = uset_getItem(origSet, idx,
44 &start, &end,
45 graphme, UPRV_LENGTHOF(graphme),
46 status);
47 if (U_FAILURE(*status)) {
48 log_err("ERROR: uset_getItem returned %s\n", u_errorName(*status));
49 *status = U_ZERO_ERROR;
50 }
51 if (graphmeSize) {
52 uset_addAllCodePoints(newSet, graphme, graphmeSize);
53 }
54 else {
55 uset_addRange(newSet, start, end);
56 }
57 }
58 uset_closeOver(newSet,USET_CASE_INSENSITIVE);
59 return newSet;
60 }
61
62 static UBool
isCurrencyPreEuro(const char * currencyKey)63 isCurrencyPreEuro(const char* currencyKey){
64 if( strcmp(currencyKey, "PTE") == 0 ||
65 strcmp(currencyKey, "ESP") == 0 ||
66 strcmp(currencyKey, "LUF") == 0 ||
67 strcmp(currencyKey, "GRD") == 0 ||
68 strcmp(currencyKey, "BEF") == 0 ||
69 strcmp(currencyKey, "ITL") == 0 ||
70 strcmp(currencyKey, "EEK") == 0){
71 return TRUE;
72 }
73 return FALSE;
74 }
75 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
76 static void
TestKeyInRootRecursive(UResourceBundle * root,const char * rootName,UResourceBundle * currentBundle,const char * locale)77 TestKeyInRootRecursive(UResourceBundle *root, const char *rootName,
78 UResourceBundle *currentBundle, const char *locale) {
79 UErrorCode errorCode = U_ZERO_ERROR;
80 UResourceBundle *subRootBundle = NULL, *subBundle = NULL, *arr = NULL;
81
82 ures_resetIterator(root);
83 ures_resetIterator(currentBundle);
84 while (ures_hasNext(currentBundle)) {
85 const char *subBundleKey = NULL;
86 const char *currentBundleKey = NULL;
87
88 errorCode = U_ZERO_ERROR;
89 currentBundleKey = ures_getKey(currentBundle);
90 (void)currentBundleKey; /* Suppress set but not used warning. */
91 subBundle = ures_getNextResource(currentBundle, NULL, &errorCode);
92 if (U_FAILURE(errorCode)) {
93 log_err("Can't open a resource for lnocale %s. Error: %s\n", locale, u_errorName(errorCode));
94 continue;
95 }
96 subBundleKey = ures_getKey(subBundle);
97
98
99 subRootBundle = ures_getByKey(root, subBundleKey, NULL, &errorCode);
100 if (U_FAILURE(errorCode)) {
101 log_err("Can't open a resource with key \"%s\" in \"%s\" from %s for locale \"%s\"\n",
102 subBundleKey,
103 ures_getKey(currentBundle),
104 rootName,
105 locale);
106 ures_close(subBundle);
107 continue;
108 }
109 if (ures_getType(subRootBundle) != ures_getType(subBundle)) {
110 log_err("key \"%s\" in \"%s\" has a different type from root for locale \"%s\"\n"
111 "\troot=%d, locale=%d\n",
112 subBundleKey,
113 ures_getKey(currentBundle),
114 locale,
115 ures_getType(subRootBundle),
116 ures_getType(subBundle));
117 ures_close(subBundle);
118 continue;
119 }
120 else if (ures_getType(subBundle) == URES_INT_VECTOR) {
121 int32_t minSize;
122 int32_t subBundleSize;
123 int32_t idx;
124 UBool sameArray = TRUE;
125 const int32_t *subRootBundleArr = ures_getIntVector(subRootBundle, &minSize, &errorCode);
126 const int32_t *subBundleArr = ures_getIntVector(subBundle, &subBundleSize, &errorCode);
127
128 if (minSize > subBundleSize) {
129 minSize = subBundleSize;
130 log_err("Arrays are different size with key \"%s\" in \"%s\" from root for locale \"%s\"\n",
131 subBundleKey,
132 ures_getKey(currentBundle),
133 locale);
134 }
135
136 for (idx = 0; idx < minSize && sameArray; idx++) {
137 if (subRootBundleArr[idx] != subBundleArr[idx]) {
138 sameArray = FALSE;
139 }
140 if (strcmp(subBundleKey, "DateTimeElements") == 0
141 && (subBundleArr[idx] < 1 || 7 < subBundleArr[idx]))
142 {
143 log_err("Value out of range with key \"%s\" at index %d in \"%s\" for locale \"%s\"\n",
144 subBundleKey,
145 idx,
146 ures_getKey(currentBundle),
147 locale);
148 }
149 }
150 /* Special exception es_US and DateTimeElements */
151 if (sameArray
152 && !(strcmp(locale, "es_US") == 0 && strcmp(subBundleKey, "DateTimeElements") == 0))
153 {
154 log_err("Integer vectors are the same with key \"%s\" in \"%s\" from root for locale \"%s\"\n",
155 subBundleKey,
156 ures_getKey(currentBundle),
157 locale);
158 }
159 }
160 else if (ures_getType(subBundle) == URES_ARRAY) {
161 UResourceBundle *subSubBundle = ures_getByIndex(subBundle, 0, NULL, &errorCode);
162 UResourceBundle *subSubRootBundle = ures_getByIndex(subRootBundle, 0, NULL, &errorCode);
163
164 if (U_SUCCESS(errorCode)
165 && (ures_getType(subSubBundle) == URES_ARRAY || ures_getType(subSubRootBundle) == URES_ARRAY))
166 {
167 /* Here is one of the recursive parts */
168 TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale);
169 }
170 else {
171 int32_t minSize = ures_getSize(subRootBundle);
172 int32_t idx;
173 UBool sameArray = TRUE;
174
175 if (minSize > ures_getSize(subBundle)) {
176 minSize = ures_getSize(subBundle);
177 }
178
179 if ((subBundleKey == NULL
180 || (subBundleKey != NULL && strcmp(subBundleKey, "LocaleScript") != 0 && !isCurrencyPreEuro(subBundleKey)))
181 && ures_getSize(subRootBundle) != ures_getSize(subBundle))
182 {
183 log_err("Different size array with key \"%s\" in \"%s\" from root for locale \"%s\"\n"
184 "\troot array size=%d, locale array size=%d\n",
185 subBundleKey,
186 ures_getKey(currentBundle),
187 locale,
188 ures_getSize(subRootBundle),
189 ures_getSize(subBundle));
190 }
191 /*
192 if(isCurrencyPreEuro(subBundleKey) && ures_getSize(subBundle)!=3){
193 log_err("Different size array with key \"%s\" in \"%s\" for locale \"%s\" the expected size is 3 got size=%d\n",
194 subBundleKey,
195 ures_getKey(currentBundle),
196 locale,
197 ures_getSize(subBundle));
198 }
199 */
200 for (idx = 0; idx < minSize; idx++) {
201 int32_t rootStrLen, localeStrLen;
202 const UChar *rootStr = ures_getStringByIndex(subRootBundle,idx,&rootStrLen,&errorCode);
203 const UChar *localeStr = ures_getStringByIndex(subBundle,idx,&localeStrLen,&errorCode);
204 if (rootStr && localeStr && U_SUCCESS(errorCode)) {
205 if (u_strcmp(rootStr, localeStr) != 0) {
206 sameArray = FALSE;
207 }
208 }
209 else {
210 if ( rootStrLen > 1 && rootStr[0] == 0x41 && rootStr[1] >= 0x30 && rootStr[1] <= 0x39 ) {
211 /* A2 or A4 in the root string indicates that the resource can optionally be an array instead of a */
212 /* string. Attempt to read it as an array. */
213 errorCode = U_ZERO_ERROR;
214 arr = ures_getByIndex(subBundle,idx,NULL,&errorCode);
215 if (U_FAILURE(errorCode)) {
216 log_err("Got a NULL string with key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n",
217 subBundleKey,
218 ures_getKey(currentBundle),
219 idx,
220 locale);
221 continue;
222 }
223 if (ures_getType(arr) != URES_ARRAY || ures_getSize(arr) != (int32_t)rootStr[1] - 0x30) {
224 log_err("Got something other than a string or array of size %d for key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n",
225 rootStr[1] - 0x30,
226 subBundleKey,
227 ures_getKey(currentBundle),
228 idx,
229 locale);
230 ures_close(arr);
231 continue;
232 }
233 localeStr = ures_getStringByIndex(arr,0,&localeStrLen,&errorCode);
234 ures_close(arr);
235 if (U_FAILURE(errorCode)) {
236 log_err("Got something other than a string or array for key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n",
237 subBundleKey,
238 ures_getKey(currentBundle),
239 idx,
240 locale);
241 continue;
242 }
243 } else {
244 log_err("Got a NULL string with key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n",
245 subBundleKey,
246 ures_getKey(currentBundle),
247 idx,
248 locale);
249 continue;
250 }
251 }
252 if (localeStr[0] == (UChar)0x20) {
253 log_err("key \"%s\" at index %d in \"%s\" starts with a space in locale \"%s\"\n",
254 subBundleKey,
255 idx,
256 ures_getKey(currentBundle),
257 locale);
258 }
259 else if ((localeStr[localeStrLen - 1] == (UChar)0x20) && (strcmp(subBundleKey,"separator") != 0)) {
260 log_err("key \"%s\" at index %d in \"%s\" ends with a space in locale \"%s\"\n",
261 subBundleKey,
262 idx,
263 ures_getKey(currentBundle),
264 locale);
265 }
266 else if (subBundleKey != NULL
267 && strcmp(subBundleKey, "DateTimePatterns") == 0)
268 {
269 int32_t quoted = 0;
270 const UChar *localeStrItr = localeStr;
271 while (*localeStrItr) {
272 if (*localeStrItr == (UChar)0x27 /* ' */) {
273 quoted++;
274 }
275 else if ((quoted % 2) == 0) {
276 /* Search for unquoted characters */
277 if (4 <= idx && idx <= 7
278 && (*localeStrItr == (UChar)0x6B /* k */
279 || *localeStrItr == (UChar)0x48 /* H */
280 || *localeStrItr == (UChar)0x6D /* m */
281 || *localeStrItr == (UChar)0x73 /* s */
282 || *localeStrItr == (UChar)0x53 /* S */
283 || *localeStrItr == (UChar)0x61 /* a */
284 || *localeStrItr == (UChar)0x68 /* h */
285 || *localeStrItr == (UChar)0x7A /* z */))
286 {
287 log_err("key \"%s\" at index %d has time pattern chars in date for locale \"%s\"\n",
288 subBundleKey,
289 idx,
290 locale);
291 }
292 else if (0 <= idx && idx <= 3
293 && (*localeStrItr == (UChar)0x47 /* G */
294 || *localeStrItr == (UChar)0x79 /* y */
295 || *localeStrItr == (UChar)0x4D /* M */
296 || *localeStrItr == (UChar)0x64 /* d */
297 || *localeStrItr == (UChar)0x45 /* E */
298 || *localeStrItr == (UChar)0x44 /* D */
299 || *localeStrItr == (UChar)0x46 /* F */
300 || *localeStrItr == (UChar)0x77 /* w */
301 || *localeStrItr == (UChar)0x57 /* W */))
302 {
303 log_err("key \"%s\" at index %d has date pattern chars in time for locale \"%s\"\n",
304 subBundleKey,
305 idx,
306 locale);
307 }
308 }
309 localeStrItr++;
310 }
311 }
312 else if (idx == 4 && subBundleKey != NULL
313 && strcmp(subBundleKey, "NumberElements") == 0
314 && u_charDigitValue(localeStr[0]) != 0)
315 {
316 log_err("key \"%s\" at index %d has a non-zero based number for locale \"%s\"\n",
317 subBundleKey,
318 idx,
319 locale);
320 }
321 }
322 (void)sameArray; /* Suppress set but not used warning. */
323 /* if (sameArray && strcmp(rootName, "root") == 0) {
324 log_err("Arrays are the same with key \"%s\" in \"%s\" from root for locale \"%s\"\n",
325 subBundleKey,
326 ures_getKey(currentBundle),
327 locale);
328 }*/
329 }
330 ures_close(subSubBundle);
331 ures_close(subSubRootBundle);
332 }
333 else if (ures_getType(subBundle) == URES_STRING) {
334 int32_t len = 0;
335 const UChar *string = ures_getString(subBundle, &len, &errorCode);
336 if (U_FAILURE(errorCode) || string == NULL) {
337 log_err("Can't open a string with key \"%s\" in \"%s\" for locale \"%s\"\n",
338 subBundleKey,
339 ures_getKey(currentBundle),
340 locale);
341 } else if (string[0] == (UChar)0x20) {
342 log_err("key \"%s\" in \"%s\" starts with a space in locale \"%s\"\n",
343 subBundleKey,
344 ures_getKey(currentBundle),
345 locale);
346 /* localeDisplayPattern/separator can end with a space */
347 } else if (string[len - 1] == (UChar)0x20 && (strcmp(subBundleKey,"separator"))) {
348 log_err("key \"%s\" in \"%s\" ends with a space in locale \"%s\"\n",
349 subBundleKey,
350 ures_getKey(currentBundle),
351 locale);
352 } else if (strcmp(subBundleKey, "localPatternChars") == 0) {
353 /* Note: We no longer import localPatternChars data starting
354 * ICU 3.8. So it never comes into this else if block. (ticket#5597)
355 */
356
357 /* Check well-formedness of localPatternChars. First, the
358 * length must match the number of fields defined by
359 * DateFormat. Second, each character in the string must
360 * be in the set [A-Za-z]. Finally, each character must be
361 * unique.
362 */
363 int32_t i,j;
364 #if !UCONFIG_NO_FORMATTING
365 if (len != UDAT_FIELD_COUNT) {
366 log_err("key \"%s\" has the wrong number of characters in locale \"%s\"\n",
367 subBundleKey,
368 locale);
369 }
370 #endif
371 /* Check char validity. */
372 for (i=0; i<len; ++i) {
373 if (!((string[i] >= 65/*'A'*/ && string[i] <= 90/*'Z'*/) ||
374 (string[i] >= 97/*'a'*/ && string[i] <= 122/*'z'*/))) {
375 log_err("key \"%s\" has illegal character '%c' in locale \"%s\"\n",
376 subBundleKey,
377 (char) string[i],
378 locale);
379 }
380 /* Do O(n^2) check for duplicate chars. */
381 for (j=0; j<i; ++j) {
382 if (string[j] == string[i]) {
383 log_err("key \"%s\" has duplicate character '%c' in locale \"%s\"\n",
384 subBundleKey,
385 (char) string[i],
386 locale);
387 }
388 }
389 }
390 }
391 /* No fallback was done. Check for duplicate data */
392 /* The ures_* API does not do fallback of sub-resource bundles,
393 So we can't do this now. */
394 #if 0
395 else if (strcmp(locale, "root") != 0 && errorCode == U_ZERO_ERROR) {
396
397 const UChar *rootString = ures_getString(subRootBundle, &len, &errorCode);
398 if (U_FAILURE(errorCode) || rootString == NULL) {
399 log_err("Can't open a string with key \"%s\" in \"%s\" in root\n",
400 ures_getKey(subRootBundle),
401 ures_getKey(currentBundle));
402 continue;
403 } else if (u_strcmp(string, rootString) == 0) {
404 if (strcmp(locale, "de_CH") != 0 && strcmp(subBundleKey, "Countries") != 0 &&
405 strcmp(subBundleKey, "Version") != 0) {
406 log_err("Found duplicate data with key \"%s\" in \"%s\" in locale \"%s\"\n",
407 ures_getKey(subRootBundle),
408 ures_getKey(currentBundle),
409 locale);
410 }
411 else {
412 /* Ignore for now. */
413 /* Can be fixed if fallback through de locale was done. */
414 log_verbose("Skipping key %s in %s\n", subBundleKey, locale);
415 }
416 }
417 }
418 #endif
419 }
420 else if (ures_getType(subBundle) == URES_TABLE) {
421 if (strcmp(subBundleKey, "availableFormats")!=0) {
422 /* Here is one of the recursive parts */
423 TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale);
424 }
425 else {
426 log_verbose("Skipping key %s in %s\n", subBundleKey, locale);
427 }
428 }
429 else if (ures_getType(subBundle) == URES_BINARY || ures_getType(subBundle) == URES_INT) {
430 /* Can't do anything to check it */
431 /* We'll assume it's all correct */
432 if (strcmp(subBundleKey, "MeasurementSystem") != 0) {
433 log_verbose("Skipping key \"%s\" in \"%s\" for locale \"%s\"\n",
434 subBundleKey,
435 ures_getKey(currentBundle),
436 locale);
437 }
438 /* Testing for MeasurementSystem is done in VerifyTranslation */
439 }
440 else {
441 log_err("Type %d for key \"%s\" in \"%s\" is unknown for locale \"%s\"\n",
442 ures_getType(subBundle),
443 subBundleKey,
444 ures_getKey(currentBundle),
445 locale);
446 }
447 ures_close(subRootBundle);
448 ures_close(subBundle);
449 }
450 }
451 #endif
452
453 static void
testLCID(UResourceBundle * currentBundle,const char * localeName)454 testLCID(UResourceBundle *currentBundle,
455 const char *localeName)
456 {
457 (void)currentBundle; // suppress compiler warnings about unused variables
458 UErrorCode status = U_ZERO_ERROR;
459 uint32_t expectedLCID;
460 char lcidStringC[64] = {0};
461 int32_t len;
462
463 expectedLCID = uloc_getLCID(localeName);
464 if (expectedLCID == 0) {
465 log_verbose("INFO: %-5s does not have any LCID mapping\n",
466 localeName);
467 return;
468 }
469
470 status = U_ZERO_ERROR;
471 len = uprv_convertToPosix(expectedLCID, lcidStringC, UPRV_LENGTHOF(lcidStringC) - 1, &status);
472 if (U_FAILURE(status)) {
473 log_err("ERROR: %.4x does not have a POSIX mapping due to %s\n",
474 expectedLCID, u_errorName(status));
475 }
476 lcidStringC[len] = 0;
477
478 if(strcmp(localeName, lcidStringC) != 0) {
479 char langName[1024];
480 char langLCID[1024];
481 uloc_getLanguage(localeName, langName, sizeof(langName), &status);
482 uloc_getLanguage(lcidStringC, langLCID, sizeof(langLCID), &status);
483
484 if (strcmp(langName, langLCID) == 0) {
485 log_verbose("WARNING: %-5s resolves to %s (0x%.4x)\n",
486 localeName, lcidStringC, expectedLCID);
487 }
488 else if (!(strcmp(localeName, "ku") == 0 && log_knownIssue("20181", "ICU-20181 Fix LCID mapping for ckb vs ku"))) {
489 log_err("ERROR: %-5s has 0x%.4x and the number resolves wrongfully to %s\n",
490 localeName, expectedLCID, lcidStringC);
491 }
492 }
493 }
494
495 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
496 static void
TestLocaleStructure(void)497 TestLocaleStructure(void) {
498 // This test checks the locale structure against a key file located
499 // at source/test/testdata/structLocale.txt. When adding new data to
500 // a locale file such as en.txt, the structLocale.txt file must be changed
501 // too to include the the template of the new data. Otherwise this test
502 // will fail!
503
504 UResourceBundle *root, *currentLocale;
505 int32_t locCount = uloc_countAvailable();
506 int32_t locIndex;
507 UErrorCode errorCode = U_ZERO_ERROR;
508 const char *currLoc, *resolvedLoc;
509
510 /* TODO: Compare against parent's data too. This code can't handle fallbacks that some tools do already. */
511 /* char locName[ULOC_FULLNAME_CAPACITY];
512 char *locNamePtr;
513
514 for (locIndex = 0; locIndex < locCount; locIndex++) {
515 errorCode=U_ZERO_ERROR;
516 strcpy(locName, uloc_getAvailable(locIndex));
517 locNamePtr = strrchr(locName, '_');
518 if (locNamePtr) {
519 *locNamePtr = 0;
520 }
521 else {
522 strcpy(locName, "root");
523 }
524
525 root = ures_openDirect(NULL, locName, &errorCode);
526 if(U_FAILURE(errorCode)) {
527 log_err("Can't open %s\n", locName);
528 continue;
529 }
530 */
531 if (locCount <= 1) {
532 log_data_err("At least root needs to be installed\n");
533 }
534
535 root = ures_openDirect(loadTestData(&errorCode), "structLocale", &errorCode);
536 if(U_FAILURE(errorCode)) {
537 log_data_err("Can't open structLocale\n");
538 return;
539 }
540 for (locIndex = 0; locIndex < locCount; locIndex++) {
541 errorCode=U_ZERO_ERROR;
542 currLoc = uloc_getAvailable(locIndex);
543 currentLocale = ures_open(NULL, currLoc, &errorCode);
544 if(errorCode != U_ZERO_ERROR) {
545 if(U_SUCCESS(errorCode)) {
546 /* It's installed, but there is no data.
547 It's installed for the g18n white paper [grhoten] */
548 log_err("ERROR: Locale %-5s not installed, and it should be, err %s\n",
549 uloc_getAvailable(locIndex), u_errorName(errorCode));
550 } else {
551 log_err("%%%%%%% Unexpected error %d in %s %%%%%%%",
552 u_errorName(errorCode),
553 uloc_getAvailable(locIndex));
554 }
555 ures_close(currentLocale);
556 continue;
557 }
558 const UChar *version = ures_getStringByKey(currentLocale, "Version", NULL, &errorCode);
559 if(U_FAILURE(errorCode)) {
560 log_err("No version information is available for locale %s, and it should be!\n",
561 currLoc);
562 }
563 else if (version[0] == u'x') {
564 log_verbose("WARNING: The locale %s is experimental! "
565 "It shouldn't be listed as an installed locale.\n",
566 currLoc);
567 }
568 resolvedLoc = ures_getLocaleByType(currentLocale, ULOC_ACTUAL_LOCALE, &errorCode);
569 if (strcmp(resolvedLoc, currLoc) != 0) {
570 log_err("Locale resolves to different locale. Is %s an alias of %s?\n",
571 currLoc, resolvedLoc);
572 }
573 TestKeyInRootRecursive(root, "root", currentLocale, currLoc);
574
575 testLCID(currentLocale, currLoc);
576
577 ures_close(currentLocale);
578 }
579
580 ures_close(root);
581 }
582 #endif
583
584 static void
compareArrays(const char * keyName,UResourceBundle * fromArray,const char * fromLocale,UResourceBundle * toArray,const char * toLocale,int32_t start,int32_t end)585 compareArrays(const char *keyName,
586 UResourceBundle *fromArray, const char *fromLocale,
587 UResourceBundle *toArray, const char *toLocale,
588 int32_t start, int32_t end)
589 {
590 int32_t fromSize = ures_getSize(fromArray);
591 int32_t toSize = ures_getSize(fromArray);
592 int32_t idx;
593 UErrorCode errorCode = U_ZERO_ERROR;
594
595 if (fromSize > toSize) {
596 fromSize = toSize;
597 log_err("Arrays are different size from \"%s\" to \"%s\"\n",
598 fromLocale,
599 toLocale);
600 }
601
602 for (idx = start; idx <= end; idx++) {
603 const UChar *fromBundleStr = ures_getStringByIndex(fromArray, idx, NULL, &errorCode);
604 const UChar *toBundleStr = ures_getStringByIndex(toArray, idx, NULL, &errorCode);
605 if (fromBundleStr && toBundleStr && u_strcmp(fromBundleStr, toBundleStr) != 0)
606 {
607 log_err("Difference for %s at index %d from %s= \"%s\" to %s= \"%s\"\n",
608 keyName,
609 idx,
610 fromLocale,
611 austrdup(fromBundleStr),
612 toLocale,
613 austrdup(toBundleStr));
614 }
615 }
616 }
617
618 static void
compareConsistentCountryInfo(const char * fromLocale,const char * toLocale)619 compareConsistentCountryInfo(const char *fromLocale, const char *toLocale) {
620 UErrorCode errorCode = U_ZERO_ERROR;
621 UResourceBundle *fromArray, *toArray;
622 UResourceBundle *fromLocaleBund = ures_open(NULL, fromLocale, &errorCode);
623 UResourceBundle *toLocaleBund = ures_open(NULL, toLocale, &errorCode);
624 UResourceBundle *toCalendar, *fromCalendar, *toGregorian, *fromGregorian;
625
626 if(U_FAILURE(errorCode)) {
627 log_err("Can't open resource bundle %s or %s - %s\n", fromLocale, toLocale, u_errorName(errorCode));
628 return;
629 }
630 fromCalendar = ures_getByKey(fromLocaleBund, "calendar", NULL, &errorCode);
631 fromGregorian = ures_getByKeyWithFallback(fromCalendar, "gregorian", NULL, &errorCode);
632
633 toCalendar = ures_getByKey(toLocaleBund, "calendar", NULL, &errorCode);
634 toGregorian = ures_getByKeyWithFallback(toCalendar, "gregorian", NULL, &errorCode);
635
636 fromArray = ures_getByKey(fromLocaleBund, "CurrencyElements", NULL, &errorCode);
637 toArray = ures_getByKey(toLocaleBund, "CurrencyElements", NULL, &errorCode);
638 if (strcmp(fromLocale, "en_CA") != 0)
639 {
640 /* The first one is probably localized. */
641 compareArrays("CurrencyElements", fromArray, fromLocale, toArray, toLocale, 1, 2);
642 }
643 ures_close(fromArray);
644 ures_close(toArray);
645
646 fromArray = ures_getByKey(fromLocaleBund, "NumberPatterns", NULL, &errorCode);
647 toArray = ures_getByKey(toLocaleBund, "NumberPatterns", NULL, &errorCode);
648 if (strcmp(fromLocale, "en_CA") != 0)
649 {
650 compareArrays("NumberPatterns", fromArray, fromLocale, toArray, toLocale, 0, 3);
651 }
652 ures_close(fromArray);
653 ures_close(toArray);
654
655 /* Difficult to test properly */
656 /*
657 fromArray = ures_getByKey(fromLocaleBund, "DateTimePatterns", NULL, &errorCode);
658 toArray = ures_getByKey(toLocaleBund, "DateTimePatterns", NULL, &errorCode);
659 {
660 compareArrays("DateTimePatterns", fromArray, fromLocale, toArray, toLocale);
661 }
662 ures_close(fromArray);
663 ures_close(toArray);*/
664
665 fromArray = ures_getByKey(fromLocaleBund, "NumberElements", NULL, &errorCode);
666 toArray = ures_getByKey(toLocaleBund, "NumberElements", NULL, &errorCode);
667 if (strcmp(fromLocale, "en_CA") != 0)
668 {
669 compareArrays("NumberElements", fromArray, fromLocale, toArray, toLocale, 0, 3);
670 /* Index 4 is a script based 0 */
671 compareArrays("NumberElements", fromArray, fromLocale, toArray, toLocale, 5, 10);
672 }
673 ures_close(fromArray);
674 ures_close(toArray);
675 ures_close(fromCalendar);
676 ures_close(toCalendar);
677 ures_close(fromGregorian);
678 ures_close(toGregorian);
679
680 ures_close(fromLocaleBund);
681 ures_close(toLocaleBund);
682 }
683
684 static void
TestConsistentCountryInfo(void)685 TestConsistentCountryInfo(void) {
686 /* UResourceBundle *fromLocale, *toLocale;*/
687 int32_t locCount = uloc_countAvailable();
688 int32_t fromLocIndex, toLocIndex;
689
690 int32_t fromCountryLen, toCountryLen;
691 char fromCountry[ULOC_FULLNAME_CAPACITY], toCountry[ULOC_FULLNAME_CAPACITY];
692
693 int32_t fromVariantLen, toVariantLen;
694 char fromVariant[ULOC_FULLNAME_CAPACITY], toVariant[ULOC_FULLNAME_CAPACITY];
695
696 UErrorCode errorCode = U_ZERO_ERROR;
697
698 for (fromLocIndex = 0; fromLocIndex < locCount; fromLocIndex++) {
699 const char *fromLocale = uloc_getAvailable(fromLocIndex);
700
701 errorCode=U_ZERO_ERROR;
702 fromCountryLen = uloc_getCountry(fromLocale, fromCountry, ULOC_FULLNAME_CAPACITY, &errorCode);
703 if (fromCountryLen <= 0) {
704 /* Ignore countryless locales */
705 continue;
706 }
707 fromVariantLen = uloc_getVariant(fromLocale, fromVariant, ULOC_FULLNAME_CAPACITY, &errorCode);
708 if (fromVariantLen > 0) {
709 /* Most variants are ignorable like collation variants. */
710 continue;
711 }
712 /* Start comparing only after the current index.
713 Previous loop should have already compared fromLocIndex.
714 */
715 for (toLocIndex = fromLocIndex + 1; toLocIndex < locCount; toLocIndex++) {
716 const char *toLocale = uloc_getAvailable(toLocIndex);
717
718 toCountryLen = uloc_getCountry(toLocale, toCountry, ULOC_FULLNAME_CAPACITY, &errorCode);
719 if(U_FAILURE(errorCode)) {
720 log_err("Unknown failure fromLocale=%s toLocale=%s errorCode=%s\n",
721 fromLocale, toLocale, u_errorName(errorCode));
722 continue;
723 }
724
725 if (toCountryLen <= 0) {
726 /* Ignore countryless locales */
727 continue;
728 }
729 toVariantLen = uloc_getVariant(toLocale, toVariant, ULOC_FULLNAME_CAPACITY, &errorCode);
730 if (toVariantLen > 0) {
731 /* Most variants are ignorable like collation variants. */
732 /* They're a variant for a reason. */
733 continue;
734 }
735 if (strcmp(fromCountry, toCountry) == 0) {
736 log_verbose("comparing fromLocale=%s toLocale=%s\n",
737 fromLocale, toLocale);
738 compareConsistentCountryInfo(fromLocale, toLocale);
739 }
740 }
741 }
742 }
743
744 static int32_t
findStringSetMismatch(const char * currLoc,const UChar * string,int32_t langSize,USet * mergedExemplarSet,UBool ignoreNumbers,UChar32 * badCharPtr)745 findStringSetMismatch(const char *currLoc, const UChar *string, int32_t langSize,
746 USet * mergedExemplarSet,
747 UBool ignoreNumbers, UChar32* badCharPtr) {
748 UErrorCode errorCode = U_ZERO_ERROR;
749 USet *exemplarSet;
750 int32_t strIdx;
751 if (mergedExemplarSet == NULL) {
752 return -1;
753 }
754 exemplarSet = createFlattenSet(mergedExemplarSet, &errorCode);
755 if (U_FAILURE(errorCode)) {
756 log_err("%s: error createFlattenSet returned %s\n", currLoc, u_errorName(errorCode));
757 return -1;
758 }
759
760 for (strIdx = 0; strIdx < langSize;) {
761 UChar32 testChar;
762 U16_NEXT(string, strIdx, langSize, testChar);
763 if (!uset_contains(exemplarSet, testChar)
764 && testChar != 0x0020 && testChar != 0x00A0 && testChar != 0x002e && testChar != 0x002c && testChar != 0x002d && testChar != 0x0027
765 && testChar != 0x005B && testChar != 0x005D && testChar != 0x2019 && testChar != 0x0f0b && testChar != 0x200C && testChar != 0x200D) {
766 if (!ignoreNumbers || (ignoreNumbers && (testChar < 0x30 || testChar > 0x39))) {
767 uset_close(exemplarSet);
768 if (badCharPtr) {
769 *badCharPtr = testChar;
770 }
771 return strIdx;
772 }
773 }
774 }
775 uset_close(exemplarSet);
776 if (badCharPtr) {
777 *badCharPtr = 0;
778 }
779 return -1;
780 }
781 /* include non-invariant chars */
782 static int32_t
myUCharsToChars(const UChar * us,char * cs,int32_t len)783 myUCharsToChars(const UChar* us, char* cs, int32_t len){
784 int32_t i=0;
785 for(; i< len; i++){
786 if(us[i] < 0x7f){
787 cs[i] = (char)us[i];
788 }else{
789 return -1;
790 }
791 }
792 return i;
793 }
794 static void
findSetMatch(UScriptCode * scriptCodes,int32_t scriptsLen,USet * exemplarSet,const char * locale)795 findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen,
796 USet *exemplarSet,
797 const char *locale){
798 USet *scripts[10]= {0};
799 char pattern[256] = { '[', ':', 0x000 };
800 int32_t patternLen;
801 UChar uPattern[256] = {0};
802 UErrorCode status = U_ZERO_ERROR;
803 int32_t i;
804
805 /* create the sets with script codes */
806 for(i = 0; i<scriptsLen; i++){
807 strcat(pattern, uscript_getShortName(scriptCodes[i]));
808 strcat(pattern, ":]");
809 patternLen = (int32_t)strlen(pattern);
810 u_charsToUChars(pattern, uPattern, patternLen);
811 scripts[i] = uset_openPattern(uPattern, patternLen, &status);
812 if(U_FAILURE(status)){
813 log_err("Could not create set for pattern %s. Error: %s\n", pattern, u_errorName(status));
814 return;
815 }
816 pattern[2] = 0;
817 }
818 if (strcmp(locale, "uk") == 0 || strcmp(locale, "uk_UA") == 0) {
819 /* Special addition. Add the modifying apostrophe, which isn't in Cyrillic. */
820 uset_add(scripts[0], 0x2bc);
821 }
822 if(U_SUCCESS(status)){
823 UBool existsInScript = FALSE;
824 /* iterate over the exemplarSet and ascertain if all
825 * UChars in exemplarSet belong to the scripts returned
826 * by getScript
827 */
828 int32_t count = uset_getItemCount(exemplarSet);
829
830 for( i=0; i < count; i++){
831 UChar32 start = 0;
832 UChar32 end = 0;
833 UChar *str = NULL;
834 int32_t strCapacity = 0;
835
836 strCapacity = uset_getItem(exemplarSet, i, &start, &end, str, strCapacity, &status);
837 if(U_SUCCESS(status)){
838 int32_t j;
839 if(strCapacity == 0){
840 /* ok the item is a range */
841 for( j = 0; j < scriptsLen; j++){
842 if(uset_containsRange(scripts[j], start, end) == TRUE){
843 existsInScript = TRUE;
844 }
845 }
846 if(existsInScript == FALSE){
847 for( j = 0; j < scriptsLen; j++){
848 UChar toPattern[500]={'\0'};
849 char pat[500]={'\0'};
850 int32_t len = uset_toPattern(scripts[j], toPattern, 500, TRUE, &status);
851 len = myUCharsToChars(toPattern, pat, len);
852 log_err("uset_indexOf(\\u%04X)=%i uset_indexOf(\\u%04X)=%i\n", start, uset_indexOf(scripts[0], start), end, uset_indexOf(scripts[0], end));
853 if(len!=-1){
854 log_err("Pattern: %s\n",pat);
855 }
856 }
857 log_err("ExemplarCharacters and LocaleScript containment test failed for locale %s. \n", locale);
858 }
859 }else{
860 strCapacity++; /* increment for NUL termination */
861 /* allocate the str and call the api again */
862 str = (UChar*) malloc(U_SIZEOF_UCHAR * strCapacity);
863 strCapacity = uset_getItem(exemplarSet, i, &start, &end, str, strCapacity, &status);
864 /* iterate over the scripts and figure out if the string contained is actually
865 * in the script set
866 */
867 for( j = 0; j < scriptsLen; j++){
868 if(uset_containsString(scripts[j],str, strCapacity) == TRUE){
869 existsInScript = TRUE;
870 }
871 }
872 if(existsInScript == FALSE){
873 log_err("ExemplarCharacters and LocaleScript containment test failed for locale %s. \n", locale);
874 }
875 }
876 }
877 }
878
879 }
880
881 /* close the sets */
882 for(i = 0; i<scriptsLen; i++){
883 uset_close(scripts[i]);
884 }
885 }
886
VerifyTranslation(void)887 static void VerifyTranslation(void) {
888 UResourceBundle *root, *currentLocale;
889 int32_t locCount = uloc_countAvailable();
890 int32_t locIndex;
891 UErrorCode errorCode = U_ZERO_ERROR;
892 const char *currLoc;
893 UScriptCode scripts[USCRIPT_CODE_LIMIT];
894 int32_t numScripts;
895 int32_t idx;
896 int32_t end;
897 UResourceBundle *resArray;
898
899 if (locCount <= 1) {
900 log_data_err("At least root needs to be installed\n");
901 }
902
903 root = ures_openDirect(NULL, "root", &errorCode);
904 if(U_FAILURE(errorCode)) {
905 log_data_err("Can't open root\n");
906 return;
907 }
908 for (locIndex = 0; locIndex < locCount; locIndex++) {
909 USet * mergedExemplarSet = NULL;
910 errorCode=U_ZERO_ERROR;
911 currLoc = uloc_getAvailable(locIndex);
912 // BEGIN Android patch: Android enables pesudolocale ar_XB, but doesn't pass this test. http://b/145129186
913 if (strcmp("ar_XB", currLoc) == 0) {
914 continue;
915 }
916 // END Android patch: Android enables pesudolocale ar_XB, but doesn't pass this test. http://b/145129186
917 currentLocale = ures_open(NULL, currLoc, &errorCode);
918 if(errorCode != U_ZERO_ERROR) {
919 if(U_SUCCESS(errorCode)) {
920 /* It's installed, but there is no data.
921 It's installed for the g18n white paper [grhoten] */
922 log_err("ERROR: Locale %-5s not installed, and it should be!\n",
923 uloc_getAvailable(locIndex));
924 } else {
925 log_err("%%%%%%% Unexpected error %d in %s %%%%%%%",
926 u_errorName(errorCode),
927 uloc_getAvailable(locIndex));
928 }
929 ures_close(currentLocale);
930 continue;
931 }
932 {
933 UErrorCode exemplarStatus = U_ZERO_ERROR;
934 ULocaleData * uld = ulocdata_open(currLoc, &exemplarStatus);
935 if (U_SUCCESS(exemplarStatus)) {
936 USet * exemplarSet = ulocdata_getExemplarSet(uld, NULL, USET_ADD_CASE_MAPPINGS, ULOCDATA_ES_STANDARD, &exemplarStatus);
937 if (U_SUCCESS(exemplarStatus)) {
938 mergedExemplarSet = uset_cloneAsThawed(exemplarSet);
939 uset_close(exemplarSet);
940 exemplarSet = ulocdata_getExemplarSet(uld, NULL, USET_ADD_CASE_MAPPINGS, ULOCDATA_ES_AUXILIARY, &exemplarStatus);
941 if (U_SUCCESS(exemplarStatus)) {
942 uset_addAll(mergedExemplarSet, exemplarSet);
943 uset_close(exemplarSet);
944 }
945 exemplarStatus = U_ZERO_ERROR;
946 exemplarSet = ulocdata_getExemplarSet(uld, NULL, 0, ULOCDATA_ES_PUNCTUATION, &exemplarStatus);
947 if (U_SUCCESS(exemplarStatus)) {
948 uset_addAll(mergedExemplarSet, exemplarSet);
949 uset_close(exemplarSet);
950 }
951 } else {
952 log_err("error ulocdata_getExemplarSet (main) for locale %s returned %s\n", currLoc, u_errorName(errorCode));
953 }
954 ulocdata_close(uld);
955 } else {
956 log_err("error ulocdata_open for locale %s returned %s\n", currLoc, u_errorName(errorCode));
957 }
958 }
959 if (mergedExemplarSet == NULL /*|| (getTestOption(QUICK_OPTION) && uset_size() > 2048)*/) {
960 log_verbose("skipping test for %s\n", currLoc);
961 }
962 //else if (uprv_strncmp(currLoc,"bem",3) == 0 || uprv_strncmp(currLoc,"mgo",3) == 0 || uprv_strncmp(currLoc,"nl",2) == 0) {
963 // log_verbose("skipping test for %s, some month and country names known to use aux exemplars\n", currLoc);
964 //}
965 else {
966 UChar langBuffer[128];
967 int32_t langSize;
968 int32_t strIdx;
969 UChar32 badChar;
970 langSize = uloc_getDisplayLanguage(currLoc, currLoc, langBuffer, UPRV_LENGTHOF(langBuffer), &errorCode);
971 if (U_FAILURE(errorCode)) {
972 log_err("error uloc_getDisplayLanguage returned %s\n", u_errorName(errorCode));
973 }
974 else {
975 strIdx = findStringSetMismatch(currLoc, langBuffer, langSize, mergedExemplarSet, FALSE, &badChar);
976 if (strIdx >= 0) {
977 log_err("getDisplayLanguage(%s) at index %d returned characters not in the exemplar characters: %04X.\n",
978 currLoc, strIdx, badChar);
979 }
980 }
981 langSize = uloc_getDisplayCountry(currLoc, currLoc, langBuffer, UPRV_LENGTHOF(langBuffer), &errorCode);
982 if (U_FAILURE(errorCode)) {
983 log_err("error uloc_getDisplayCountry returned %s\n", u_errorName(errorCode));
984 }
985 {
986 UResourceBundle* cal = ures_getByKey(currentLocale, "calendar", NULL, &errorCode);
987 UResourceBundle* greg = ures_getByKeyWithFallback(cal, "gregorian", NULL, &errorCode);
988 UResourceBundle* names = ures_getByKeyWithFallback(greg, "dayNames", NULL, &errorCode);
989 UResourceBundle* format = ures_getByKeyWithFallback(names, "format", NULL, &errorCode);
990 resArray = ures_getByKeyWithFallback(format, "wide", NULL, &errorCode);
991
992 if (U_FAILURE(errorCode)) {
993 log_err("error ures_getByKey returned %s\n", u_errorName(errorCode));
994 }
995 if (getTestOption(QUICK_OPTION)) {
996 end = 1;
997 }
998 else {
999 end = ures_getSize(resArray);
1000 }
1001
1002 if ((uprv_strncmp(currLoc,"lrc",3) == 0 || uprv_strncmp(currLoc,"mzn",3) == 0) &&
1003 log_knownIssue("cldrbug:8899", "lrc and mzn locales don't have translated day names")) {
1004 end = 0;
1005 }
1006 if ((uprv_strncmp(currLoc,"mai",3) == 0 || uprv_strncmp(currLoc,"sd_Deva",7) == 0) &&
1007 log_knownIssue("cldrbug:14995", "mai/sd_Deva day names use chars not in exemplars")) {
1008 end = 0;
1009 }
1010
1011 for (idx = 0; idx < end; idx++) {
1012 const UChar *fromBundleStr = ures_getStringByIndex(resArray, idx, &langSize, &errorCode);
1013 if (U_FAILURE(errorCode)) {
1014 log_err("error ures_getStringByIndex(%d) returned %s\n", idx, u_errorName(errorCode));
1015 continue;
1016 }
1017 strIdx = findStringSetMismatch(currLoc, fromBundleStr, langSize, mergedExemplarSet, TRUE, &badChar);
1018 if ( strIdx >= 0 ) {
1019 log_err("getDayNames(%s, %d) at index %d returned characters not in the exemplar characters: %04X.\n",
1020 currLoc, idx, strIdx, badChar);
1021 }
1022 }
1023 ures_close(resArray);
1024 ures_close(format);
1025 ures_close(names);
1026
1027 names = ures_getByKeyWithFallback(greg, "monthNames", NULL, &errorCode);
1028 format = ures_getByKeyWithFallback(names,"format", NULL, &errorCode);
1029 resArray = ures_getByKeyWithFallback(format, "wide", NULL, &errorCode);
1030 if (U_FAILURE(errorCode)) {
1031 log_err("error ures_getByKey returned %s\n", u_errorName(errorCode));
1032 }
1033 if (getTestOption(QUICK_OPTION)) {
1034 end = 1;
1035 }
1036 else {
1037 end = ures_getSize(resArray);
1038 }
1039 if (uprv_strncmp(currLoc,"sd_Deva",7) == 0 &&
1040 log_knownIssue("cldrbug:14995", "sd_Deva month names use chars not in exemplars")) {
1041 end = 0;
1042 }
1043
1044 for (idx = 0; idx < end; idx++) {
1045 const UChar *fromBundleStr = ures_getStringByIndex(resArray, idx, &langSize, &errorCode);
1046 if (U_FAILURE(errorCode)) {
1047 log_err("error ures_getStringByIndex(%d) returned %s\n", idx, u_errorName(errorCode));
1048 continue;
1049 }
1050 strIdx = findStringSetMismatch(currLoc, fromBundleStr, langSize, mergedExemplarSet, TRUE, &badChar);
1051 if (strIdx >= 0) {
1052 log_err("getMonthNames(%s, %d) at index %d returned characters not in the exemplar characters: %04X.\n",
1053 currLoc, idx, strIdx, badChar);
1054 }
1055 }
1056 ures_close(resArray);
1057 ures_close(format);
1058 ures_close(names);
1059 ures_close(greg);
1060 ures_close(cal);
1061 }
1062 errorCode = U_ZERO_ERROR;
1063 numScripts = uscript_getCode(currLoc, scripts, UPRV_LENGTHOF(scripts), &errorCode);
1064 if (strcmp(currLoc, "yi") == 0 && numScripts > 0 && log_knownIssue("11217", "Fix result of uscript_getCode for yi: USCRIPT_YI -> USCRIPT_HEBREW")) {
1065 scripts[0] = USCRIPT_HEBREW;
1066 }
1067 if (numScripts == 0) {
1068 log_err("uscript_getCode(%s) doesn't work.\n", currLoc);
1069 }else if(scripts[0] == USCRIPT_COMMON){
1070 log_err("uscript_getCode(%s) returned USCRIPT_COMMON.\n", currLoc);
1071 }
1072
1073 /* test that the scripts are a superset of exemplar characters. */
1074 {
1075 ULocaleData *uld = ulocdata_open(currLoc,&errorCode);
1076 USet *exemplarSet = ulocdata_getExemplarSet(uld, NULL, 0, ULOCDATA_ES_STANDARD, &errorCode);
1077 /* test if exemplar characters are part of script code */
1078 findSetMatch(scripts, numScripts, exemplarSet, currLoc);
1079 uset_close(exemplarSet);
1080 ulocdata_close(uld);
1081 }
1082
1083 /* test that the paperSize API works */
1084 {
1085 int32_t height=0, width=0;
1086 ulocdata_getPaperSize(currLoc, &height, &width, &errorCode);
1087 if(U_FAILURE(errorCode)){
1088 log_err("ulocdata_getPaperSize failed for locale %s with error: %s \n", currLoc, u_errorName(errorCode));
1089 }
1090 if(strstr(currLoc, "_US")!=NULL && height != 279 && width != 216 ){
1091 log_err("ulocdata_getPaperSize did not return expected data for locale %s \n", currLoc);
1092 }
1093 }
1094 /* test that the MeasurementSystem API works */
1095 {
1096 char fullLoc[ULOC_FULLNAME_CAPACITY];
1097 UMeasurementSystem measurementSystem;
1098 int32_t height = 0, width = 0;
1099
1100 uloc_addLikelySubtags(currLoc, fullLoc, ULOC_FULLNAME_CAPACITY, &errorCode);
1101
1102 errorCode = U_ZERO_ERROR;
1103 measurementSystem = ulocdata_getMeasurementSystem(currLoc, &errorCode);
1104 if (U_FAILURE(errorCode)) {
1105 log_err("ulocdata_getMeasurementSystem failed for locale %s with error: %s \n", currLoc, u_errorName(errorCode));
1106 } else {
1107 if ( strstr(fullLoc, "_US")!=NULL || strstr(fullLoc, "_LR")!=NULL ) {
1108 if(measurementSystem != UMS_US){
1109 log_err("ulocdata_getMeasurementSystem did not return expected data for locale %s \n", currLoc);
1110 }
1111 } else if ( strstr(fullLoc, "_GB")!=NULL || strstr(fullLoc, "_MM")!=NULL ) {
1112 if(measurementSystem != UMS_UK){
1113 log_err("ulocdata_getMeasurementSystem did not return expected data for locale %s \n", currLoc);
1114 }
1115 } else if (measurementSystem != UMS_SI) {
1116 log_err("ulocdata_getMeasurementSystem did not return expected data for locale %s \n", currLoc);
1117 }
1118 }
1119
1120 errorCode = U_ZERO_ERROR;
1121 ulocdata_getPaperSize(currLoc, &height, &width, &errorCode);
1122 if (U_FAILURE(errorCode)) {
1123 log_err("ulocdata_getPaperSize failed for locale %s with error: %s \n", currLoc, u_errorName(errorCode));
1124 } else {
1125 if ( strstr(fullLoc, "_US")!=NULL || strstr(fullLoc, "_BZ")!=NULL || strstr(fullLoc, "_CA")!=NULL || strstr(fullLoc, "_CL")!=NULL ||
1126 strstr(fullLoc, "_CO")!=NULL || strstr(fullLoc, "_CR")!=NULL || strstr(fullLoc, "_GT")!=NULL || strstr(fullLoc, "_MX")!=NULL ||
1127 strstr(fullLoc, "_NI")!=NULL || strstr(fullLoc, "_PA")!=NULL || strstr(fullLoc, "_PH")!=NULL || strstr(fullLoc, "_PR")!=NULL ||
1128 strstr(fullLoc, "_SV")!=NULL || strstr(fullLoc, "_VE")!=NULL ) {
1129 if (height != 279 || width != 216) {
1130 log_err("ulocdata_getPaperSize did not return expected data for locale %s \n", currLoc);
1131 }
1132 } else if (height != 297 || width != 210) {
1133 log_err("ulocdata_getPaperSize did not return expected data for locale %s \n", currLoc);
1134 }
1135 }
1136 }
1137 }
1138 if (mergedExemplarSet != NULL) {
1139 uset_close(mergedExemplarSet);
1140 }
1141 ures_close(currentLocale);
1142 }
1143
1144 ures_close(root);
1145 }
1146
1147 /* adjust this limit as appropriate */
1148 #define MAX_SCRIPTS_PER_LOCALE 8
1149
TestExemplarSet(void)1150 static void TestExemplarSet(void){
1151 int32_t i, j, k, m, n;
1152 int32_t equalCount = 0;
1153 UErrorCode ec = U_ZERO_ERROR;
1154 UEnumeration* avail;
1155 USet* exemplarSets[2];
1156 USet* unassignedSet;
1157 UScriptCode code[MAX_SCRIPTS_PER_LOCALE];
1158 USet* codeSets[MAX_SCRIPTS_PER_LOCALE];
1159 int32_t codeLen;
1160 char cbuf[32]; /* 9 should be enough */
1161 UChar ubuf[64]; /* adjust as needed */
1162 UBool existsInScript;
1163 int32_t itemCount;
1164 int32_t strLen;
1165 UChar32 start, end;
1166
1167 unassignedSet = NULL;
1168 exemplarSets[0] = NULL;
1169 exemplarSets[1] = NULL;
1170 for (i=0; i<MAX_SCRIPTS_PER_LOCALE; ++i) {
1171 codeSets[i] = NULL;
1172 }
1173
1174 avail = ures_openAvailableLocales(NULL, &ec);
1175 if (!assertSuccess("ures_openAvailableLocales", &ec)) goto END;
1176 n = uenum_count(avail, &ec);
1177 if (!assertSuccess("uenum_count", &ec)) goto END;
1178
1179 u_uastrcpy(ubuf, "[:unassigned:]");
1180 unassignedSet = uset_openPattern(ubuf, -1, &ec);
1181 if (!assertSuccess("uset_openPattern", &ec)) goto END;
1182
1183 for(i=0; i<n; i++){
1184 const char* locale = uenum_next(avail, NULL, &ec);
1185 if (!assertSuccess("uenum_next", &ec)) goto END;
1186 log_verbose("%s\n", locale);
1187 for (k=0; k<2; ++k) {
1188 uint32_t option = (k==0) ? 0 : USET_CASE_INSENSITIVE;
1189 ULocaleData *uld = ulocdata_open(locale,&ec);
1190 USet* exemplarSet = ulocdata_getExemplarSet(uld,NULL, option, ULOCDATA_ES_STANDARD, &ec);
1191 uset_close(exemplarSets[k]);
1192 ulocdata_close(uld);
1193 exemplarSets[k] = exemplarSet;
1194 if (!assertSuccess("ulocaledata_getExemplarSet", &ec)) goto END;
1195
1196 if (uset_containsSome(exemplarSet, unassignedSet)) {
1197 log_err("ExemplarSet contains unassigned characters for locale : %s\n", locale);
1198 }
1199 codeLen = uscript_getCode(locale, code, 8, &ec);
1200 if (strcmp(locale, "yi") == 0 && codeLen > 0 && log_knownIssue("11217", "Fix result of uscript_getCode for yi: USCRIPT_YI -> USCRIPT_HEBREW")) {
1201 code[0] = USCRIPT_HEBREW;
1202 }
1203 if (!assertSuccess("uscript_getCode", &ec)) goto END;
1204
1205 for (j=0; j<MAX_SCRIPTS_PER_LOCALE; ++j) {
1206 uset_close(codeSets[j]);
1207 codeSets[j] = NULL;
1208 }
1209 for (j=0; j<codeLen; ++j) {
1210 uprv_strcpy(cbuf, "[:");
1211 if(code[j]==-1){
1212 log_err("USCRIPT_INVALID_CODE returned for locale: %s\n", locale);
1213 continue;
1214 }
1215 uprv_strcat(cbuf, uscript_getShortName(code[j]));
1216 uprv_strcat(cbuf, ":]");
1217 u_uastrcpy(ubuf, cbuf);
1218 codeSets[j] = uset_openPattern(ubuf, -1, &ec);
1219 }
1220 if (!assertSuccess("uset_openPattern", &ec)) goto END;
1221
1222 existsInScript = FALSE;
1223 itemCount = uset_getItemCount(exemplarSet);
1224 for (m=0; m<itemCount && !existsInScript; ++m) {
1225 strLen = uset_getItem(exemplarSet, m, &start, &end, ubuf,
1226 UPRV_LENGTHOF(ubuf), &ec);
1227 /* failure here might mean str[] needs to be larger */
1228 if (!assertSuccess("uset_getItem", &ec)) goto END;
1229 if (strLen == 0) {
1230 for (j=0; j<codeLen; ++j) {
1231 if (codeSets[j]!=NULL && uset_containsRange(codeSets[j], start, end)) {
1232 existsInScript = TRUE;
1233 break;
1234 }
1235 }
1236 } else {
1237 for (j=0; j<codeLen; ++j) {
1238 if (codeSets[j]!=NULL && uset_containsString(codeSets[j], ubuf, strLen)) {
1239 existsInScript = TRUE;
1240 break;
1241 }
1242 }
1243 }
1244 }
1245
1246 if (existsInScript == FALSE){
1247 log_err("ExemplarSet containment failed for locale : %s\n", locale);
1248 }
1249 }
1250 assertTrue("case-folded is a superset",
1251 uset_containsAll(exemplarSets[1], exemplarSets[0]));
1252 if (uset_equals(exemplarSets[1], exemplarSets[0])) {
1253 ++equalCount;
1254 }
1255 }
1256 /* Note: The case-folded set should sometimes be a strict superset
1257 and sometimes be equal. */
1258 assertTrue("case-folded is sometimes a strict superset, and sometimes equal",
1259 equalCount > 0 && equalCount < n);
1260
1261 END:
1262 uenum_close(avail);
1263 uset_close(exemplarSets[0]);
1264 uset_close(exemplarSets[1]);
1265 uset_close(unassignedSet);
1266 for (i=0; i<MAX_SCRIPTS_PER_LOCALE; ++i) {
1267 uset_close(codeSets[i]);
1268 }
1269 }
1270
1271 enum { kUBufMax = 32 };
TestLocaleDisplayPattern(void)1272 static void TestLocaleDisplayPattern(void){
1273 UErrorCode status;
1274 UChar pattern[kUBufMax] = {0,};
1275 UChar separator[kUBufMax] = {0,};
1276 ULocaleData *uld;
1277 static const UChar enExpectPat[] = { 0x007B,0x0030,0x007D,0x0020,0x0028,0x007B,0x0031,0x007D,0x0029,0 }; /* "{0} ({1})" */
1278 static const UChar enExpectSep[] = { 0x002C,0x0020,0 }; /* ", " */
1279 static const UChar zhExpectPat[] = { 0x007B,0x0030,0x007D,0xFF08,0x007B,0x0031,0x007D,0xFF09,0 };
1280 static const UChar zhExpectSep[] = { 0xFF0C,0 };
1281
1282 status = U_ZERO_ERROR;
1283 uld = ulocdata_open("en", &status);
1284 if(U_FAILURE(status)){
1285 log_data_err("ulocdata_open en error %s", u_errorName(status));
1286 } else {
1287 ulocdata_getLocaleDisplayPattern(uld, pattern, kUBufMax, &status);
1288 if (U_FAILURE(status)){
1289 log_err("ulocdata_getLocaleDisplayPattern en error %s", u_errorName(status));
1290 } else if (u_strcmp(pattern, enExpectPat) != 0) {
1291 log_err("ulocdata_getLocaleDisplayPattern en returns unexpected pattern");
1292 }
1293 status = U_ZERO_ERROR;
1294 ulocdata_getLocaleSeparator(uld, separator, kUBufMax, &status);
1295 if (U_FAILURE(status)){
1296 log_err("ulocdata_getLocaleSeparator en error %s", u_errorName(status));
1297 } else if (u_strcmp(separator, enExpectSep) != 0) {
1298 log_err("ulocdata_getLocaleSeparator en returns unexpected string ");
1299 }
1300 ulocdata_close(uld);
1301 }
1302
1303 status = U_ZERO_ERROR;
1304 uld = ulocdata_open("zh", &status);
1305 if(U_FAILURE(status)){
1306 log_data_err("ulocdata_open zh error %s", u_errorName(status));
1307 } else {
1308 ulocdata_getLocaleDisplayPattern(uld, pattern, kUBufMax, &status);
1309 if (U_FAILURE(status)){
1310 log_err("ulocdata_getLocaleDisplayPattern zh error %s", u_errorName(status));
1311 } else if (u_strcmp(pattern, zhExpectPat) != 0) {
1312 log_err("ulocdata_getLocaleDisplayPattern zh returns unexpected pattern");
1313 }
1314 status = U_ZERO_ERROR;
1315 ulocdata_getLocaleSeparator(uld, separator, kUBufMax, &status);
1316 if (U_FAILURE(status)){
1317 log_err("ulocdata_getLocaleSeparator zh error %s", u_errorName(status));
1318 } else if (u_strcmp(separator, zhExpectSep) != 0) {
1319 log_err("ulocdata_getLocaleSeparator zh returns unexpected string ");
1320 }
1321 ulocdata_close(uld);
1322 }
1323 }
1324
TestCoverage(void)1325 static void TestCoverage(void){
1326 ULocaleDataDelimiterType types[] = {
1327 ULOCDATA_QUOTATION_START, /* Quotation start */
1328 ULOCDATA_QUOTATION_END, /* Quotation end */
1329 ULOCDATA_ALT_QUOTATION_START, /* Alternate quotation start */
1330 ULOCDATA_ALT_QUOTATION_END, /* Alternate quotation end */
1331 ULOCDATA_DELIMITER_COUNT
1332 };
1333 int i;
1334 UBool sub;
1335 UErrorCode status = U_ZERO_ERROR;
1336 ULocaleData *uld = ulocdata_open(uloc_getDefault(), &status);
1337
1338 if(U_FAILURE(status)){
1339 log_data_err("ulocdata_open error");
1340 return;
1341 }
1342
1343
1344 for(i = 0; i < ULOCDATA_DELIMITER_COUNT; i++){
1345 UChar result[32] = {0,};
1346 status = U_ZERO_ERROR;
1347 ulocdata_getDelimiter(uld, types[i], result, 32, &status);
1348 if (U_FAILURE(status)){
1349 log_err("ulocdata_getDelimiter error with type %d", types[i]);
1350 }
1351 }
1352
1353 sub = ulocdata_getNoSubstitute(uld);
1354 ulocdata_setNoSubstitute(uld,sub);
1355 ulocdata_close(uld);
1356 }
1357
1358 typedef struct {
1359 const char* locale;
1360 const UChar* quoteStart;
1361 const UChar* quoteEnd;
1362 } TestDelimitersItem;
1363
1364 static const TestDelimitersItem testDelimsItems[] = {
1365 { "fr_CA", u"«", u"»" }, // inherited from fr
1366 { "de_CH", u"„", u"“" }, // inherited from de
1367 { "es_MX", u"“", u"”" }, // inherited from es_419
1368 { "ja", u"「", u"」" },
1369 { NULL, NULL, NULL }
1370 };
1371
1372 enum { kUDelimMax = 8, kBDelimMax = 16 };
TestDelimiters(void)1373 static void TestDelimiters(void){
1374 const TestDelimitersItem* itemPtr = testDelimsItems;
1375 for (; itemPtr->locale != NULL; itemPtr++) {
1376 UErrorCode status = U_ZERO_ERROR;
1377 ULocaleData *uld = ulocdata_open(itemPtr->locale, &status);
1378 if (U_FAILURE(status)) {
1379 log_data_err("ulocdata_open for locale %s fails: %s\n", itemPtr->locale, u_errorName(status));
1380 } else {
1381 UChar quoteStart[kUDelimMax], quoteEnd[kUDelimMax];
1382 (void)ulocdata_getDelimiter(uld, ULOCDATA_QUOTATION_START, quoteStart, kUDelimMax, &status);
1383 (void)ulocdata_getDelimiter(uld, ULOCDATA_QUOTATION_END, quoteEnd, kUDelimMax, &status);
1384 if (U_FAILURE(status)) {
1385 log_err("ulocdata_getDelimiter ULOCDATA_QUOTATION_START/END for locale %s fails: %s\n", itemPtr->locale, u_errorName(status));
1386 } else if (u_strcmp(quoteStart,itemPtr->quoteStart)!=0 || u_strcmp(quoteEnd,itemPtr->quoteEnd)!=0) {
1387 char expStart[kBDelimMax], expEnd[kBDelimMax], getStart[kBDelimMax], getEnd[kBDelimMax];
1388 u_austrcpy(expStart, itemPtr->quoteStart);
1389 u_austrcpy(expEnd, itemPtr->quoteEnd);
1390 u_austrcpy(getStart, quoteStart);
1391 u_austrcpy(getEnd, quoteEnd);
1392 log_err("ulocdata_getDelimiter ULOCDATA_QUOTATION_START/END for locale %s, expect %s..%s, get %s..%s\n",
1393 itemPtr->locale, expStart, expEnd, getStart, getEnd);
1394 }
1395 ulocdata_close(uld);
1396 }
1397 }
1398 }
1399
1400
TestIndexChars(void)1401 static void TestIndexChars(void) {
1402 /* Very basic test of ULOCDATA_ES_INDEX.
1403 * No comprehensive test of data, just basic check that the code path is alive.
1404 */
1405 UErrorCode status = U_ZERO_ERROR;
1406 ULocaleData *uld;
1407 USet *exemplarChars;
1408 USet *indexChars;
1409
1410 uld = ulocdata_open("en", &status);
1411 exemplarChars = uset_openEmpty();
1412 indexChars = uset_openEmpty();
1413 ulocdata_getExemplarSet(uld, exemplarChars, 0, ULOCDATA_ES_STANDARD, &status);
1414 ulocdata_getExemplarSet(uld, indexChars, 0, ULOCDATA_ES_INDEX, &status);
1415 if (U_FAILURE(status)) {
1416 log_data_err("File %s, line %d, Failure opening exemplar chars: %s", __FILE__, __LINE__, u_errorName(status));
1417 goto close_sets;
1418 }
1419 /* en data, standard exemplars are [a-z], lower case. */
1420 /* en data, index characters are [A-Z], upper case. */
1421 if ((uset_contains(exemplarChars, (UChar32)0x41) || uset_contains(indexChars, (UChar32)0x61))) {
1422 log_err("File %s, line %d, Exemplar characters incorrect.", __FILE__, __LINE__ );
1423 goto close_sets;
1424 }
1425 if (!(uset_contains(exemplarChars, (UChar32)0x61) && uset_contains(indexChars, (UChar32)0x41) )) {
1426 log_err("File %s, line %d, Exemplar characters incorrect.", __FILE__, __LINE__ );
1427 goto close_sets;
1428 }
1429
1430 close_sets:
1431 uset_close(exemplarChars);
1432 uset_close(indexChars);
1433 ulocdata_close(uld);
1434 }
1435
1436
1437
1438 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
TestCurrencyList(void)1439 static void TestCurrencyList(void){
1440 #if !UCONFIG_NO_FORMATTING
1441 UErrorCode errorCode = U_ZERO_ERROR;
1442 int32_t structLocaleCount, currencyCount;
1443 UEnumeration *en = ucurr_openISOCurrencies(UCURR_ALL, &errorCode);
1444 const char *isoCode, *structISOCode;
1445 UResourceBundle *subBundle;
1446 UResourceBundle *currencies = ures_openDirect(loadTestData(&errorCode), "structLocale", &errorCode);
1447 if(U_FAILURE(errorCode)) {
1448 log_data_err("Can't open structLocale\n");
1449 return;
1450 }
1451 currencies = ures_getByKey(currencies, "Currencies", currencies, &errorCode);
1452 currencyCount = uenum_count(en, &errorCode);
1453 structLocaleCount = ures_getSize(currencies);
1454 if (currencyCount != structLocaleCount) {
1455 log_err("structLocale(%d) and ISO4217(%d) currency list are out of sync.\n", structLocaleCount, currencyCount);
1456 #if U_CHARSET_FAMILY == U_ASCII_FAMILY
1457 ures_resetIterator(currencies);
1458 while ((isoCode = uenum_next(en, NULL, &errorCode)) != NULL && ures_hasNext(currencies)) {
1459 subBundle = ures_getNextResource(currencies, NULL, &errorCode);
1460 structISOCode = ures_getKey(subBundle);
1461 ures_close(subBundle);
1462 if (strcmp(structISOCode, isoCode) != 0) {
1463 log_err("First difference found at structLocale(%s) and ISO4217(%s).\n", structISOCode, isoCode);
1464 break;
1465 }
1466 }
1467 #endif
1468 }
1469 ures_close(currencies);
1470 uenum_close(en);
1471 #endif
1472 }
1473 #endif
1474
TestAvailableIsoCodes(void)1475 static void TestAvailableIsoCodes(void){
1476 #if !UCONFIG_NO_FORMATTING
1477 UErrorCode errorCode = U_ZERO_ERROR;
1478 const char* eurCode = "EUR";
1479 const char* usdCode = "USD";
1480 const char* lastCode = "RHD";
1481 const char* zzzCode = "ZZZ";
1482 UDate date1950 = (UDate)-630720000000.0;/* year 1950 */
1483 UDate date1970 = (UDate)0.0; /* year 1970 */
1484 UDate date1975 = (UDate)173448000000.0; /* year 1975 */
1485 UDate date1978 = (UDate)260172000000.0; /* year 1978 */
1486 UDate date1981 = (UDate)346896000000.0; /* year 1981 */
1487 UDate date1992 = (UDate)693792000000.0; /* year 1992 */
1488 UChar* isoCode = (UChar*)malloc(sizeof(UChar) * (uprv_strlen(usdCode) + 1));
1489
1490 /* testing available codes with no time ranges */
1491 u_charsToUChars(eurCode, isoCode, (int32_t)uprv_strlen(usdCode) + 1);
1492 if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
1493 log_data_err("FAIL: ISO code (%s) is not found.\n", eurCode);
1494 }
1495
1496 u_charsToUChars(usdCode, isoCode, (int32_t)uprv_strlen(zzzCode) + 1);
1497 if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
1498 log_data_err("FAIL: ISO code (%s) is not found.\n", usdCode);
1499 }
1500
1501 u_charsToUChars(zzzCode, isoCode, (int32_t)uprv_strlen(zzzCode) + 1);
1502 if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == TRUE) {
1503 log_err("FAIL: ISO code (%s) is reported as available, but it doesn't exist.\n", zzzCode);
1504 }
1505
1506 u_charsToUChars(lastCode, isoCode, (int32_t)uprv_strlen(zzzCode) + 1);
1507 if (ucurr_isAvailable(isoCode, U_DATE_MIN, U_DATE_MAX, &errorCode) == FALSE) {
1508 log_data_err("FAIL: ISO code (%s) is not found.\n", lastCode);
1509 }
1510
1511 /* RHD was used from 1970-02-17 to 1980-04-18*/
1512
1513 /* to = null */
1514 if (ucurr_isAvailable(isoCode, date1970, U_DATE_MAX, &errorCode) == FALSE) {
1515 log_data_err("FAIL: ISO code (%s) was available in time range >1970-01-01.\n", lastCode);
1516 }
1517
1518 if (ucurr_isAvailable(isoCode, date1975, U_DATE_MAX, &errorCode) == FALSE) {
1519 log_data_err("FAIL: ISO code (%s) was available in time range >1975.\n", lastCode);
1520 }
1521
1522 if (ucurr_isAvailable(isoCode, date1981, U_DATE_MAX, &errorCode) == TRUE) {
1523 log_err("FAIL: ISO code (%s) was not available in time range >1981.\n", lastCode);
1524 }
1525
1526 /* from = null */
1527 if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1970, &errorCode) == TRUE) {
1528 log_err("FAIL: ISO code (%s) was not available in time range <1970.\n", lastCode);
1529 }
1530
1531 if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1975, &errorCode) == FALSE) {
1532 log_data_err("FAIL: ISO code (%s) was available in time range <1975.\n", lastCode);
1533 }
1534
1535 if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1981, &errorCode) == FALSE) {
1536 log_data_err("FAIL: ISO code (%s) was available in time range <1981.\n", lastCode);
1537 }
1538
1539 /* full ranges */
1540 if (ucurr_isAvailable(isoCode, date1975, date1978, &errorCode) == FALSE) {
1541 log_data_err("FAIL: ISO code (%s) was available in time range 1975-1978.\n", lastCode);
1542 }
1543
1544 if (ucurr_isAvailable(isoCode, date1970, date1975, &errorCode) == FALSE) {
1545 log_data_err("FAIL: ISO code (%s) was available in time range 1970-1975.\n", lastCode);
1546 }
1547
1548 if (ucurr_isAvailable(isoCode, date1975, date1981, &errorCode) == FALSE) {
1549 log_data_err("FAIL: ISO code (%s) was available in time range 1975-1981.\n", lastCode);
1550 }
1551
1552 if (ucurr_isAvailable(isoCode, date1970, date1981, &errorCode) == FALSE) {
1553 log_data_err("FAIL: ISO code (%s) was available in time range 1970-1981.\n", lastCode);
1554 }
1555
1556 if (ucurr_isAvailable(isoCode, date1981, date1992, &errorCode) == TRUE) {
1557 log_err("FAIL: ISO code (%s) was not available in time range 1981-1992.\n", lastCode);
1558 }
1559
1560 if (ucurr_isAvailable(isoCode, date1950, date1970, &errorCode) == TRUE) {
1561 log_err("FAIL: ISO code (%s) was not available in time range 1950-1970.\n", lastCode);
1562 }
1563
1564 /* wrong range - from > to*/
1565 if (ucurr_isAvailable(isoCode, date1975, date1970, &errorCode) == TRUE) {
1566 log_err("FAIL: Wrong range 1975-1970 for ISO code (%s) was not reported.\n", lastCode);
1567 } else if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) {
1568 log_data_err("FAIL: Error code not reported for wrong range 1975-1970 for ISO code (%s).\n", lastCode);
1569 }
1570
1571 free(isoCode);
1572 #endif
1573 }
1574
1575 #define TESTCASE(name) addTest(root, &name, "tsutil/cldrtest/" #name)
1576
1577 void addCLDRTest(TestNode** root);
1578
addCLDRTest(TestNode ** root)1579 void addCLDRTest(TestNode** root)
1580 {
1581 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
1582 TESTCASE(TestLocaleStructure);
1583 TESTCASE(TestCurrencyList);
1584 #endif
1585 TESTCASE(TestConsistentCountryInfo);
1586 TESTCASE(VerifyTranslation);
1587 TESTCASE(TestExemplarSet);
1588 TESTCASE(TestLocaleDisplayPattern);
1589 TESTCASE(TestCoverage);
1590 TESTCASE(TestDelimiters);
1591 TESTCASE(TestIndexChars);
1592 TESTCASE(TestAvailableIsoCodes);
1593 }
1594
1595