ICU-3748 merge alan's changes, modify to not test getName on non-ICU localeIDs, modify test of canonicalize of "@foo=bar" to not convert empty base to en_US_POSIX

X-SVN-Rev: 15393
This commit is contained in:
Doug Felt 2004-05-19 03:01:16 +00:00
parent 854360738c
commit 8064ff5e19

View File

@ -709,83 +709,116 @@ public class ULocaleTest extends TestFmwk {
}
public void TestCanonicalization(){
final String[][]testCases = new String[][]{
{ "ca_ES_PREEURO-with-extra-stuff-that really doesn't make any sense-unless-you're trying to increase code coverage",
"ca_ES_PREEURO_WITH_EXTRA_STUFF_THAT REALLY DOESN'T MAKE ANY SENSE_UNLESS_YOU'RE TRYING TO INCREASE CODE COVERAGE"},
{ "ca_ES_PREEURO", "ca_ES@currency=ESP" },
{ "de_AT_PREEURO", "de_AT@currency=ATS" },
{ "de_DE_PREEURO", "de_DE@currency=DEM" },
{ "de_LU_PREEURO", "de_LU@currency=EUR" },
{ "el_GR_PREEURO", "el_GR@currency=GRD" },
{ "en_BE_PREEURO", "en_BE@currency=BEF" },
{ "en_IE_PREEURO", "en_IE@currency=IEP" },
{ "es_ES_PREEURO", "es_ES@currency=ESP" },
{ "eu_ES_PREEURO", "eu_ES@currency=ESP" },
{ "fi_FI_PREEURO", "fi_FI@currency=FIM" },
{ "fr_BE_PREEURO", "fr_BE@currency=BEF" },
{ "fr_FR_PREEURO", "fr_FR@currency=FRF" },
{ "fr_LU_PREEURO", "fr_LU@currency=LUF" },
{ "ga_IE_PREEURO", "ga_IE@currency=IEP" },
{ "gl_ES_PREEURO", "gl_ES@currency=ESP" },
{ "it_IT_PREEURO", "it_IT@currency=ITL" },
{ "nl_BE_PREEURO", "nl_BE@currency=BEF" },
{ "nl_NL_PREEURO", "nl_NL@currency=NLG" },
{ "pt_PT_PREEURO", "pt_PT@currency=PTE" },
{ "de__PHONEBOOK", "de@collation=phonebook" },
{ "en_GB_EURO", "en_GB@currency=EUR" },
{ "en_GB@EURO", "en_GB@currency=EUR" }, //POSIX ID
{ "es__TRADITIONAL", "es@collation=traditional" },
{ "hi__DIRECT", "hi@collation=direct" },
{ "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" },
{ "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" },
{ "zh_TW_STROKE", "zh_TW@collation=stroke" },
{ "zh__PINYIN", "zh@collation=pinyin" },
{ "zh@collation=pinyin", "zh@collation=pinyin" },
{ "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" },
{ "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin" },
{ "en_US_POSIX", "en_US_POSIX" },
{ "hy_AM_REVISED", "hy_AM_REVISED" },
{ "no_NO_NY", "no_NO_NY" },
{ "no@ny", "no__NY" }, //POSIX ID
{ "no-no.utf32@B", "no_NO_B" }, //POSIX ID
{ "qz-qz@Euro", "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */
{ "en-BOONT", "en__BOONT" }, /* registered name */
{ "de-1901", "de__1901" }, /* registered name */
{ "de-1906", "de__1906" }, /* registered name */
{ "sr-SP-Cyrl", "sr_Cyrl_SP" }, /* .NET name */
{ "sr-SP-Latn", "sr_Latn_SP" }, /* .NET name */
{ "uz-UZ-Cyrl", "uz_Cyrl_UZ" }, /* .NET name */
{ "uz-UZ-Latn", "uz_Latn_UZ" }, /* .NET name */
{ "zh-CHS", "zh_Hans" }, /* .NET name */
{ "zh-CHT", "zh_TW" }, /* .NET name This may change back to zh_Hant */
{ "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES@currency=ESP" },
{ "de_AT_PREEURO", "de_AT_PREEURO", "de_AT@currency=ATS" },
{ "de_DE_PREEURO", "de_DE_PREEURO", "de_DE@currency=DEM" },
{ "de_LU_PREEURO", "de_LU_PREEURO", "de_LU@currency=EUR" },
{ "el_GR_PREEURO", "el_GR_PREEURO", "el_GR@currency=GRD" },
{ "en_BE_PREEURO", "en_BE_PREEURO", "en_BE@currency=BEF" },
{ "en_IE_PREEURO", "en_IE_PREEURO", "en_IE@currency=IEP" },
{ "es_ES_PREEURO", "es_ES_PREEURO", "es_ES@currency=ESP" },
{ "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES@currency=ESP" },
{ "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI@currency=FIM" },
{ "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE@currency=BEF" },
{ "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR@currency=FRF" },
{ "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU@currency=LUF" },
{ "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE@currency=IEP" },
{ "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES@currency=ESP" },
{ "it_IT_PREEURO", "it_IT_PREEURO", "it_IT@currency=ITL" },
{ "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE@currency=BEF" },
{ "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL@currency=NLG" },
{ "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT@currency=PTE" },
{ "de__PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" },
{ "en_GB_EURO", "en_GB_EURO", "en_GB@currency=EUR" },
{ "en_GB@EURO", null, "en_GB@currency=EUR" }, /* POSIX ID */
{ "es__TRADITIONAL", "es__TRADITIONAL", "es@collation=traditional" },
{ "hi__DIRECT", "hi__DIRECT", "hi@collation=direct" },
{ "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" },
{ "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" },
{ "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW@collation=stroke" },
{ "zh__PINYIN", "zh__PINYIN", "zh@collation=pinyin" },
{ "zh@collation=pinyin", "zh@collation=pinyin", "zh@collation=pinyin" },
{ "zh_CN@collation=pinyin", "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" },
{ "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin" },
{ "en_US_POSIX", "en_US_POSIX", "en_US_POSIX" },
{ "hy_AM_REVISED", "hy_AM_REVISED", "hy_AM_REVISED" },
{ "no_NO_NY", "no_NO_NY", "no_NO_NY" /* not: "nn_NO" [alan ICU3.0] */ },
{ "no@ny", null, "no__NY" /* not: "nn" [alan ICU3.0] */ }, /* POSIX ID */
{ "no-no.utf32@B", null, "no_NO_B" /* not: "nb_NO_B" [alan ICU3.0] */ }, /* POSIX ID */
{ "qz-qz@Euro", null, "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */
{ "en-BOONT", "en_BOONT", "en__BOONT" }, /* registered name */
{ "de-1901", "de_1901", "de__1901" }, /* registered name */
{ "de-1906", "de_1906", "de__1906" }, /* registered name */
{ "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_SP" }, /* .NET name */
{ "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_SP" }, /* .NET name */
{ "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */
{ "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */
{ "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */
{ "zh-CHT", "zh_CHT", "zh_TW" }, /* .NET name This may change back to zh_Hant */
// posix behavior that used to be performed by getName
{ "mr.utf8", "mr" },
{ "de-tv.koi8r", "de_TV" },
{ "x-piglatin_ML.MBE", "x-piglatin_ML" },
{ "i-cherokee_US.utf7", "i-cherokee_US" },
{ "x-filfli_MT_FILFLA.gb-18030", "x-filfli_MT_FILFLA" },
{ "no-no-ny.utf8@B", "no_NO_NY_B" }, /* variant parts before and after @ combined */
/* posix behavior that used to be performed by getName */
{ "mr.utf8", null, "mr" },
{ "de-tv.koi8r", null, "de_TV" },
{ "x-piglatin_ML.MBE", null, "x-piglatin_ML" },
{ "i-cherokee_US.utf7", null, "i-cherokee_US" },
{ "x-filfli_MT_FILFLA.gb-18030", null, "x-filfli_MT_FILFLA" },
{ "no-no-ny.utf8@B", null, "no_NO_NY_B" /* not: "nn_NO" [alan ICU3.0] */ }, /* @ ignored unless variant is empty */
// fleshing out canonicalization
// trim space and sort keywords, ';' is separator so not present at end in canonical form
{ "en_Hant_IL_VALLEY_GIRL@ currency = EUR; calendar = Japanese ;", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" },
// already-canonical ids are not changed
{ "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" },
// PRE_EURO and EURO conversions don't affect other keywords
{ "es_ES_PREEURO@CALendar=Japanese", "es_ES@calendar=Japanese;currency=ESP" },
{ "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES@currency=EUR;shout=zipeedeedoodah" },
// currency keyword overrides PRE_EURO and EURO currency
{ "es_ES_PREEURO@currency=EUR", "es_ES@currency=EUR" },
{ "es_ES_EURO@currency=ESP", "es_ES@currency=ESP" },
/* fleshing out canonicalization */
/* sort keywords, ';' is separator so not present at end in canonical form */
{ "en_Hant_IL_VALLEY_GIRL@currency=EUR;calendar=Japanese;", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" },
/* already-canonical ids are not changed */
{ "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR", "en_Hant_IL_VALLEY_GIRL@calendar=Japanese;currency=EUR" },
/* PRE_EURO and EURO conversions don't affect other keywords */
/* not in spec
{ "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES@calendar=Japanese;currency=ESP" },
{ "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah", "es_ES@currency=EUR;shout=zipeedeedoodah" },
*/
/* currency keyword overrides PRE_EURO and EURO currency */
/* not in spec
{ "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES@currency=EUR" },
{ "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES@currency=ESP" },
*/
/* norwegian is just too weird, if we handle things in their full generality */
/* this is a negative test to show that we DO NOT handle 'lang=no,var=NY' specially. */
{ "no-Hant-GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$" /* not: "nn_Hant_GB@currency=$$$" [alan ICU3.0] */ },
/* test cases reflecting internal resource bundle usage */
/* root is just a language */
{ "root@kw=foo", "root@kw=foo", "root@kw=foo" },
/* level 2 canonicalization should not touch basename when there are keywords and it is null */
{ "@calendar=gregorian", "@calendar=gregorian", "@calendar=gregorian" },
};
for(int i = 0; i< testCases.length;i++){
String canonical = ULocale.canonicalize(testCases[i][0]);
if(!canonical.equals(testCases[i][1])){
errln("ULocale.canonicalize did not return the expected ID for: "+ testCases[i][0]+
" Expected: "+ testCases[i][1]+
" Got: "+ canonical);
}
String[] testCase = testCases[i];
String source = testCase[0];
String level1Expected = testCase[1];
String level2Expected = testCase[2];
if (level1Expected != null) { // null means we have no expectations for how this case is handled
String level1 = ULocale.getName(source);
if (!level1.equals(level1Expected)) {
errln("ULocale.getName error for: '" + source +
"' expected: '" + level1Expected + "' but got: '" + level1 + "'");
} else {
logln("Ulocale.getName for: '" + source + "' returned: '" + level1 + "'");
}
} else {
logln("ULocale.getName skipped: '" + source + "'");
}
if (level2Expected != null) {
String level2 = ULocale.canonicalize(source);
if(!level2.equals(level2Expected)){
errln("ULocale.getName error for: '" + source +
"' expected: '" + level2Expected + "' but got: '" + level2 + "'");
} else {
logln("Ulocale.canonicalize for: '" + source + "' returned: '" + level2 + "'");
}
} else {
logln("ULocale.canonicalize skipped: '" + source + "'");
}
}
}