1 /********************************************************************
3 * Copyright (c) 1997-2008, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
8 #include "unicode/ures.h"
9 #include "unicode/ucurr.h"
10 #include "unicode/ustring.h"
11 #include "unicode/uset.h"
12 #include "unicode/udat.h"
13 #include "unicode/uscript.h"
14 #include "unicode/ulocdata.h"
19 /*--------------------------------------------------------------------
20 Time bomb - allows temporary behavior that expires at a given
22 ---------------------------------------------------------------------*/
23 static const UVersionInfo ICU_37
= {3,7,0,0};
26 returns a new UnicodeSet that is a flattened form of the original
30 createFlattenSet(USet
*origSet
, UErrorCode
*status
) {
34 int32_t origItemCount
= 0;
35 int32_t idx
, graphmeSize
;
38 if (U_FAILURE(*status
)) {
39 log_err("createFlattenSet called with %s\n", u_errorName(*status
));
42 newSet
= uset_open(1, 0);
43 origItemCount
= uset_getItemCount(origSet
);
44 for (idx
= 0; idx
< origItemCount
; idx
++) {
45 graphmeSize
= uset_getItem(origSet
, idx
,
47 graphme
, (int32_t)(sizeof(graphme
)/sizeof(graphme
[0])),
49 if (U_FAILURE(*status
)) {
50 log_err("ERROR: uset_getItem returned %s\n", u_errorName(*status
));
51 *status
= U_ZERO_ERROR
;
54 uset_addAllCodePoints(newSet
, graphme
, graphmeSize
);
57 uset_addRange(newSet
, start
, end
);
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){
76 TestKeyInRootRecursive(UResourceBundle
*root
, const char *rootName
,
77 UResourceBundle
*currentBundle
, const char *locale
) {
78 UErrorCode errorCode
= U_ZERO_ERROR
;
79 UResourceBundle
*subRootBundle
= NULL
, *subBundle
= NULL
;
81 ures_resetIterator(root
);
82 ures_resetIterator(currentBundle
);
83 while (ures_hasNext(currentBundle
)) {
84 const char *subBundleKey
= NULL
;
85 const char *currentBundleKey
= NULL
;
87 errorCode
= U_ZERO_ERROR
;
88 currentBundleKey
= ures_getKey(currentBundle
);
89 subBundle
= ures_getNextResource(currentBundle
, NULL
, &errorCode
);
90 if (U_FAILURE(errorCode
)) {
91 log_err("Can't open a resource for locale %s. Error: %s\n", locale
, u_errorName(errorCode
));
94 subBundleKey
= ures_getKey(subBundle
);
97 subRootBundle
= ures_getByKey(root
, subBundleKey
, NULL
, &errorCode
);
98 if (U_FAILURE(errorCode
)) {
99 log_err("Can't open a resource with key \"%s\" in \"%s\" from %s for locale \"%s\"\n",
101 ures_getKey(currentBundle
),
104 ures_close(subBundle
);
107 if (ures_getType(subRootBundle
) != ures_getType(subBundle
)) {
108 log_err("key \"%s\" in \"%s\" has a different type from root for locale \"%s\"\n"
109 "\troot=%d, locale=%d\n",
111 ures_getKey(currentBundle
),
113 ures_getType(subRootBundle
),
114 ures_getType(subBundle
));
115 ures_close(subBundle
);
118 else if (ures_getType(subBundle
) == URES_INT_VECTOR
) {
120 int32_t subBundleSize
;
122 UBool sameArray
= TRUE
;
123 const int32_t *subRootBundleArr
= ures_getIntVector(subRootBundle
, &minSize
, &errorCode
);
124 const int32_t *subBundleArr
= ures_getIntVector(subBundle
, &subBundleSize
, &errorCode
);
126 if (minSize
> subBundleSize
) {
127 minSize
= subBundleSize
;
128 log_err("Arrays are different size with key \"%s\" in \"%s\" from root for locale \"%s\"\n",
130 ures_getKey(currentBundle
),
134 for (idx
= 0; idx
< minSize
&& sameArray
; idx
++) {
135 if (subRootBundleArr
[idx
] != subBundleArr
[idx
]) {
138 if (strcmp(subBundleKey
, "DateTimeElements") == 0
139 && (subBundleArr
[idx
] < 1 || 7 < subBundleArr
[idx
]))
141 log_err("Value out of range with key \"%s\" at index %d in \"%s\" for locale \"%s\"\n",
144 ures_getKey(currentBundle
),
148 /* Special exception es_US and DateTimeElements */
150 && !(strcmp(locale
, "es_US") == 0 && strcmp(subBundleKey
, "DateTimeElements") == 0))
152 log_err("Integer vectors are the same with key \"%s\" in \"%s\" from root for locale \"%s\"\n",
154 ures_getKey(currentBundle
),
158 else if (ures_getType(subBundle
) == URES_ARRAY
) {
159 UResourceBundle
*subSubBundle
= ures_getByIndex(subBundle
, 0, NULL
, &errorCode
);
160 UResourceBundle
*subSubRootBundle
= ures_getByIndex(subRootBundle
, 0, NULL
, &errorCode
);
162 if (U_SUCCESS(errorCode
)
163 && (ures_getType(subSubBundle
) == URES_ARRAY
|| ures_getType(subSubRootBundle
) == URES_ARRAY
))
165 /* Here is one of the recursive parts */
166 TestKeyInRootRecursive(subRootBundle
, rootName
, subBundle
, locale
);
169 int32_t minSize
= ures_getSize(subRootBundle
);
171 UBool sameArray
= TRUE
;
173 if (minSize
> ures_getSize(subBundle
)) {
174 minSize
= ures_getSize(subBundle
);
177 if ((subBundleKey
== NULL
178 || (subBundleKey
!= NULL
&& strcmp(subBundleKey
, "LocaleScript") != 0 && !isCurrencyPreEuro(subBundleKey
)))
179 && ures_getSize(subRootBundle
) != ures_getSize(subBundle
))
181 log_err("Different size array with key \"%s\" in \"%s\" from root for locale \"%s\"\n"
182 "\troot array size=%d, locale array size=%d\n",
184 ures_getKey(currentBundle
),
186 ures_getSize(subRootBundle
),
187 ures_getSize(subBundle
));
190 if(isCurrencyPreEuro(subBundleKey) && ures_getSize(subBundle)!=3){
191 log_err("Different size array with key \"%s\" in \"%s\" for locale \"%s\" the expected size is 3 got size=%d\n",
193 ures_getKey(currentBundle),
195 ures_getSize(subBundle));
198 for (idx
= 0; idx
< minSize
; idx
++) {
199 int32_t rootStrLen
, localeStrLen
;
200 const UChar
*rootStr
= ures_getStringByIndex(subRootBundle
,idx
,&rootStrLen
,&errorCode
);
201 const UChar
*localeStr
= ures_getStringByIndex(subBundle
,idx
,&localeStrLen
,&errorCode
);
202 if (rootStr
&& localeStr
&& U_SUCCESS(errorCode
)) {
203 if (u_strcmp(rootStr
, localeStr
) != 0) {
208 log_err("Got a NULL string with key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n",
210 ures_getKey(currentBundle
),
215 if (localeStr
[0] == (UChar
)0x20) {
216 log_err("key \"%s\" at index %d in \"%s\" starts with a space in locale \"%s\"\n",
219 ures_getKey(currentBundle
),
222 else if ((localeStr
[localeStrLen
- 1] == (UChar
)0x20) && (strcmp(subBundleKey
,"separator") != 0)) {
223 log_err("key \"%s\" at index %d in \"%s\" ends with a space in locale \"%s\"\n",
226 ures_getKey(currentBundle
),
229 else if (subBundleKey
!= NULL
230 && strcmp(subBundleKey
, "DateTimePatterns") == 0)
233 const UChar
*localeStrItr
= localeStr
;
234 while (*localeStrItr
) {
235 if (*localeStrItr
== (UChar
)0x27 /* ' */) {
238 else if ((quoted
% 2) == 0) {
239 /* Search for unquoted characters */
240 if (4 <= idx
&& idx
<= 7
241 && (*localeStrItr
== (UChar
)0x6B /* k */
242 || *localeStrItr
== (UChar
)0x48 /* H */
243 || *localeStrItr
== (UChar
)0x6D /* m */
244 || *localeStrItr
== (UChar
)0x73 /* s */
245 || *localeStrItr
== (UChar
)0x53 /* S */
246 || *localeStrItr
== (UChar
)0x61 /* a */
247 || *localeStrItr
== (UChar
)0x68 /* h */
248 || *localeStrItr
== (UChar
)0x7A /* z */))
250 log_err("key \"%s\" at index %d has time pattern chars in date for locale \"%s\"\n",
255 else if (0 <= idx
&& idx
<= 3
256 && (*localeStrItr
== (UChar
)0x47 /* G */
257 || *localeStrItr
== (UChar
)0x79 /* y */
258 || *localeStrItr
== (UChar
)0x4D /* M */
259 || *localeStrItr
== (UChar
)0x64 /* d */
260 || *localeStrItr
== (UChar
)0x45 /* E */
261 || *localeStrItr
== (UChar
)0x44 /* D */
262 || *localeStrItr
== (UChar
)0x46 /* F */
263 || *localeStrItr
== (UChar
)0x77 /* w */
264 || *localeStrItr
== (UChar
)0x57 /* W */))
266 log_err("key \"%s\" at index %d has date pattern chars in time for locale \"%s\"\n",
275 else if (idx
== 4 && subBundleKey
!= NULL
276 && strcmp(subBundleKey
, "NumberElements") == 0
277 && u_charDigitValue(localeStr
[0]) != 0)
279 log_err("key \"%s\" at index %d has a non-zero based number for locale \"%s\"\n",
285 /* if (sameArray && strcmp(rootName, "root") == 0) {
286 log_err("Arrays are the same with key \"%s\" in \"%s\" from root for locale \"%s\"\n",
288 ures_getKey(currentBundle),
292 ures_close(subSubBundle
);
293 ures_close(subSubRootBundle
);
295 else if (ures_getType(subBundle
) == URES_STRING
) {
297 const UChar
*string
= ures_getString(subBundle
, &len
, &errorCode
);
298 if (U_FAILURE(errorCode
) || string
== NULL
) {
299 log_err("Can't open a string with key \"%s\" in \"%s\" for locale \"%s\"\n",
301 ures_getKey(currentBundle
),
303 } else if (string
[0] == (UChar
)0x20) {
304 log_err("key \"%s\" in \"%s\" starts with a space in locale \"%s\"\n",
306 ures_getKey(currentBundle
),
308 /* localeDisplayPattern/separator can end with a space */
309 } else if (string
[len
- 1] == (UChar
)0x20 && (strcmp(subBundleKey
,"separator"))) {
310 log_err("key \"%s\" in \"%s\" ends with a space in locale \"%s\"\n",
312 ures_getKey(currentBundle
),
314 } else if (strcmp(subBundleKey
, "localPatternChars") == 0) {
315 /* Note: We no longer import localPatternChars data starting
316 * ICU 3.8. So it never comes into this else if block. (ticket#5597)
319 /* Check well-formedness of localPatternChars. First, the
320 * length must match the number of fields defined by
321 * DateFormat. Second, each character in the string must
322 * be in the set [A-Za-z]. Finally, each character must be
326 #if !UCONFIG_NO_FORMATTING
327 if (len
!= UDAT_FIELD_COUNT
) {
328 log_err("key \"%s\" has the wrong number of characters in locale \"%s\"\n",
333 /* Check char validity. */
334 for (i
=0; i
<len
; ++i
) {
335 if (!((string
[i
] >= 65/*'A'*/ && string
[i
] <= 90/*'Z'*/) ||
336 (string
[i
] >= 97/*'a'*/ && string
[i
] <= 122/*'z'*/))) {
337 log_err("key \"%s\" has illegal character '%c' in locale \"%s\"\n",
342 /* Do O(n^2) check for duplicate chars. */
343 for (j
=0; j
<i
; ++j
) {
344 if (string
[j
] == string
[i
]) {
345 log_err("key \"%s\" has duplicate character '%c' in locale \"%s\"\n",
353 /* No fallback was done. Check for duplicate data */
354 /* The ures_* API does not do fallback of sub-resource bundles,
355 So we can't do this now. */
357 else if (strcmp(locale
, "root") != 0 && errorCode
== U_ZERO_ERROR
) {
359 const UChar
*rootString
= ures_getString(subRootBundle
, &len
, &errorCode
);
360 if (U_FAILURE(errorCode
) || rootString
== NULL
) {
361 log_err("Can't open a string with key \"%s\" in \"%s\" in root\n",
362 ures_getKey(subRootBundle
),
363 ures_getKey(currentBundle
));
365 } else if (u_strcmp(string
, rootString
) == 0) {
366 if (strcmp(locale
, "de_CH") != 0 && strcmp(subBundleKey
, "Countries") != 0 &&
367 strcmp(subBundleKey
, "Version") != 0) {
368 log_err("Found duplicate data with key \"%s\" in \"%s\" in locale \"%s\"\n",
369 ures_getKey(subRootBundle
),
370 ures_getKey(currentBundle
),
374 /* Ignore for now. */
375 /* Can be fixed if fallback through de locale was done. */
376 log_verbose("Skipping key %s in %s\n", subBundleKey
, locale
);
382 else if (ures_getType(subBundle
) == URES_TABLE
) {
383 if (strcmp(subBundleKey
, "availableFormats")!=0) {
384 /* Here is one of the recursive parts */
385 TestKeyInRootRecursive(subRootBundle
, rootName
, subBundle
, locale
);
388 log_verbose("Skipping key %s in %s\n", subBundleKey
, locale
);
391 else if (ures_getType(subBundle
) == URES_BINARY
|| ures_getType(subBundle
) == URES_INT
) {
392 /* Can't do anything to check it */
393 /* We'll assume it's all correct */
394 if (strcmp(subBundleKey
, "MeasurementSystem") != 0) {
395 log_verbose("Skipping key \"%s\" in \"%s\" for locale \"%s\"\n",
397 ures_getKey(currentBundle
),
400 /* Testing for MeasurementSystem is done in VerifyTranslation */
403 log_err("Type %d for key \"%s\" in \"%s\" is unknown for locale \"%s\"\n",
404 ures_getType(subBundle
),
406 ures_getKey(currentBundle
),
409 ures_close(subRootBundle
);
410 ures_close(subBundle
);
416 testLCID(UResourceBundle
*currentBundle
,
417 const char *localeName
)
419 UErrorCode status
= U_ZERO_ERROR
;
420 uint32_t expectedLCID
;
421 char lcidStringC
[64] = {0};
423 expectedLCID
= uloc_getLCID(localeName
);
424 if (expectedLCID
== 0) {
425 log_verbose("INFO: %-5s does not have any LCID mapping\n",
430 status
= U_ZERO_ERROR
;
431 uprv_strcpy(lcidStringC
, uprv_convertToPosix(expectedLCID
, &status
));
432 if (U_FAILURE(status
)) {
433 log_err("ERROR: %.4x does not have a POSIX mapping due to %s\n",
434 expectedLCID
, u_errorName(status
));
437 if(strcmp(localeName
, lcidStringC
) != 0) {
440 uloc_getLanguage(localeName
, langName
, sizeof(langName
), &status
);
441 uloc_getLanguage(lcidStringC
, langLCID
, sizeof(langLCID
), &status
);
443 if (strcmp(langName
, langLCID
) == 0) {
444 log_verbose("WARNING: %-5s resolves to %s (0x%.4x)\n",
445 localeName
, lcidStringC
, expectedLCID
);
448 log_err("ERROR: %-5s has 0x%.4x and the number resolves wrongfully to %s\n",
449 localeName
, expectedLCID
, lcidStringC
);
455 TestLocaleStructure(void) {
456 UResourceBundle
*root
, *currentLocale
;
457 int32_t locCount
= uloc_countAvailable();
459 UErrorCode errorCode
= U_ZERO_ERROR
;
460 const char *currLoc
, *resolvedLoc
;
462 /* TODO: Compare against parent's data too. This code can't handle fallbacks that some tools do already. */
463 /* char locName[ULOC_FULLNAME_CAPACITY];
466 for (locIndex = 0; locIndex < locCount; locIndex++) {
467 errorCode=U_ZERO_ERROR;
468 strcpy(locName, uloc_getAvailable(locIndex));
469 locNamePtr = strrchr(locName, '_');
474 strcpy(locName, "root");
477 root = ures_openDirect(NULL, locName, &errorCode);
478 if(U_FAILURE(errorCode)) {
479 log_err("Can't open %s\n", locName);
484 log_data_err("At least root needs to be installed\n");
487 root
= ures_openDirect(loadTestData(&errorCode
), "structLocale", &errorCode
);
488 if(U_FAILURE(errorCode
)) {
489 log_data_err("Can't open structLocale\n");
492 for (locIndex
= 0; locIndex
< locCount
; locIndex
++) {
493 errorCode
=U_ZERO_ERROR
;
494 currLoc
= uloc_getAvailable(locIndex
);
495 currentLocale
= ures_open(NULL
, currLoc
, &errorCode
);
496 if(errorCode
!= U_ZERO_ERROR
) {
497 if(U_SUCCESS(errorCode
)) {
498 /* It's installed, but there is no data.
499 It's installed for the g18n white paper [grhoten] */
500 log_err("ERROR: Locale %-5s not installed, and it should be!\n",
501 uloc_getAvailable(locIndex
));
503 log_err("%%%%%%% Unexpected error %d in %s %%%%%%%",
504 u_errorName(errorCode
),
505 uloc_getAvailable(locIndex
));
507 ures_close(currentLocale
);
510 ures_getStringByKey(currentLocale
, "Version", NULL
, &errorCode
);
511 if(errorCode
!= U_ZERO_ERROR
) {
512 log_err("No version information is available for locale %s, and it should be!\n",
515 else if (ures_getStringByKey(currentLocale
, "Version", NULL
, &errorCode
)[0] == (UChar
)(0x78)) {
516 log_verbose("WARNING: The locale %s is experimental! It shouldn't be listed as an installed locale.\n",
519 resolvedLoc
= ures_getLocaleByType(currentLocale
, ULOC_ACTUAL_LOCALE
, &errorCode
);
520 if (strcmp(resolvedLoc
, currLoc
) != 0) {
521 /* All locales have at least a Version resource.
522 If it's absolutely empty, then the previous test will fail too.*/
523 log_err("Locale resolves to different locale. Is %s an alias of %s?\n",
524 currLoc
, resolvedLoc
);
526 TestKeyInRootRecursive(root
, "root", currentLocale
, currLoc
);
528 testLCID(currentLocale
, currLoc
);
530 ures_close(currentLocale
);
537 compareArrays(const char *keyName
,
538 UResourceBundle
*fromArray
, const char *fromLocale
,
539 UResourceBundle
*toArray
, const char *toLocale
,
540 int32_t start
, int32_t end
)
542 int32_t fromSize
= ures_getSize(fromArray
);
543 int32_t toSize
= ures_getSize(fromArray
);
545 UErrorCode errorCode
= U_ZERO_ERROR
;
547 if (fromSize
> toSize
) {
549 log_err("Arrays are different size from \"%s\" to \"%s\"\n",
554 for (idx
= start
; idx
<= end
; idx
++) {
555 const UChar
*fromBundleStr
= ures_getStringByIndex(fromArray
, idx
, NULL
, &errorCode
);
556 const UChar
*toBundleStr
= ures_getStringByIndex(toArray
, idx
, NULL
, &errorCode
);
557 if (fromBundleStr
&& toBundleStr
&& u_strcmp(fromBundleStr
, toBundleStr
) != 0)
559 log_err("Difference for %s at index %d from %s= \"%s\" to %s= \"%s\"\n",
563 austrdup(fromBundleStr
),
565 austrdup(toBundleStr
));
571 compareConsistentCountryInfo(const char *fromLocale
, const char *toLocale
) {
572 UErrorCode errorCode
= U_ZERO_ERROR
;
573 UResourceBundle
*fromDateTimeElements
, *toDateTimeElements
, *fromWeekendData
= NULL
, *toWeekendData
= NULL
;
574 UResourceBundle
*fromArray
, *toArray
;
575 UResourceBundle
*fromLocaleBund
= ures_open(NULL
, fromLocale
, &errorCode
);
576 UResourceBundle
*toLocaleBund
= ures_open(NULL
, toLocale
, &errorCode
);
577 UResourceBundle
*toCalendar
, *fromCalendar
, *toGregorian
, *fromGregorian
;
579 if(U_FAILURE(errorCode
)) {
580 log_err("Can't open resource bundle %s or %s - %s\n", fromLocale
, toLocale
, u_errorName(errorCode
));
583 fromCalendar
= ures_getByKey(fromLocaleBund
, "calendar", NULL
, &errorCode
);
584 fromGregorian
= ures_getByKeyWithFallback(fromCalendar
, "gregorian", NULL
, &errorCode
);
585 fromDateTimeElements
= ures_getByKeyWithFallback(fromGregorian
, "DateTimeElements", NULL
, &errorCode
);
587 toCalendar
= ures_getByKey(toLocaleBund
, "calendar", NULL
, &errorCode
);
588 toGregorian
= ures_getByKeyWithFallback(toCalendar
, "gregorian", NULL
, &errorCode
);
589 toDateTimeElements
= ures_getByKeyWithFallback(toGregorian
, "DateTimeElements", NULL
, &errorCode
);
591 if(U_FAILURE(errorCode
)){
592 log_err("Did not get DateTimeElements from the bundle %s or %s\n", fromLocale
, toLocale
);
596 fromWeekendData
= ures_getByKeyWithFallback(fromGregorian
, "weekend", NULL
, &errorCode
);
597 if(U_FAILURE(errorCode
)){
598 log_err("Did not get weekend data from the bundle %s to compare against %s\n", fromLocale
, toLocale
);
601 toWeekendData
= ures_getByKeyWithFallback(toGregorian
, "weekend", NULL
, &errorCode
);
602 if(U_FAILURE(errorCode
)){
603 log_err("Did not get weekend data from the bundle %s to compare against %s\n", toLocale
, fromLocale
);
607 if (strcmp(fromLocale
, "ar_IN") != 0)
612 const int32_t *fromBundleArr
= ures_getIntVector(fromDateTimeElements
, &fromSize
, &errorCode
);
613 const int32_t *toBundleArr
= ures_getIntVector(toDateTimeElements
, &toSize
, &errorCode
);
615 if (fromSize
> toSize
) {
617 log_err("Arrays are different size with key \"DateTimeElements\" from \"%s\" to \"%s\"\n",
622 for (idx
= 0; idx
< fromSize
; idx
++) {
623 if (fromBundleArr
[idx
] != toBundleArr
[idx
]) {
624 log_err("Difference with key \"DateTimeElements\" at index %d from \"%s\" to \"%s\"\n",
632 /* test for weekend data */
637 const int32_t *fromBundleArr
= ures_getIntVector(fromWeekendData
, &fromSize
, &errorCode
);
638 const int32_t *toBundleArr
= ures_getIntVector(toWeekendData
, &toSize
, &errorCode
);
640 if (fromSize
> toSize
) {
642 log_err("Arrays are different size with key \"weekend\" data from \"%s\" to \"%s\"\n",
647 for (idx
= 0; idx
< fromSize
; idx
++) {
648 if (fromBundleArr
[idx
] != toBundleArr
[idx
]) {
649 log_err("Difference with key \"weekend\" data at index %d from \"%s\" to \"%s\"\n",
657 fromArray
= ures_getByKey(fromLocaleBund
, "CurrencyElements", NULL
, &errorCode
);
658 toArray
= ures_getByKey(toLocaleBund
, "CurrencyElements", NULL
, &errorCode
);
659 if (strcmp(fromLocale
, "en_CA") != 0)
661 /* The first one is probably localized. */
662 compareArrays("CurrencyElements", fromArray
, fromLocale
, toArray
, toLocale
, 1, 2);
664 ures_close(fromArray
);
667 fromArray
= ures_getByKey(fromLocaleBund
, "NumberPatterns", NULL
, &errorCode
);
668 toArray
= ures_getByKey(toLocaleBund
, "NumberPatterns", NULL
, &errorCode
);
669 if (strcmp(fromLocale
, "en_CA") != 0)
671 compareArrays("NumberPatterns", fromArray
, fromLocale
, toArray
, toLocale
, 0, 3);
673 ures_close(fromArray
);
676 /* Difficult to test properly */
678 fromArray = ures_getByKey(fromLocaleBund, "DateTimePatterns", NULL, &errorCode);
679 toArray = ures_getByKey(toLocaleBund, "DateTimePatterns", NULL, &errorCode);
681 compareArrays("DateTimePatterns", fromArray, fromLocale, toArray, toLocale);
683 ures_close(fromArray);
684 ures_close(toArray);*/
686 fromArray
= ures_getByKey(fromLocaleBund
, "NumberElements", NULL
, &errorCode
);
687 toArray
= ures_getByKey(toLocaleBund
, "NumberElements", NULL
, &errorCode
);
688 if (strcmp(fromLocale
, "en_CA") != 0)
690 compareArrays("NumberElements", fromArray
, fromLocale
, toArray
, toLocale
, 0, 3);
691 /* Index 4 is a script based 0 */
692 compareArrays("NumberElements", fromArray
, fromLocale
, toArray
, toLocale
, 5, 10);
694 ures_close(fromArray
);
698 ures_close(fromDateTimeElements
);
699 ures_close(toDateTimeElements
);
700 ures_close(fromWeekendData
);
701 ures_close(toWeekendData
);
703 ures_close(fromCalendar
);
704 ures_close(toCalendar
);
705 ures_close(fromGregorian
);
706 ures_close(toGregorian
);
708 ures_close(fromLocaleBund
);
709 ures_close(toLocaleBund
);
713 TestConsistentCountryInfo(void) {
714 /* UResourceBundle *fromLocale, *toLocale;*/
715 int32_t locCount
= uloc_countAvailable();
716 int32_t fromLocIndex
, toLocIndex
;
718 int32_t fromCountryLen
, toCountryLen
;
719 char fromCountry
[ULOC_FULLNAME_CAPACITY
], toCountry
[ULOC_FULLNAME_CAPACITY
];
721 int32_t fromVariantLen
, toVariantLen
;
722 char fromVariant
[ULOC_FULLNAME_CAPACITY
], toVariant
[ULOC_FULLNAME_CAPACITY
];
724 UErrorCode errorCode
= U_ZERO_ERROR
;
726 for (fromLocIndex
= 0; fromLocIndex
< locCount
; fromLocIndex
++) {
727 const char *fromLocale
= uloc_getAvailable(fromLocIndex
);
729 errorCode
=U_ZERO_ERROR
;
730 fromCountryLen
= uloc_getCountry(fromLocale
, fromCountry
, ULOC_FULLNAME_CAPACITY
, &errorCode
);
731 if (fromCountryLen
<= 0) {
732 /* Ignore countryless locales */
735 fromVariantLen
= uloc_getVariant(fromLocale
, fromVariant
, ULOC_FULLNAME_CAPACITY
, &errorCode
);
736 if (fromVariantLen
> 0) {
737 /* Most variants are ignorable like PREEURO, or collation variants. */
740 /* Start comparing only after the current index.
741 Previous loop should have already compared fromLocIndex.
743 for (toLocIndex
= fromLocIndex
+ 1; toLocIndex
< locCount
; toLocIndex
++) {
744 const char *toLocale
= uloc_getAvailable(toLocIndex
);
746 toCountryLen
= uloc_getCountry(toLocale
, toCountry
, ULOC_FULLNAME_CAPACITY
, &errorCode
);
747 if(U_FAILURE(errorCode
)) {
748 log_err("Unknown failure fromLocale=%s toLocale=%s errorCode=%s\n",
749 fromLocale
, toLocale
, u_errorName(errorCode
));
753 if (toCountryLen
<= 0) {
754 /* Ignore countryless locales */
757 toVariantLen
= uloc_getVariant(toLocale
, toVariant
, ULOC_FULLNAME_CAPACITY
, &errorCode
);
758 if (toVariantLen
> 0) {
759 /* Most variants are ignorable like PREEURO, or collation variants. */
760 /* They're a variant for a reason. */
763 if (strcmp(fromCountry
, toCountry
) == 0) {
764 log_verbose("comparing fromLocale=%s toLocale=%s\n",
765 fromLocale
, toLocale
);
766 compareConsistentCountryInfo(fromLocale
, toLocale
);
773 findStringSetMismatch(const char *currLoc
, const UChar
*string
, int32_t langSize
,
774 const UChar
*exemplarCharacters
, int32_t exemplarLen
,
775 UBool ignoreNumbers
) {
776 UErrorCode errorCode
= U_ZERO_ERROR
;
777 USet
*origSet
= uset_openPatternOptions(exemplarCharacters
, exemplarLen
, USET_CASE_INSENSITIVE
, &errorCode
);
778 USet
*exemplarSet
= createFlattenSet(origSet
, &errorCode
);
781 if (U_FAILURE(errorCode
)) {
782 log_err("%s: error uset_openPattern returned %s\n", currLoc
, u_errorName(errorCode
));
786 for (strIdx
= 0; strIdx
< langSize
; strIdx
++) {
787 if (!uset_contains(exemplarSet
, string
[strIdx
])
788 && string
[strIdx
] != 0x0020 && string
[strIdx
] != 0x00A0 && string
[strIdx
] != 0x002e && string
[strIdx
] != 0x002c && string
[strIdx
] != 0x002d && string
[strIdx
] != 0x0027
789 && string
[strIdx
] != 0x200C && string
[strIdx
] != 0x200D) {
790 if (!ignoreNumbers
|| (ignoreNumbers
&& (string
[strIdx
] < 0x30 || string
[strIdx
] > 0x39))) {
791 uset_close(exemplarSet
);
796 uset_close(exemplarSet
);
799 /* include non-invariant chars */
801 myUCharsToChars(const UChar
* us
, char* cs
, int32_t len
){
813 findSetMatch( UScriptCode
*scriptCodes
, int32_t scriptsLen
,
816 USet
*scripts
[10]= {0};
817 char pattern
[256] = { '[', ':', 0x000 };
819 UChar uPattern
[256] = {0};
820 UErrorCode status
= U_ZERO_ERROR
;
823 /* create the sets with script codes */
824 for(i
= 0; i
<scriptsLen
; i
++){
825 strcat(pattern
, uscript_getShortName(scriptCodes
[i
]));
826 strcat(pattern
, ":]");
827 patternLen
= (int32_t)strlen(pattern
);
828 u_charsToUChars(pattern
, uPattern
, patternLen
);
829 scripts
[i
] = uset_openPattern(uPattern
, patternLen
, &status
);
830 if(U_FAILURE(status
)){
831 log_err("Could not create set for pattern %s. Error: %s\n", pattern
, u_errorName(status
));
836 if (strcmp(locale
, "uk") == 0 || strcmp(locale
, "uk_UA") == 0) {
837 /* Special addition. Add the modifying apostrophe, which isn't in Cyrillic. */
838 uset_add(scripts
[0], 0x2bc);
840 if(U_SUCCESS(status
)){
841 UBool existsInScript
= FALSE
;
842 /* iterate over the exemplarSet and ascertain if all
843 * UChars in exemplarSet belong to the scripts returned
846 int32_t count
= uset_getItemCount(exemplarSet
);
848 for( i
=0; i
< count
; i
++){
852 int32_t strCapacity
= 0;
854 strCapacity
= uset_getItem(exemplarSet
, i
, &start
, &end
, str
, strCapacity
, &status
);
855 if(U_SUCCESS(status
)){
857 if(strCapacity
== 0){
858 /* ok the item is a range */
859 for( j
= 0; j
< scriptsLen
; j
++){
860 if(uset_containsRange(scripts
[j
], start
, end
) == TRUE
){
861 existsInScript
= TRUE
;
864 if(existsInScript
== FALSE
){
865 for( j
= 0; j
< scriptsLen
; j
++){
866 UChar toPattern
[500]={'\0'};
867 char pat
[500]={'\0'};
868 int32_t len
= uset_toPattern(scripts
[j
], toPattern
, 500, TRUE
, &status
);
869 len
= myUCharsToChars(toPattern
, pat
, len
);
870 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
));
872 log_err("Pattern: %s\n",pat
);
875 log_err("ExemplarCharacters and LocaleScript containment test failed for locale %s. \n", locale
);
878 strCapacity
++; /* increment for NUL termination */
879 /* allocate the str and call the api again */
880 str
= (UChar
*) malloc(U_SIZEOF_UCHAR
* strCapacity
);
881 strCapacity
= uset_getItem(exemplarSet
, i
, &start
, &end
, str
, strCapacity
, &status
);
882 /* iterate over the scripts and figure out if the string contained is actually
885 for( j
= 0; j
< scriptsLen
; j
++){
886 if(uset_containsString(scripts
[j
],str
, strCapacity
) == TRUE
){
887 existsInScript
= TRUE
;
890 if(existsInScript
== FALSE
){
891 log_err("ExemplarCharacters and LocaleScript containment test failed for locale %s. \n", locale
);
900 for(i
= 0; i
<scriptsLen
; i
++){
901 uset_close(scripts
[i
]);
905 static void VerifyTranslation(void) {
906 UResourceBundle
*root
, *currentLocale
;
907 int32_t locCount
= uloc_countAvailable();
909 UErrorCode errorCode
= U_ZERO_ERROR
;
911 const UChar
*exemplarCharacters
;
913 UScriptCode scripts
[USCRIPT_CODE_LIMIT
];
917 UResourceBundle
*resArray
;
920 log_data_err("At least root needs to be installed\n");
923 root
= ures_openDirect(NULL
, "root", &errorCode
);
924 if(U_FAILURE(errorCode
)) {
925 log_data_err("Can't open root\n");
928 for (locIndex
= 0; locIndex
< locCount
; locIndex
++) {
929 errorCode
=U_ZERO_ERROR
;
930 currLoc
= uloc_getAvailable(locIndex
);
931 currentLocale
= ures_open(NULL
, currLoc
, &errorCode
);
932 if(errorCode
!= U_ZERO_ERROR
) {
933 if(U_SUCCESS(errorCode
)) {
934 /* It's installed, but there is no data.
935 It's installed for the g18n white paper [grhoten] */
936 log_err("ERROR: Locale %-5s not installed, and it should be!\n",
937 uloc_getAvailable(locIndex
));
939 log_err("%%%%%%% Unexpected error %d in %s %%%%%%%",
940 u_errorName(errorCode
),
941 uloc_getAvailable(locIndex
));
943 ures_close(currentLocale
);
946 exemplarCharacters
= ures_getStringByKey(currentLocale
, "ExemplarCharacters", &exemplarLen
, &errorCode
);
947 if (U_FAILURE(errorCode
)) {
948 log_err("error ures_getStringByKey returned %s\n", u_errorName(errorCode
));
950 else if (QUICK
&& exemplarLen
> 2048) {
951 log_verbose("skipping test for %s\n", currLoc
);
954 UChar langBuffer
[128];
957 langSize
= uloc_getDisplayLanguage(currLoc
, currLoc
, langBuffer
, sizeof(langBuffer
)/sizeof(langBuffer
[0]), &errorCode
);
958 if (U_FAILURE(errorCode
)) {
959 log_err("error uloc_getDisplayLanguage returned %s\n", u_errorName(errorCode
));
962 strIdx
= findStringSetMismatch(currLoc
, langBuffer
, langSize
, exemplarCharacters
, exemplarLen
, FALSE
);
964 log_err("getDisplayLanguage(%s) at index %d returned characters not in the exemplar characters.\n",
968 langSize
= uloc_getDisplayCountry(currLoc
, currLoc
, langBuffer
, sizeof(langBuffer
)/sizeof(langBuffer
[0]), &errorCode
);
969 if (U_FAILURE(errorCode
)) {
970 log_err("error uloc_getDisplayCountry returned %s\n", u_errorName(errorCode
));
973 strIdx
= findStringSetMismatch(currLoc
, langBuffer
, langSize
, exemplarCharacters
, exemplarLen
, FALSE
);
975 log_err("getDisplayCountry(%s) at index %d returned characters not in the exemplar characters.\n",
980 UResourceBundle
* cal
= ures_getByKey(currentLocale
, "calendar", NULL
, &errorCode
);
981 UResourceBundle
* greg
= ures_getByKeyWithFallback(cal
, "gregorian", NULL
, &errorCode
);
982 UResourceBundle
* names
= ures_getByKeyWithFallback(greg
, "dayNames", NULL
, &errorCode
);
983 UResourceBundle
* format
= ures_getByKeyWithFallback(names
, "format", NULL
, &errorCode
);
984 resArray
= ures_getByKeyWithFallback(format
, "wide", NULL
, &errorCode
);
986 if (U_FAILURE(errorCode
)) {
987 log_err("error ures_getByKey returned %s\n", u_errorName(errorCode
));
993 end
= ures_getSize(resArray
);
997 for (idx
= 0; idx
< end
; idx
++) {
998 const UChar
*fromBundleStr
= ures_getStringByIndex(resArray
, idx
, &langSize
, &errorCode
);
999 if (U_FAILURE(errorCode
)) {
1000 log_err("error ures_getStringByIndex(%d) returned %s\n", idx
, u_errorName(errorCode
));
1003 strIdx
= findStringSetMismatch(currLoc
, fromBundleStr
, langSize
, exemplarCharacters
, exemplarLen
, TRUE
);
1005 log_err("getDayNames(%s, %d) at index %d returned characters not in the exemplar characters.\n",
1006 currLoc
, idx
, strIdx
);
1009 ures_close(resArray
);
1013 names
= ures_getByKeyWithFallback(greg
, "monthNames", NULL
, &errorCode
);
1014 format
= ures_getByKeyWithFallback(names
,"format", NULL
, &errorCode
);
1015 resArray
= ures_getByKeyWithFallback(format
, "wide", NULL
, &errorCode
);
1016 if (U_FAILURE(errorCode
)) {
1017 log_err("error ures_getByKey returned %s\n", u_errorName(errorCode
));
1023 end
= ures_getSize(resArray
);
1026 for (idx
= 0; idx
< end
; idx
++) {
1027 const UChar
*fromBundleStr
= ures_getStringByIndex(resArray
, idx
, &langSize
, &errorCode
);
1028 if (U_FAILURE(errorCode
)) {
1029 log_err("error ures_getStringByIndex(%d) returned %s\n", idx
, u_errorName(errorCode
));
1032 strIdx
= findStringSetMismatch(currLoc
, fromBundleStr
, langSize
, exemplarCharacters
, exemplarLen
, TRUE
);
1034 log_err("getMonthNames(%s, %d) at index %d returned characters not in the exemplar characters.\n",
1035 currLoc
, idx
, strIdx
);
1038 ures_close(resArray
);
1044 errorCode
= U_ZERO_ERROR
;
1045 numScripts
= uscript_getCode(currLoc
, scripts
, sizeof(scripts
)/sizeof(scripts
[0]), &errorCode
);
1046 if (numScripts
== 0) {
1047 log_err("uscript_getCode(%s) doesn't work.\n", currLoc
);
1048 }else if(scripts
[0] == USCRIPT_COMMON
){
1049 log_err("uscript_getCode(%s) returned USCRIPT_COMMON.\n", currLoc
);
1052 /* test that the scripts are a superset of exemplar characters. */
1054 ULocaleData
*uld
= ulocdata_open(currLoc
,&errorCode
);
1055 USet
*exemplarSet
= ulocdata_getExemplarSet(uld
, NULL
, 0, ULOCDATA_ES_STANDARD
, &errorCode
);
1056 /* test if exemplar characters are part of script code */
1057 findSetMatch(scripts
, numScripts
, exemplarSet
, currLoc
);
1058 uset_close(exemplarSet
);
1059 ulocdata_close(uld
);
1062 /* test that the paperSize API works */
1064 int32_t height
=0, width
=0;
1065 ulocdata_getPaperSize(currLoc
, &height
, &width
, &errorCode
);
1066 if(U_FAILURE(errorCode
)){
1067 log_err("ulocdata_getPaperSize failed for locale %s with error: %s \n", currLoc
, u_errorName(errorCode
));
1069 if(strstr(currLoc
, "_US")!=NULL
&& height
!= 279 && width
!= 216 ){
1070 log_err("ulocdata_getPaperSize did not return expected data for locale %s \n", currLoc
);
1073 /* test that the MeasurementSystem works API works */
1075 UMeasurementSystem measurementSystem
= ulocdata_getMeasurementSystem(currLoc
, &errorCode
);
1076 if(U_FAILURE(errorCode
)){
1077 log_err("ulocdata_getMeasurementSystem failed for locale %s with error: %s \n", currLoc
, u_errorName(errorCode
));
1079 if(strstr(currLoc
, "_US")!=NULL
){
1080 if(measurementSystem
!= UMS_US
){
1081 log_err("ulocdata_getMeasurementSystem did not return expected data for locale %s \n", currLoc
);
1083 }else if(measurementSystem
!= UMS_SI
){
1084 log_err("ulocdata_getMeasurementSystem did not return expected data for locale %s \n", currLoc
);
1088 ures_close(currentLocale
);
1094 /* adjust this limit as appropriate */
1095 #define MAX_SCRIPTS_PER_LOCALE 8
1097 static void TestExemplarSet(void){
1098 int32_t i
, j
, k
, m
, n
;
1099 int32_t equalCount
= 0;
1100 UErrorCode ec
= U_ZERO_ERROR
;
1101 UEnumeration
* avail
;
1102 USet
* exemplarSets
[2];
1103 USet
* unassignedSet
;
1104 UScriptCode code
[MAX_SCRIPTS_PER_LOCALE
];
1105 USet
* codeSets
[MAX_SCRIPTS_PER_LOCALE
];
1107 char cbuf
[32]; /* 9 should be enough */
1108 UChar ubuf
[64]; /* adjust as needed */
1109 UBool existsInScript
;
1114 unassignedSet
= NULL
;
1115 exemplarSets
[0] = NULL
;
1116 exemplarSets
[1] = NULL
;
1117 for (i
=0; i
<MAX_SCRIPTS_PER_LOCALE
; ++i
) {
1121 avail
= ures_openAvailableLocales(NULL
, &ec
);
1122 if (!assertSuccess("ures_openAvailableLocales", &ec
)) goto END
;
1123 n
= uenum_count(avail
, &ec
);
1124 if (!assertSuccess("uenum_count", &ec
)) goto END
;
1126 u_uastrcpy(ubuf
, "[:unassigned:]");
1127 unassignedSet
= uset_openPattern(ubuf
, -1, &ec
);
1128 if (!assertSuccess("uset_openPattern", &ec
)) goto END
;
1131 const char* locale
= uenum_next(avail
, NULL
, &ec
);
1132 if (!assertSuccess("uenum_next", &ec
)) goto END
;
1133 log_verbose("%s\n", locale
);
1134 for (k
=0; k
<2; ++k
) {
1135 uint32_t option
= (k
==0) ? 0 : USET_CASE_INSENSITIVE
;
1136 ULocaleData
*uld
= ulocdata_open(locale
,&ec
);
1137 USet
* exemplarSet
= ulocdata_getExemplarSet(uld
,NULL
, option
, ULOCDATA_ES_STANDARD
, &ec
);
1138 uset_close(exemplarSets
[k
]);
1139 ulocdata_close(uld
);
1140 exemplarSets
[k
] = exemplarSet
;
1141 if (!assertSuccess("ulocaledata_getExemplarSet", &ec
)) goto END
;
1143 if (uset_containsSome(exemplarSet
, unassignedSet
)) {
1144 log_err("ExemplarSet contains unassigned characters for locale : %s\n", locale
);
1146 codeLen
= uscript_getCode(locale
, code
, 8, &ec
);
1147 if (!assertSuccess("uscript_getCode", &ec
)) goto END
;
1149 for (j
=0; j
<MAX_SCRIPTS_PER_LOCALE
; ++j
) {
1150 uset_close(codeSets
[j
]);
1153 for (j
=0; j
<codeLen
; ++j
) {
1154 uprv_strcpy(cbuf
, "[:");
1156 log_err("USCRIPT_INVALID_CODE returned for locale: %s\n", locale
);
1159 uprv_strcat(cbuf
, uscript_getShortName(code
[j
]));
1160 uprv_strcat(cbuf
, ":]");
1161 u_uastrcpy(ubuf
, cbuf
);
1162 codeSets
[j
] = uset_openPattern(ubuf
, -1, &ec
);
1164 if (!assertSuccess("uset_openPattern", &ec
)) goto END
;
1166 existsInScript
= FALSE
;
1167 itemCount
= uset_getItemCount(exemplarSet
);
1168 for (m
=0; m
<itemCount
&& !existsInScript
; ++m
) {
1169 strLen
= uset_getItem(exemplarSet
, m
, &start
, &end
, ubuf
,
1170 sizeof(ubuf
)/sizeof(ubuf
[0]), &ec
);
1171 /* failure here might mean str[] needs to be larger */
1172 if (!assertSuccess("uset_getItem", &ec
)) goto END
;
1174 for (j
=0; j
<codeLen
; ++j
) {
1175 if (codeSets
[j
]!=NULL
&& uset_containsRange(codeSets
[j
], start
, end
)) {
1176 existsInScript
= TRUE
;
1181 for (j
=0; j
<codeLen
; ++j
) {
1182 if (codeSets
[j
]!=NULL
&& uset_containsString(codeSets
[j
], ubuf
, strLen
)) {
1183 existsInScript
= TRUE
;
1190 if (existsInScript
== FALSE
){
1191 log_err("ExemplarSet containment failed for locale : %s\n", locale
);
1194 assertTrue("case-folded is a superset",
1195 uset_containsAll(exemplarSets
[1], exemplarSets
[0]));
1196 if (uset_equals(exemplarSets
[1], exemplarSets
[0])) {
1200 /* Note: The case-folded set should sometimes be a strict superset
1201 and sometimes be equal. */
1202 assertTrue("case-folded is sometimes a strict superset, and sometimes equal",
1203 equalCount
> 0 && equalCount
< n
);
1207 uset_close(exemplarSets
[0]);
1208 uset_close(exemplarSets
[1]);
1209 uset_close(unassignedSet
);
1210 for (i
=0; i
<MAX_SCRIPTS_PER_LOCALE
; ++i
) {
1211 uset_close(codeSets
[i
]);
1215 static void TestCoverage(void){
1216 ULocaleDataDelimiterType types
[] = {
1217 ULOCDATA_QUOTATION_START
, /* Quotation start */
1218 ULOCDATA_QUOTATION_END
, /* Quotation end */
1219 ULOCDATA_ALT_QUOTATION_START
, /* Alternate quotation start */
1220 ULOCDATA_ALT_QUOTATION_END
, /* Alternate quotation end */
1221 ULOCDATA_DELIMITER_COUNT
1225 UErrorCode status
= U_ZERO_ERROR
;
1226 ULocaleData
*uld
= ulocdata_open(uloc_getDefault(), &status
);
1228 if(U_FAILURE(status
)){
1229 log_err("ulocdata_open error");
1234 for(i
= 0; i
< ULOCDATA_DELIMITER_COUNT
; i
++){
1235 UChar result
[32] = {0,};
1236 status
= U_ZERO_ERROR
;
1237 ulocdata_getDelimiter(uld
, types
[i
], result
, 32, &status
);
1238 if (U_FAILURE(status
)){
1239 log_err("ulocdata_getgetDelimiter error with type %d", types
[i
]);
1243 sub
= ulocdata_getNoSubstitute(uld
);
1244 ulocdata_setNoSubstitute(uld
,sub
);
1245 ulocdata_close(uld
);
1248 static void TestCurrencyList(void){
1249 #if !UCONFIG_NO_FORMATTING
1250 UErrorCode errorCode
= U_ZERO_ERROR
;
1251 int32_t structLocaleCount
, currencyCount
;
1252 UEnumeration
*en
= ucurr_openISOCurrencies(UCURR_ALL
, &errorCode
);
1253 const char *isoCode
, *structISOCode
;
1254 UResourceBundle
*subBundle
;
1255 UResourceBundle
*currencies
= ures_openDirect(loadTestData(&errorCode
), "structLocale", &errorCode
);
1256 if(U_FAILURE(errorCode
)) {
1257 log_data_err("Can't open structLocale\n");
1260 currencies
= ures_getByKey(currencies
, "Currencies", currencies
, &errorCode
);
1261 currencyCount
= uenum_count(en
, &errorCode
);
1262 structLocaleCount
= ures_getSize(currencies
);
1263 if (currencyCount
!= structLocaleCount
) {
1264 log_err("structLocale(%d) and ISO4217(%d) currency list are out of sync.\n", structLocaleCount
, currencyCount
);
1265 #if U_CHARSET_FAMILY == U_ASCII_FAMILY
1266 ures_resetIterator(currencies
);
1267 while ((isoCode
= uenum_next(en
, NULL
, &errorCode
)) != NULL
&& ures_hasNext(currencies
)) {
1268 subBundle
= ures_getNextResource(currencies
, NULL
, &errorCode
);
1269 structISOCode
= ures_getKey(subBundle
);
1270 ures_close(subBundle
);
1271 if (strcmp(structISOCode
, isoCode
) != 0) {
1272 log_err("First difference found at structLocale(%s) and ISO4217(%s).\n", structISOCode
, isoCode
);
1278 ures_close(currencies
);
1283 #define TESTCASE(name) addTest(root, &name, "tsutil/cldrtest/" #name)
1285 void addCLDRTest(TestNode
** root
);
1287 void addCLDRTest(TestNode
** root
)
1289 TESTCASE(TestLocaleStructure
);
1290 TESTCASE(TestConsistentCountryInfo
);
1291 TESTCASE(VerifyTranslation
);
1292 TESTCASE(TestExemplarSet
);
1293 TESTCASE(TestCurrencyList
);
1294 TESTCASE(TestCoverage
);