X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..51004dcb01e06fef634b61be77ed73dd61cb6db9:/icuSources/test/cintltst/cldrtest.c diff --git a/icuSources/test/cintltst/cldrtest.c b/icuSources/test/cintltst/cldrtest.c index 053b109e..2515b1f1 100644 --- a/icuSources/test/cintltst/cldrtest.c +++ b/icuSources/test/cintltst/cldrtest.c @@ -1,36 +1,80 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2004, International Business Machines Corporation and + * Copyright (c) 1997-2013, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ #include "cintltst.h" #include "unicode/ures.h" +#include "unicode/ucurr.h" #include "unicode/ustring.h" #include "unicode/uset.h" #include "unicode/udat.h" #include "unicode/uscript.h" +#include "unicode/uloc.h" #include "unicode/ulocdata.h" #include "cstring.h" #include "locmap.h" #include "uresimp.h" -static UBool isCurrencyPreEuro(const char* currencyKey){ +/* +returns a new UnicodeSet that is a flattened form of the original +UnicodeSet. +*/ +static USet* +createFlattenSet(USet *origSet, UErrorCode *status) { + + + USet *newSet = NULL; + int32_t origItemCount = 0; + int32_t idx, graphmeSize; + UChar32 start, end; + UChar graphme[64]; + if (U_FAILURE(*status)) { + log_err("createFlattenSet called with %s\n", u_errorName(*status)); + return NULL; + } + newSet = uset_open(1, 0); + origItemCount = uset_getItemCount(origSet); + for (idx = 0; idx < origItemCount; idx++) { + graphmeSize = uset_getItem(origSet, idx, + &start, &end, + graphme, (int32_t)(sizeof(graphme)/sizeof(graphme[0])), + status); + if (U_FAILURE(*status)) { + log_err("ERROR: uset_getItem returned %s\n", u_errorName(*status)); + *status = U_ZERO_ERROR; + } + if (graphmeSize) { + uset_addAllCodePoints(newSet, graphme, graphmeSize); + } + else { + uset_addRange(newSet, start, end); + } + } + uset_closeOver(newSet,USET_CASE_INSENSITIVE); + return newSet; +} + +static UBool +isCurrencyPreEuro(const char* currencyKey){ if( strcmp(currencyKey, "PTE") == 0 || strcmp(currencyKey, "ESP") == 0 || strcmp(currencyKey, "LUF") == 0 || strcmp(currencyKey, "GRD") == 0 || strcmp(currencyKey, "BEF") == 0 || - strcmp(currencyKey, "ITL") == 0 ){ + strcmp(currencyKey, "ITL") == 0 || + strcmp(currencyKey, "EEK") == 0){ return TRUE; } return FALSE; } +#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION static void TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, UResourceBundle *currentBundle, const char *locale) { UErrorCode errorCode = U_ZERO_ERROR; - UResourceBundle *subRootBundle = NULL, *subBundle = NULL; + UResourceBundle *subRootBundle = NULL, *subBundle = NULL, *arr = NULL; ures_resetIterator(root); ures_resetIterator(currentBundle); @@ -42,11 +86,11 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, currentBundleKey = ures_getKey(currentBundle); subBundle = ures_getNextResource(currentBundle, NULL, &errorCode); if (U_FAILURE(errorCode)) { - log_err("Can't open a resource for locale %s. Error: %s\n", locale, u_errorName(errorCode)); + log_err("Can't open a resource for lnocale %s. Error: %s\n", locale, u_errorName(errorCode)); continue; } subBundleKey = ures_getKey(subBundle); - + subRootBundle = ures_getByKey(root, subBundleKey, NULL, &errorCode); if (U_FAILURE(errorCode)) { @@ -66,6 +110,7 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, locale, ures_getType(subRootBundle), ures_getType(subBundle)); + ures_close(subBundle); continue; } else if (ures_getType(subBundle) == URES_INT_VECTOR) { @@ -115,26 +160,8 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, if (U_SUCCESS(errorCode) && (ures_getType(subSubBundle) == URES_ARRAY || ures_getType(subSubRootBundle) == URES_ARRAY)) { - /* TODO: Properly check for 2D arrays and zoneStrings */ - if (subBundleKey != NULL && strcmp(subBundleKey, "zoneStrings") == 0) { -/* int32_t minSize = ures_getSize(subBundle); - int32_t idx; - - for (idx = 0; idx < minSize; idx++) { - UResourceBundle *subSubBundleAtIndex = ures_getByIndex(subBundle, idx, NULL, &errorCode); - if (ures_getSize(subSubBundleAtIndex) != 6) { - log_err("zoneStrings at index %d has wrong size for locale \"%s\". array size=%d\n", - idx, - locale, - ures_getSize(subSubBundleAtIndex)); - } - ures_close(subSubBundleAtIndex); - }*/ - } - else { - /* Here is one of the recursive parts */ - TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale); - } + /* Here is one of the recursive parts */ + TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale); } else { int32_t minSize = ures_getSize(subRootBundle); @@ -176,12 +203,47 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, } } else { - log_err("Got a NULL string with key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n", + if ( rootStrLen > 1 && rootStr[0] == 0x41 && rootStr[1] >= 0x30 && rootStr[1] <= 0x39 ) { + /* A2 or A4 in the root string indicates that the resource can optionally be an array instead of a */ + /* string. Attempt to read it as an array. */ + errorCode = U_ZERO_ERROR; + arr = ures_getByIndex(subBundle,idx,NULL,&errorCode); + if (U_FAILURE(errorCode)) { + log_err("Got a NULL string with key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n", + subBundleKey, + ures_getKey(currentBundle), + idx, + locale); + continue; + } + if (ures_getType(arr) != URES_ARRAY || ures_getSize(arr) != (int32_t)rootStr[1] - 0x30) { + 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", + rootStr[1] - 0x30, + subBundleKey, + ures_getKey(currentBundle), + idx, + locale); + ures_close(arr); + continue; + } + localeStr = ures_getStringByIndex(arr,0,&localeStrLen,&errorCode); + ures_close(arr); + if (U_FAILURE(errorCode)) { + log_err("Got something other than a string or array for key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n", + subBundleKey, + ures_getKey(currentBundle), + idx, + locale); + continue; + } + } else { + log_err("Got a NULL string with key \"%s\" in \"%s\" at index %d for root or locale \"%s\"\n", subBundleKey, ures_getKey(currentBundle), idx, locale); - continue; + continue; + } } if (localeStr[0] == (UChar)0x20) { log_err("key \"%s\" at index %d in \"%s\" starts with a space in locale \"%s\"\n", @@ -190,7 +252,7 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, ures_getKey(currentBundle), locale); } - else if (localeStr[localeStrLen - 1] == (UChar)0x20) { + else if ((localeStr[localeStrLen - 1] == (UChar)0x20) && (strcmp(subBundleKey,"separator") != 0)) { log_err("key \"%s\" at index %d in \"%s\" ends with a space in locale \"%s\"\n", subBundleKey, idx, @@ -276,12 +338,17 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, subBundleKey, ures_getKey(currentBundle), locale); - } else if (string[len - 1] == (UChar)0x20) { + /* localeDisplayPattern/separator can end with a space */ + } else if (string[len - 1] == (UChar)0x20 && (strcmp(subBundleKey,"separator"))) { log_err("key \"%s\" in \"%s\" ends with a space in locale \"%s\"\n", subBundleKey, ures_getKey(currentBundle), locale); } else if (strcmp(subBundleKey, "localPatternChars") == 0) { + /* Note: We no longer import localPatternChars data starting + * ICU 3.8. So it never comes into this else if block. (ticket#5597) + */ + /* Check well-formedness of localPatternChars. First, the * length must match the number of fields defined by * DateFormat. Second, each character in the string must @@ -329,7 +396,7 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, ures_getKey(currentBundle)); continue; } else if (u_strcmp(string, rootString) == 0) { - if (strcmp(locale, "de_CH") != 0 && strcmp(subBundleKey, "Countries") != 0 && + if (strcmp(locale, "de_CH") != 0 && strcmp(subBundleKey, "Countries") != 0 && strcmp(subBundleKey, "Version") != 0) { log_err("Found duplicate data with key \"%s\" in \"%s\" in locale \"%s\"\n", ures_getKey(subRootBundle), @@ -346,8 +413,13 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, #endif } else if (ures_getType(subBundle) == URES_TABLE) { - /* Here is one of the recursive parts */ - TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale); + if (strcmp(subBundleKey, "availableFormats")!=0) { + /* Here is one of the recursive parts */ + TestKeyInRootRecursive(subRootBundle, rootName, subBundle, locale); + } + else { + log_verbose("Skipping key %s in %s\n", subBundleKey, locale); + } } else if (ures_getType(subBundle) == URES_BINARY || ures_getType(subBundle) == URES_INT) { /* Can't do anything to check it */ @@ -371,7 +443,7 @@ TestKeyInRootRecursive(UResourceBundle *root, const char *rootName, ures_close(subBundle); } } - +#endif static void testLCID(UResourceBundle *currentBundle, @@ -412,13 +484,14 @@ testLCID(UResourceBundle *currentBundle, } } +#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION static void TestLocaleStructure(void) { UResourceBundle *root, *currentLocale; int32_t locCount = uloc_countAvailable(); int32_t locIndex; UErrorCode errorCode = U_ZERO_ERROR; - const char *currLoc; + const char *currLoc, *resolvedLoc; /* TODO: Compare against parent's data too. This code can't handle fallbacks that some tools do already. */ /* char locName[ULOC_FULLNAME_CAPACITY]; @@ -458,8 +531,8 @@ TestLocaleStructure(void) { if(U_SUCCESS(errorCode)) { /* It's installed, but there is no data. It's installed for the g18n white paper [grhoten] */ - log_err("ERROR: Locale %-5s not installed, and it should be!\n", - uloc_getAvailable(locIndex)); + log_err("ERROR: Locale %-5s not installed, and it should be, err %s\n", + uloc_getAvailable(locIndex), u_errorName(errorCode)); } else { log_err("%%%%%%% Unexpected error %d in %s %%%%%%%", u_errorName(errorCode), @@ -477,6 +550,13 @@ TestLocaleStructure(void) { log_verbose("WARNING: The locale %s is experimental! It shouldn't be listed as an installed locale.\n", currLoc); } + resolvedLoc = ures_getLocaleByType(currentLocale, ULOC_ACTUAL_LOCALE, &errorCode); + if (strcmp(resolvedLoc, currLoc) != 0) { + /* All locales have at least a Version resource. + If it's absolutely empty, then the previous test will fail too.*/ + log_err("Locale resolves to different locale. Is %s an alias of %s?\n", + currLoc, resolvedLoc); + } TestKeyInRootRecursive(root, "root", currentLocale, currLoc); testLCID(currentLocale, currLoc); @@ -486,6 +566,7 @@ TestLocaleStructure(void) { ures_close(root); } +#endif static void compareArrays(const char *keyName, @@ -524,7 +605,6 @@ compareArrays(const char *keyName, static void compareConsistentCountryInfo(const char *fromLocale, const char *toLocale) { UErrorCode errorCode = U_ZERO_ERROR; - UResourceBundle *fromDateTimeElements, *toDateTimeElements, *fromWeekendData = NULL, *toWeekendData = NULL; UResourceBundle *fromArray, *toArray; UResourceBundle *fromLocaleBund = ures_open(NULL, fromLocale, &errorCode); UResourceBundle *toLocaleBund = ures_open(NULL, toLocale, &errorCode); @@ -536,77 +616,9 @@ compareConsistentCountryInfo(const char *fromLocale, const char *toLocale) { } fromCalendar = ures_getByKey(fromLocaleBund, "calendar", NULL, &errorCode); fromGregorian = ures_getByKeyWithFallback(fromCalendar, "gregorian", NULL, &errorCode); - fromDateTimeElements = ures_getByKeyWithFallback(fromGregorian, "DateTimeElements", NULL, &errorCode); - + toCalendar = ures_getByKey(toLocaleBund, "calendar", NULL, &errorCode); toGregorian = ures_getByKeyWithFallback(toCalendar, "gregorian", NULL, &errorCode); - toDateTimeElements = ures_getByKeyWithFallback(toGregorian, "DateTimeElements", NULL, &errorCode); - - if(U_FAILURE(errorCode)){ - log_err("Did not get DateTimeElements from the bundle %s or %s\n", fromLocale, toLocale); - goto cleanup; - } - - fromWeekendData = ures_getByKeyWithFallback(fromGregorian, "weekend", NULL, &errorCode); - if(U_FAILURE(errorCode)){ - log_err("Did not get weekend data from the bundle %s to compare against %s\n", fromLocale, toLocale); - goto cleanup; - } - toWeekendData = ures_getByKeyWithFallback(toGregorian, "weekend", NULL, &errorCode); - if(U_FAILURE(errorCode)){ - log_err("Did not get weekend data from the bundle %s to compare against %s\n", toLocale, fromLocale); - goto cleanup; - } - - if (strcmp(fromLocale, "ar_IN") != 0) - { - int32_t fromSize; - int32_t toSize; - int32_t idx; - const int32_t *fromBundleArr = ures_getIntVector(fromDateTimeElements, &fromSize, &errorCode); - const int32_t *toBundleArr = ures_getIntVector(toDateTimeElements, &toSize, &errorCode); - - if (fromSize > toSize) { - fromSize = toSize; - log_err("Arrays are different size with key \"DateTimeElements\" from \"%s\" to \"%s\"\n", - fromLocale, - toLocale); - } - - for (idx = 0; idx < fromSize; idx++) { - if (fromBundleArr[idx] != toBundleArr[idx]) { - log_err("Difference with key \"DateTimeElements\" at index %d from \"%s\" to \"%s\"\n", - idx, - fromLocale, - toLocale); - } - } - } - - /* test for weekend data */ - { - int32_t fromSize; - int32_t toSize; - int32_t idx; - const int32_t *fromBundleArr = ures_getIntVector(fromWeekendData, &fromSize, &errorCode); - const int32_t *toBundleArr = ures_getIntVector(toWeekendData, &toSize, &errorCode); - - if (fromSize > toSize) { - fromSize = toSize; - log_err("Arrays are different size with key \"weekend\" data from \"%s\" to \"%s\"\n", - fromLocale, - toLocale); - } - - for (idx = 0; idx < fromSize; idx++) { - if (fromBundleArr[idx] != toBundleArr[idx]) { - log_err("Difference with key \"weekend\" data at index %d from \"%s\" to \"%s\"\n", - idx, - fromLocale, - toLocale); - } - } - } fromArray = ures_getByKey(fromLocaleBund, "CurrencyElements", NULL, &errorCode); toArray = ures_getByKey(toLocaleBund, "CurrencyElements", NULL, &errorCode); @@ -647,13 +659,6 @@ compareConsistentCountryInfo(const char *fromLocale, const char *toLocale) { } ures_close(fromArray); ures_close(toArray); - -cleanup: - ures_close(fromDateTimeElements); - ures_close(toDateTimeElements); - ures_close(fromWeekendData); - ures_close(toWeekendData); - ures_close(fromCalendar); ures_close(toCalendar); ures_close(fromGregorian); @@ -726,29 +731,51 @@ TestConsistentCountryInfo(void) { static int32_t findStringSetMismatch(const char *currLoc, const UChar *string, int32_t langSize, const UChar *exemplarCharacters, int32_t exemplarLen, - UBool ignoreNumbers) { + UBool ignoreNumbers, UChar* badCharPtr) { UErrorCode errorCode = U_ZERO_ERROR; - USet *exemplarSet = uset_openPatternOptions(exemplarCharacters, exemplarLen, USET_CASE_INSENSITIVE, &errorCode); + USet *origSet = uset_openPatternOptions(exemplarCharacters, exemplarLen, USET_CASE_INSENSITIVE, &errorCode); + USet *exemplarSet = createFlattenSet(origSet, &errorCode); int32_t strIdx; + uset_close(origSet); if (U_FAILURE(errorCode)) { - log_err("%s: error uset_openPattern returned %s\n", currLoc, u_errorName(errorCode)); + log_err("%s: error uset_openPattern returned %s\n", currLoc, u_errorName(errorCode)); return -1; } for (strIdx = 0; strIdx < langSize; strIdx++) { if (!uset_contains(exemplarSet, string[strIdx]) - && string[strIdx] != 0x0020 && string[strIdx] != 0x00A0 && string[strIdx] != 0x002e && string[strIdx] != 0x002c && string[strIdx] != 0x002d && string[strIdx] != 0x0027) { + && string[strIdx] != 0x0020 && string[strIdx] != 0x00A0 && string[strIdx] != 0x002e && string[strIdx] != 0x002c && string[strIdx] != 0x002d && string[strIdx] != 0x0027 && string[strIdx] != 0x005B && string[strIdx] != 0x005D && string[strIdx] != 0x2019 && string[strIdx] != 0x0f0b + && string[strIdx] != 0x200C && string[strIdx] != 0x200D) { if (!ignoreNumbers || (ignoreNumbers && (string[strIdx] < 0x30 || string[strIdx] > 0x39))) { + uset_close(exemplarSet); + if (badCharPtr) { + *badCharPtr = string[strIdx]; + } return strIdx; } } } uset_close(exemplarSet); + if (badCharPtr) { + *badCharPtr = 0; + } return -1; } - -static void -findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen, +/* include non-invariant chars */ +static int32_t +myUCharsToChars(const UChar* us, char* cs, int32_t len){ + int32_t i=0; + for(; i< len; i++){ + if(us[i] < 0x7f){ + cs[i] = (char)us[i]; + }else{ + return -1; + } + } + return i; +} +static void +findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen, USet *exemplarSet, const char *locale){ USet *scripts[10]= {0}; @@ -766,10 +793,10 @@ findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen, u_charsToUChars(pattern, uPattern, patternLen); scripts[i] = uset_openPattern(uPattern, patternLen, &status); if(U_FAILURE(status)){ - log_err("Could not create set for patter %s. Error: %s\n", pattern, u_errorName(status)); - break; + log_err("Could not create set for pattern %s. Error: %s\n", pattern, u_errorName(status)); + return; } - pattern[2] = 0; + pattern[2] = 0; } if (strcmp(locale, "uk") == 0 || strcmp(locale, "uk_UA") == 0) { /* Special addition. Add the modifying apostrophe, which isn't in Cyrillic. */ @@ -800,6 +827,16 @@ findSetMatch( UScriptCode *scriptCodes, int32_t scriptsLen, } } if(existsInScript == FALSE){ + for( j = 0; j < scriptsLen; j++){ + UChar toPattern[500]={'\0'}; + char pat[500]={'\0'}; + int32_t len = uset_toPattern(scripts[j], toPattern, 500, TRUE, &status); + len = myUCharsToChars(toPattern, pat, len); + 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)); + if(len!=-1){ + log_err("Pattern: %s\n",pat); + } + } log_err("ExemplarCharacters and LocaleScript containment test failed for locale %s. \n", locale); } }else{ @@ -875,33 +912,37 @@ static void VerifyTranslation(void) { if (U_FAILURE(errorCode)) { log_err("error ures_getStringByKey returned %s\n", u_errorName(errorCode)); } - else if (QUICK && exemplarLen > 2048) { + else if (getTestOption(QUICK_OPTION) && exemplarLen > 2048) { log_verbose("skipping test for %s\n", currLoc); } + else if (uprv_strncmp(currLoc,"bem",3) == 0 || uprv_strncmp(currLoc,"mgo",3) == 0 || uprv_strncmp(currLoc,"nl",2) == 0 || uprv_strncmp(currLoc,"ky",2) == 0) { + log_verbose("skipping test for %s, some month and country names known to use aux exemplars\n", currLoc); + } else { UChar langBuffer[128]; int32_t langSize; int32_t strIdx; + UChar badChar; langSize = uloc_getDisplayLanguage(currLoc, currLoc, langBuffer, sizeof(langBuffer)/sizeof(langBuffer[0]), &errorCode); if (U_FAILURE(errorCode)) { log_err("error uloc_getDisplayLanguage returned %s\n", u_errorName(errorCode)); } else { - strIdx = findStringSetMismatch(currLoc, langBuffer, langSize, exemplarCharacters, exemplarLen, FALSE); + strIdx = findStringSetMismatch(currLoc, langBuffer, langSize, exemplarCharacters, exemplarLen, FALSE, &badChar); if (strIdx >= 0) { - log_err("getDisplayLanguage(%s) at index %d returned characters not in the exemplar characters.\n", - currLoc, strIdx); + log_err("getDisplayLanguage(%s) at index %d returned characters not in the exemplar characters: %04X.\n", + currLoc, strIdx, badChar); } } langSize = uloc_getDisplayCountry(currLoc, currLoc, langBuffer, sizeof(langBuffer)/sizeof(langBuffer[0]), &errorCode); if (U_FAILURE(errorCode)) { log_err("error uloc_getDisplayCountry returned %s\n", u_errorName(errorCode)); } - else { - strIdx = findStringSetMismatch(currLoc, langBuffer, langSize, exemplarCharacters, exemplarLen, FALSE); + else if (uprv_strstr(currLoc, "ti_") != currLoc || isICUVersionAtLeast(52, 0, 1)) { /* TODO: FIX or REMOVE this test! Was: restore DisplayCountry test for ti_* when cldrbug 3058 is fixed) - but CldrBug:3058 is wontfix */ + strIdx = findStringSetMismatch(currLoc, langBuffer, langSize, exemplarCharacters, exemplarLen, FALSE, &badChar); if (strIdx >= 0) { - log_err("getDisplayCountry(%s) at index %d returned characters not in the exemplar characters.\n", - currLoc, strIdx); + log_err("getDisplayCountry(%s) at index %d returned characters not in the exemplar characters: %04X.\n", + currLoc, strIdx, badChar); } } { @@ -914,7 +955,7 @@ static void VerifyTranslation(void) { if (U_FAILURE(errorCode)) { log_err("error ures_getByKey returned %s\n", u_errorName(errorCode)); } - if (QUICK) { + if (getTestOption(QUICK_OPTION)) { end = 1; } else { @@ -928,10 +969,12 @@ static void VerifyTranslation(void) { log_err("error ures_getStringByIndex(%d) returned %s\n", idx, u_errorName(errorCode)); continue; } - strIdx = findStringSetMismatch(currLoc, fromBundleStr, langSize, exemplarCharacters, exemplarLen, TRUE); - if (strIdx >= 0) { - log_err("getDayNames(%s, %d) at index %d returned characters not in the exemplar characters.\n", - currLoc, idx, strIdx); + if (uprv_strstr(currLoc, "uz_Arab") != currLoc || isICUVersionAtLeast(52, 0, 1)) { /* TODO: FIX or REMOVE this test! */ + strIdx = findStringSetMismatch(currLoc, fromBundleStr, langSize, exemplarCharacters, exemplarLen, TRUE, &badChar); + if (strIdx >= 0) { + log_err("getDayNames(%s, %d) at index %d returned characters not in the exemplar characters: %04X.\n", + currLoc, idx, strIdx, badChar); + } } } ures_close(resArray); @@ -944,7 +987,7 @@ static void VerifyTranslation(void) { if (U_FAILURE(errorCode)) { log_err("error ures_getByKey returned %s\n", u_errorName(errorCode)); } - if (QUICK) { + if (getTestOption(QUICK_OPTION)) { end = 1; } else { @@ -957,10 +1000,12 @@ static void VerifyTranslation(void) { log_err("error ures_getStringByIndex(%d) returned %s\n", idx, u_errorName(errorCode)); continue; } - strIdx = findStringSetMismatch(currLoc, fromBundleStr, langSize, exemplarCharacters, exemplarLen, TRUE); - if (strIdx >= 0) { - log_err("getMonthNames(%s, %d) at index %d returned characters not in the exemplar characters.\n", - currLoc, idx, strIdx); + if (uprv_strstr(currLoc, "uz_Arab") != currLoc || isICUVersionAtLeast(52, 0, 1)) { /* TODO: FIX or REMOVE this test! */ + strIdx = findStringSetMismatch(currLoc, fromBundleStr, langSize, exemplarCharacters, exemplarLen, TRUE, &badChar); + if (strIdx >= 0) { + log_err("getMonthNames(%s, %d) at index %d returned characters not in the exemplar characters: %04X.\n", + currLoc, idx, strIdx, badChar); + } } } ures_close(resArray); @@ -974,15 +1019,17 @@ static void VerifyTranslation(void) { if (numScripts == 0) { log_err("uscript_getCode(%s) doesn't work.\n", currLoc); }else if(scripts[0] == USCRIPT_COMMON){ - log_err("uscript_getCode(%s) returned USCRIPT_COMMON.\n", currLoc); + log_err("uscript_getCode(%s) returned USCRIPT_COMMON.\n", currLoc); } /* test that the scripts are a superset of exemplar characters. */ { - USet *exemplarSet = ulocdata_getExemplarSet(NULL,currLoc, 0, &errorCode); + ULocaleData *uld = ulocdata_open(currLoc,&errorCode); + USet *exemplarSet = ulocdata_getExemplarSet(uld, NULL, 0, ULOCDATA_ES_STANDARD, &errorCode); /* test if exemplar characters are part of script code */ findSetMatch(scripts, numScripts, exemplarSet, currLoc); uset_close(exemplarSet); + ulocdata_close(uld); } /* test that the paperSize API works */ @@ -998,11 +1045,13 @@ static void VerifyTranslation(void) { } /* test that the MeasurementSystem works API works */ { + char fullLoc[ULOC_FULLNAME_CAPACITY]; UMeasurementSystem measurementSystem = ulocdata_getMeasurementSystem(currLoc, &errorCode); if(U_FAILURE(errorCode)){ log_err("ulocdata_getMeasurementSystem failed for locale %s with error: %s \n", currLoc, u_errorName(errorCode)); } - if(strstr(currLoc, "_US")!=NULL){ + uloc_addLikelySubtags(currLoc, fullLoc, ULOC_FULLNAME_CAPACITY, &errorCode); + if(strstr(fullLoc, "_US")!=NULL || strstr(fullLoc, "_MM")!=NULL || strstr(fullLoc, "_LR")!=NULL){ if(measurementSystem != UMS_US){ log_err("ulocdata_getMeasurementSystem did not return expected data for locale %s \n", currLoc); } @@ -1026,6 +1075,7 @@ static void TestExemplarSet(void){ UErrorCode ec = U_ZERO_ERROR; UEnumeration* avail; USet* exemplarSets[2]; + USet* unassignedSet; UScriptCode code[MAX_SCRIPTS_PER_LOCALE]; USet* codeSets[MAX_SCRIPTS_PER_LOCALE]; int32_t codeLen; @@ -1035,8 +1085,10 @@ static void TestExemplarSet(void){ int32_t itemCount; int32_t strLen; UChar32 start, end; - - exemplarSets[0] = exemplarSets[1] = NULL; + + unassignedSet = NULL; + exemplarSets[0] = NULL; + exemplarSets[1] = NULL; for (i=0; i 0 && equalCount < n); - + END: uenum_close(avail); uset_close(exemplarSets[0]); uset_close(exemplarSets[1]); + uset_close(unassignedSet); for (i=0; i1970-01-01.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, date1975, U_DATE_MAX, &errorCode) == FALSE) { + log_data_err("FAIL: ISO code (%s) was available in time range >1975.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, date1981, U_DATE_MAX, &errorCode) == TRUE) { + log_err("FAIL: ISO code (%s) was not available in time range >1981.\n", lastCode); + } + + /* from = null */ + if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1970, &errorCode) == TRUE) { + log_err("FAIL: ISO code (%s) was not available in time range <1970.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1975, &errorCode) == FALSE) { + log_data_err("FAIL: ISO code (%s) was available in time range <1975.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, U_DATE_MIN, date1981, &errorCode) == FALSE) { + log_data_err("FAIL: ISO code (%s) was available in time range <1981.\n", lastCode); + } + + /* full ranges */ + if (ucurr_isAvailable(isoCode, date1975, date1978, &errorCode) == FALSE) { + log_data_err("FAIL: ISO code (%s) was available in time range 1975-1978.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, date1970, date1975, &errorCode) == FALSE) { + log_data_err("FAIL: ISO code (%s) was available in time range 1970-1975.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, date1975, date1981, &errorCode) == FALSE) { + log_data_err("FAIL: ISO code (%s) was available in time range 1975-1981.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, date1970, date1981, &errorCode) == FALSE) { + log_data_err("FAIL: ISO code (%s) was available in time range 1970-1981.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, date1981, date1992, &errorCode) == TRUE) { + log_err("FAIL: ISO code (%s) was not available in time range 1981-1992.\n", lastCode); + } + + if (ucurr_isAvailable(isoCode, date1950, date1970, &errorCode) == TRUE) { + log_err("FAIL: ISO code (%s) was not available in time range 1950-1970.\n", lastCode); + } + + /* wrong range - from > to*/ + if (ucurr_isAvailable(isoCode, date1975, date1970, &errorCode) == TRUE) { + log_err("FAIL: Wrong range 1975-1970 for ISO code (%s) was not reported.\n", lastCode); + } else if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) { + log_data_err("FAIL: Error code not reported for wrong range 1975-1970 for ISO code (%s).\n", lastCode); + } + + free(isoCode); +#endif +} + #define TESTCASE(name) addTest(root, &name, "tsutil/cldrtest/" #name) void addCLDRTest(TestNode** root); void addCLDRTest(TestNode** root) { +#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION TESTCASE(TestLocaleStructure); + TESTCASE(TestCurrencyList); +#endif TESTCASE(TestConsistentCountryInfo); TESTCASE(VerifyTranslation); TESTCASE(TestExemplarSet); + TESTCASE(TestLocaleDisplayPattern); + TESTCASE(TestCoverage); + TESTCASE(TestIndexChars); + TESTCASE(TestAvailableIsoCodes); } +