OLD | NEW |
1 /******************************************************************** | 1 /******************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2013, International Business Machines Corporation and | 3 * Copyright (c) 1997-2014, International Business Machines Corporation and |
4 * others. All Rights Reserved. | 4 * others. All Rights Reserved. |
5 ********************************************************************/ | 5 ********************************************************************/ |
6 | 6 |
7 #include "cintltst.h" | 7 #include "cintltst.h" |
8 #include "unicode/ures.h" | 8 #include "unicode/ures.h" |
9 #include "unicode/ucurr.h" | 9 #include "unicode/ucurr.h" |
10 #include "unicode/ustring.h" | 10 #include "unicode/ustring.h" |
11 #include "unicode/uset.h" | 11 #include "unicode/uset.h" |
12 #include "unicode/udat.h" | 12 #include "unicode/udat.h" |
13 #include "unicode/uscript.h" | 13 #include "unicode/uscript.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 if(strcmp(localeName, lcidStringC) != 0) { | 473 if(strcmp(localeName, lcidStringC) != 0) { |
474 char langName[1024]; | 474 char langName[1024]; |
475 char langLCID[1024]; | 475 char langLCID[1024]; |
476 uloc_getLanguage(localeName, langName, sizeof(langName), &status); | 476 uloc_getLanguage(localeName, langName, sizeof(langName), &status); |
477 uloc_getLanguage(lcidStringC, langLCID, sizeof(langLCID), &status); | 477 uloc_getLanguage(lcidStringC, langLCID, sizeof(langLCID), &status); |
478 | 478 |
479 if (strcmp(langName, langLCID) == 0) { | 479 if (strcmp(langName, langLCID) == 0) { |
480 log_verbose("WARNING: %-5s resolves to %s (0x%.4x)\n", | 480 log_verbose("WARNING: %-5s resolves to %s (0x%.4x)\n", |
481 localeName, lcidStringC, expectedLCID); | 481 localeName, lcidStringC, expectedLCID); |
482 } | 482 } |
483 else { | 483 else if (strncmp(localeName, "hsb", 3) != 0 || !log_knownIssue("11216",
"Duplicate LCID mapping for language hsb")) { |
484 log_err("ERROR: %-5s has 0x%.4x and the number resolves wrongfully
to %s\n", | 484 log_err("ERROR: %-5s has 0x%.4x and the number resolves wrongfully
to %s\n", |
485 localeName, expectedLCID, lcidStringC); | 485 localeName, expectedLCID, lcidStringC); |
486 } | 486 } |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION | 490 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION |
491 static void | 491 static void |
492 TestLocaleStructure(void) { | 492 TestLocaleStructure(void) { |
493 // This test checks the locale structure against a key file located | 493 // This test checks the locale structure against a key file located |
494 // at source/test/testdata/structLocale.txt. When adding new data to | 494 // at source/test/testdata/structLocale.txt. When adding new data to |
495 // a loale file such as en.txt, the structLocale.txt file must be changed | 495 // a locale file such as en.txt, the structLocale.txt file must be changed |
496 // too to include the the template of the new data. Otherwise this test | 496 // too to include the the template of the new data. Otherwise this test |
497 // will fail! | 497 // will fail! |
498 | 498 |
499 UResourceBundle *root, *currentLocale; | 499 UResourceBundle *root, *currentLocale; |
500 int32_t locCount = uloc_countAvailable(); | 500 int32_t locCount = uloc_countAvailable(); |
501 int32_t locIndex; | 501 int32_t locIndex; |
502 UErrorCode errorCode = U_ZERO_ERROR; | 502 UErrorCode errorCode = U_ZERO_ERROR; |
503 const char *currLoc, *resolvedLoc; | 503 const char *currLoc, *resolvedLoc; |
504 | 504 |
505 /* TODO: Compare against parent's data too. This code can't handle fallbacks
that some tools do already. */ | 505 /* TODO: Compare against parent's data too. This code can't handle fallbacks
that some tools do already. */ |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 end = ures_getSize(resArray); | 988 end = ures_getSize(resArray); |
989 } | 989 } |
990 | 990 |
991 | 991 |
992 for (idx = 0; idx < end; idx++) { | 992 for (idx = 0; idx < end; idx++) { |
993 const UChar *fromBundleStr = ures_getStringByIndex(resArray,
idx, &langSize, &errorCode); | 993 const UChar *fromBundleStr = ures_getStringByIndex(resArray,
idx, &langSize, &errorCode); |
994 if (U_FAILURE(errorCode)) { | 994 if (U_FAILURE(errorCode)) { |
995 log_err("error ures_getStringByIndex(%d) returned %s\n",
idx, u_errorName(errorCode)); | 995 log_err("error ures_getStringByIndex(%d) returned %s\n",
idx, u_errorName(errorCode)); |
996 continue; | 996 continue; |
997 } | 997 } |
998 if (uprv_strstr(currLoc, "uz_Arab") != currLoc || !log_known
Issue("10405", "skipping exemplar check: %s", currLoc)) { /* TODO: FIX or REMOVE
this test! */ | 998 strIdx = findStringSetMismatch(currLoc, fromBundleStr, langS
ize, mergedExemplarSet, TRUE, &badChar); |
999 strIdx = findStringSetMismatch(currLoc, fromBundleStr, l
angSize, mergedExemplarSet, TRUE, &badChar); | 999 if (strIdx >= 0) { |
1000 if (strIdx >= 0) { | 1000 log_err("getDayNames(%s, %d) at index %d returned charac
ters not in the exemplar characters: %04X.\n", |
1001 log_err("getDayNames(%s, %d) at index %d returned ch
aracters not in the exemplar characters: %04X.\n", | 1001 currLoc, idx, strIdx, badChar); |
1002 currLoc, idx, strIdx, badChar); | |
1003 } | |
1004 } | 1002 } |
1005 } | 1003 } |
1006 ures_close(resArray); | 1004 ures_close(resArray); |
1007 ures_close(format); | 1005 ures_close(format); |
1008 ures_close(names); | 1006 ures_close(names); |
1009 | 1007 |
1010 names = ures_getByKeyWithFallback(greg, "monthNames", NULL, &err
orCode); | 1008 names = ures_getByKeyWithFallback(greg, "monthNames", NULL, &err
orCode); |
1011 format = ures_getByKeyWithFallback(names,"format", NULL, &errorC
ode); | 1009 format = ures_getByKeyWithFallback(names,"format", NULL, &errorC
ode); |
1012 resArray = ures_getByKeyWithFallback(format, "wide", NULL, &erro
rCode); | 1010 resArray = ures_getByKeyWithFallback(format, "wide", NULL, &erro
rCode); |
1013 if (U_FAILURE(errorCode)) { | 1011 if (U_FAILURE(errorCode)) { |
1014 log_err("error ures_getByKey returned %s\n", u_errorName(err
orCode)); | 1012 log_err("error ures_getByKey returned %s\n", u_errorName(err
orCode)); |
1015 } | 1013 } |
1016 if (getTestOption(QUICK_OPTION)) { | 1014 if (getTestOption(QUICK_OPTION)) { |
1017 end = 1; | 1015 end = 1; |
1018 } | 1016 } |
1019 else { | 1017 else { |
1020 end = ures_getSize(resArray); | 1018 end = ures_getSize(resArray); |
1021 } | 1019 } |
1022 | 1020 |
1023 for (idx = 0; idx < end; idx++) { | 1021 for (idx = 0; idx < end; idx++) { |
1024 const UChar *fromBundleStr = ures_getStringByIndex(resArray,
idx, &langSize, &errorCode); | 1022 const UChar *fromBundleStr = ures_getStringByIndex(resArray,
idx, &langSize, &errorCode); |
1025 if (U_FAILURE(errorCode)) { | 1023 if (U_FAILURE(errorCode)) { |
1026 log_err("error ures_getStringByIndex(%d) returned %s\n",
idx, u_errorName(errorCode)); | 1024 log_err("error ures_getStringByIndex(%d) returned %s\n",
idx, u_errorName(errorCode)); |
1027 continue; | 1025 continue; |
1028 } | 1026 } |
1029 if (uprv_strstr(currLoc, "uz_Arab") != currLoc || !log_known
Issue("10405", "skipping exemplar check: %s", currLoc)) { /* TODO: FIX or REMOVE
this test! */ | 1027 strIdx = findStringSetMismatch(currLoc, fromBundleStr, langS
ize, mergedExemplarSet, TRUE, &badChar); |
1030 strIdx = findStringSetMismatch(currLoc, fromBundleStr, l
angSize, mergedExemplarSet, TRUE, &badChar); | 1028 if (strIdx >= 0) { |
1031 if (strIdx >= 0) { | 1029 log_err("getMonthNames(%s, %d) at index %d returned char
acters not in the exemplar characters: %04X.\n", |
1032 log_err("getMonthNames(%s, %d) at index %d returned
characters not in the exemplar characters: %04X.\n", | 1030 currLoc, idx, strIdx, badChar); |
1033 currLoc, idx, strIdx, badChar); | |
1034 } | |
1035 } | 1031 } |
1036 } | 1032 } |
1037 ures_close(resArray); | 1033 ures_close(resArray); |
1038 ures_close(format); | 1034 ures_close(format); |
1039 ures_close(names); | 1035 ures_close(names); |
1040 ures_close(greg); | 1036 ures_close(greg); |
1041 ures_close(cal); | 1037 ures_close(cal); |
1042 } | 1038 } |
1043 errorCode = U_ZERO_ERROR; | 1039 errorCode = U_ZERO_ERROR; |
1044 numScripts = uscript_getCode(currLoc, scripts, sizeof(scripts)/sizeo
f(scripts[0]), &errorCode); | 1040 numScripts = uscript_getCode(currLoc, scripts, sizeof(scripts)/sizeo
f(scripts[0]), &errorCode); |
| 1041 if (strcmp(currLoc, "yi") == 0 && numScripts > 0 && log_knownIssue("
11217", "Fix result of uscript_getCode for yi: USCRIPT_YI -> USCRIPT_HEBREW")) { |
| 1042 scripts[0] = USCRIPT_HEBREW; |
| 1043 } |
1045 if (numScripts == 0) { | 1044 if (numScripts == 0) { |
1046 log_err("uscript_getCode(%s) doesn't work.\n", currLoc); | 1045 log_err("uscript_getCode(%s) doesn't work.\n", currLoc); |
1047 }else if(scripts[0] == USCRIPT_COMMON){ | 1046 }else if(scripts[0] == USCRIPT_COMMON){ |
1048 log_err("uscript_getCode(%s) returned USCRIPT_COMMON.\n", currLo
c); | 1047 log_err("uscript_getCode(%s) returned USCRIPT_COMMON.\n", currLo
c); |
1049 } | 1048 } |
1050 | 1049 |
1051 /* test that the scripts are a superset of exemplar characters. */ | 1050 /* test that the scripts are a superset of exemplar characters. */ |
1052 { | 1051 { |
1053 ULocaleData *uld = ulocdata_open(currLoc,&errorCode); | 1052 ULocaleData *uld = ulocdata_open(currLoc,&errorCode); |
1054 USet *exemplarSet = ulocdata_getExemplarSet(uld, NULL, 0, ULOCD
ATA_ES_STANDARD, &errorCode); | 1053 USet *exemplarSet = ulocdata_getExemplarSet(uld, NULL, 0, ULOCD
ATA_ES_STANDARD, &errorCode); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 USet* exemplarSet = ulocdata_getExemplarSet(uld,NULL, option, ULOCDA
TA_ES_STANDARD, &ec); | 1163 USet* exemplarSet = ulocdata_getExemplarSet(uld,NULL, option, ULOCDA
TA_ES_STANDARD, &ec); |
1165 uset_close(exemplarSets[k]); | 1164 uset_close(exemplarSets[k]); |
1166 ulocdata_close(uld); | 1165 ulocdata_close(uld); |
1167 exemplarSets[k] = exemplarSet; | 1166 exemplarSets[k] = exemplarSet; |
1168 if (!assertSuccess("ulocaledata_getExemplarSet", &ec)) goto END; | 1167 if (!assertSuccess("ulocaledata_getExemplarSet", &ec)) goto END; |
1169 | 1168 |
1170 if (uset_containsSome(exemplarSet, unassignedSet)) { | 1169 if (uset_containsSome(exemplarSet, unassignedSet)) { |
1171 log_err("ExemplarSet contains unassigned characters for locale :
%s\n", locale); | 1170 log_err("ExemplarSet contains unassigned characters for locale :
%s\n", locale); |
1172 } | 1171 } |
1173 codeLen = uscript_getCode(locale, code, 8, &ec); | 1172 codeLen = uscript_getCode(locale, code, 8, &ec); |
| 1173 if (strcmp(locale, "yi") == 0 && codeLen > 0 && log_knownIssue("1121
7", "Fix result of uscript_getCode for yi: USCRIPT_YI -> USCRIPT_HEBREW")) { |
| 1174 code[0] = USCRIPT_HEBREW; |
| 1175 } |
1174 if (!assertSuccess("uscript_getCode", &ec)) goto END; | 1176 if (!assertSuccess("uscript_getCode", &ec)) goto END; |
1175 | 1177 |
1176 for (j=0; j<MAX_SCRIPTS_PER_LOCALE; ++j) { | 1178 for (j=0; j<MAX_SCRIPTS_PER_LOCALE; ++j) { |
1177 uset_close(codeSets[j]); | 1179 uset_close(codeSets[j]); |
1178 codeSets[j] = NULL; | 1180 codeSets[j] = NULL; |
1179 } | 1181 } |
1180 for (j=0; j<codeLen; ++j) { | 1182 for (j=0; j<codeLen; ++j) { |
1181 uprv_strcpy(cbuf, "[:"); | 1183 uprv_strcpy(cbuf, "[:"); |
1182 if(code[j]==-1){ | 1184 if(code[j]==-1){ |
1183 log_err("USCRIPT_INVALID_CODE returned for locale: %s\n", lo
cale); | 1185 log_err("USCRIPT_INVALID_CODE returned for locale: %s\n", lo
cale); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 #endif | 1514 #endif |
1513 TESTCASE(TestConsistentCountryInfo); | 1515 TESTCASE(TestConsistentCountryInfo); |
1514 TESTCASE(VerifyTranslation); | 1516 TESTCASE(VerifyTranslation); |
1515 TESTCASE(TestExemplarSet); | 1517 TESTCASE(TestExemplarSet); |
1516 TESTCASE(TestLocaleDisplayPattern); | 1518 TESTCASE(TestLocaleDisplayPattern); |
1517 TESTCASE(TestCoverage); | 1519 TESTCASE(TestCoverage); |
1518 TESTCASE(TestIndexChars); | 1520 TESTCASE(TestIndexChars); |
1519 TESTCASE(TestAvailableIsoCodes); | 1521 TESTCASE(TestAvailableIsoCodes); |
1520 } | 1522 } |
1521 | 1523 |
OLD | NEW |