public void TestGetKeywordValues() { String[][] PREFERRED = { new string[] { "und", "standard", "eor", "search" }, new string[] { "en_US", "standard", "eor", "search" }, new string[] { "en_029", "standard", "eor", "search" }, new string[] { "de_DE", "standard", "phonebook", "search", "eor"}, new string[] { "de_Latn_DE", "standard", "phonebook", "search", "eor"}, new string[] { "zh", "pinyin", "stroke", "eor", "search", "standard"}, new string[] { "zh_Hans", "pinyin", "stroke", "eor", "search", "standard"}, new string[] { "zh_CN", "pinyin", "stroke", "eor", "search", "standard"}, new string[] { "zh_Hant", "stroke", "pinyin", "eor", "search", "standard"}, new string[] { "zh_TW", "stroke", "pinyin", "eor", "search", "standard"}, new string[] { "zh__PINYIN", "pinyin", "stroke", "eor", "search", "standard"}, new string[] { "es_ES", "standard", "search", "traditional", "eor"}, new string[] { "es__TRADITIONAL", "traditional", "search", "standard", "eor"}, new string[] { "und@collation=phonebook", "standard", "eor", "search" }, new string[] { "de_DE@collation=big5han", "standard", "phonebook", "search", "eor"}, new string[] { "zzz@collation=xxx", "standard", "eor", "search" }, }; for (int i = 0; i < PREFERRED.Length; i++) { String locale = PREFERRED[i][0]; UCultureInfo loc = new UCultureInfo(locale); String[] expected = PREFERRED[i]; String[] pref = Collator.GetKeywordValuesForLocale("collation", loc, true); for (int j = 1; j < expected.Length; ++j) { if (!arrayContains(pref, expected[j])) { Errln("Keyword value " + expected[j] + " missing for locale: " + locale); } } // Collator.getKeywordValues return the same contents for both commonlyUsed // true and false. String[] all = Collator.GetKeywordValuesForLocale("collation", loc, false); bool matchAll = false; if (pref.Length == all.Length) { matchAll = true; for (int j = 0; j < pref.Length; j++) { bool foundMatch = false; for (int k = 0; k < all.Length; k++) { if (pref[j].Equals(all[k])) { foundMatch = true; break; } } if (!foundMatch) { matchAll = false; break; } } } if (!matchAll) { Errln(string.Format(StringFormatter.CurrentCulture, "FAIL: All values for locale {0} got:{1} expected:{2}", loc, all, pref)); } } }