mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 22:15:31 +00:00
ICU-2487 further getFunctionalEquivalent test changes
X-SVN-Rev: 15354
This commit is contained in:
parent
2e9def5cdb
commit
61d3a101a0
1 changed files with 73 additions and 32 deletions
|
@ -948,12 +948,69 @@ static void TestGetKeywordValues(void) {
|
|||
log_err("'standard' was not found in the keyword list.\n");
|
||||
}
|
||||
uenum_close(kwVals);
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("err %s getting collation values\n", u_errorName(status));
|
||||
}
|
||||
status = U_ZERO_ERROR;
|
||||
|
||||
kwVals = ures_getKeywordValues( "ICUDATA", "calendar", &status);
|
||||
|
||||
log_verbose("Testing getting calendar keyword values:\n");
|
||||
|
||||
while(kw=uenum_next(kwVals, NULL, &status)) {
|
||||
log_verbose(" %s\n", kw);
|
||||
if(!strcmp(kw,"standard")) {
|
||||
if(foundStandard == FALSE) {
|
||||
foundStandard = TRUE;
|
||||
} else {
|
||||
log_err("'standard' was found twice in the calendar keyword list.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(foundStandard == FALSE) {
|
||||
log_err("'standard' was not found in the calendar keyword list.\n");
|
||||
}
|
||||
uenum_close(kwVals);
|
||||
if(U_FAILURE(status)) {
|
||||
log_err("err %s getting calendar values\n", u_errorName(status));
|
||||
}
|
||||
}
|
||||
|
||||
static void TestGetFunctionalEquivalentOf(const char *path, const char *resName, const char *keyword, UBool truncate, const char *testCases[]) {
|
||||
int32_t i;
|
||||
for(i=0;testCases[i];i+=3) {
|
||||
UBool expectAvail = (testCases[i][0]=='t')?TRUE:FALSE;
|
||||
UBool gotAvail = FALSE;
|
||||
const char *inLocale = testCases[i+1];
|
||||
const char *expectLocale = testCases[i+2];
|
||||
char equivLocale[256];
|
||||
int32_t len;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
log_verbose("%d: %c %s\texpect %s\n",i/3, expectAvail?'t':'f', inLocale, expectLocale);
|
||||
len = ures_getFunctionalEquivalent(equivLocale, 255, path,
|
||||
resName, keyword, inLocale,
|
||||
&gotAvail, truncate, &status);
|
||||
if(U_FAILURE(status) || (len <= 0)) {
|
||||
log_err("FAIL: got len %d, err %s on #%d: %c\t%s\t%s\n",
|
||||
len, u_errorName(status),
|
||||
i/3,expectAvail?'t':'f', inLocale, expectLocale);
|
||||
} else {
|
||||
log_verbose("got: %c %s\n", expectAvail?'t':'f',equivLocale);
|
||||
|
||||
if((gotAvail != expectAvail) || strcmp(equivLocale, expectLocale)) {
|
||||
log_err("FAIL: got avail=%c, loc=%s but expected #%d: %c\t%s\t-> loc=%s\n",
|
||||
gotAvail?'t':'f', equivLocale,
|
||||
i/3,
|
||||
expectAvail?'t':'f', inLocale, expectLocale);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TestGetFunctionalEquivalent(void) {
|
||||
int32_t i;
|
||||
static const char *testCases[] = {
|
||||
/* avail locale equiv */
|
||||
static const char *collCases[] = {
|
||||
/* avail locale equiv */
|
||||
"f", "de_US_CALIFORNIA", "de",
|
||||
"t", "zh_TW@collation=stroke", "zh@collation=stroke",
|
||||
"f", "de_CN@collation=pinyin", "de",
|
||||
|
@ -972,35 +1029,19 @@ static void TestGetFunctionalEquivalent(void) {
|
|||
"f", "hi_AU@collation=standard;currency=CHF;calendar=buddhist", "hi",
|
||||
NULL
|
||||
};
|
||||
|
||||
for(i=0;testCases[i];i+=3) {
|
||||
UBool expectAvail = (testCases[i][0]=='t')?TRUE:FALSE;
|
||||
UBool gotAvail;
|
||||
const char *inLocale = testCases[i+1];
|
||||
const char *expectLocale = testCases[i+2];
|
||||
char equivLocale[256];
|
||||
int32_t len;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
log_verbose("%d: %c %s\texpect %s\n",i/3, expectAvail?'t':'f', inLocale, expectLocale);
|
||||
len = ures_getFunctionalEquivalent(equivLocale, 255, U_ICUDATA_COLL,
|
||||
"collations", "collation", inLocale,
|
||||
&gotAvail, &status);
|
||||
if(U_FAILURE(status) || (len <= 0)) {
|
||||
log_err("FAIL: got len %d, err %s on #%d: %c\t%s\t%s\n",
|
||||
len, u_errorName(status),
|
||||
i/3,expectAvail?'t':'f', inLocale, expectLocale);
|
||||
} else {
|
||||
log_verbose("got: %c %s\n", expectAvail?'t':'f',equivLocale);
|
||||
|
||||
if((gotAvail != expectAvail) || strcmp(equivLocale, expectLocale)) {
|
||||
log_err("FAIL: got avail=%c, loc=%s but expected #%d: %c\t%s\t-> loc=%s\n",
|
||||
gotAvail?'t':'f', equivLocale,
|
||||
i/3,
|
||||
expectAvail?'t':'f', inLocale, expectLocale);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
static const char *calCases[] = {
|
||||
/* avail locale equiv */
|
||||
"t", "en_US", "en@calendar=gregorian",
|
||||
"f", "ja_JP_TOKYO", "ja@calendar=gregorian",
|
||||
"f", "ja_JP_TOKYO@calendar=japanese", "ja@calendar=japanese",
|
||||
"t", "sr@calendar=gregorian", "sr@calendar=gregorian",
|
||||
"t", "en", "en@calendar=gregorian",
|
||||
NULL
|
||||
};
|
||||
|
||||
TestGetFunctionalEquivalentOf(U_ICUDATA_COLL, "collations", "collation", TRUE, collCases);
|
||||
TestGetFunctionalEquivalentOf("ICUDATA", "calendar", "calendar", FALSE, calCases);
|
||||
|
||||
log_verbose("Testing error conditions:\n");
|
||||
{
|
||||
|
@ -1011,7 +1052,7 @@ static void TestGetFunctionalEquivalent(void) {
|
|||
|
||||
len = ures_getFunctionalEquivalent(equivLocale, 255, U_ICUDATA_COLL,
|
||||
"calendar", "calendar", "ar_EG@calendar=islamic",
|
||||
&gotAvail, &status);
|
||||
&gotAvail, FALSE, &status);
|
||||
|
||||
if(status == U_MISSING_RESOURCE_ERROR) {
|
||||
log_verbose("PASS: Got expected U_MISSING_RESOURCE_ERROR\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue