2 *******************************************************************************
\r
3 * Copyright (C) 2006, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
8 package com.ibm.icu.tests;
\r
10 import java.util.Iterator;
\r
11 import java.util.Locale;
\r
13 import com.ibm.icu.util.ULocale;
\r
15 public class ULocaleTest extends ICUTestCase {
\r
16 private String sampleName;
\r
17 private String longULocaleName;
\r
18 private String longULocaleBasename;
\r
19 private String nonNormalizedName;
\r
20 private ULocale longULocale;
\r
21 private Locale sampleLocale;
\r
26 protected void setUp() throws Exception {
\r
29 sampleName = "ll_CC_VVVV";
\r
30 longULocaleName = "ll_Ssss_CC_VVVV@collation=phonebook;key=value";
\r
31 longULocaleBasename = longULocaleName.substring(0, longULocaleName.indexOf('@'));
\r
32 nonNormalizedName = "LL_ssss_cc_VVVV@ Key = value ; Collation = phonebook ; ";
\r
33 longULocale = new ULocale(longULocaleName);
\r
34 sampleLocale = new ULocale(sampleName).toLocale();
\r
38 * Test method for 'com.ibm.icu.x.util.ULocale.hashCode()'
\r
40 public void testHashCode() {
\r
41 ULocale obj = ULocale.GERMANY;
\r
42 ULocale eq = new ULocale("de_DE");
\r
43 ULocale neq = new ULocale("de_DE_FRENCH");
\r
45 ICUTestCase.testEHCS(obj, eq, neq);
\r
49 * Test method for 'com.ibm.icu.x.util.ULocale.forLocale(Locale)'
\r
51 public void testForLocale() {
\r
52 assertEquals(ULocale.GERMANY, ULocale.forLocale(Locale.GERMANY));
\r
56 * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String)'
\r
58 public void testULocaleString() {
\r
59 assertEquals(ULocale.GERMAN, new ULocale("de"));
\r
63 * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String)'
\r
65 public void testULocaleStringString() {
\r
66 assertEquals(ULocale.GERMANY, new ULocale("de", "DE"));
\r
70 * Test method for 'com.ibm.icu.x.util.ULocale.ULocale(String, String, String)'
\r
72 public void testULocaleStringStringString() {
\r
73 assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
\r
77 * Test method for 'com.ibm.icu.x.util.ULocale.createCanonical(String)'
\r
79 public void testCreateCanonical() {
\r
80 ULocale result = ULocale.createCanonical("de__PHONEBOOK");
\r
81 assertEquals(new ULocale("de@collation=phonebook"), result);
\r
85 * Test method for 'com.ibm.icu.x.util.ULocale.toLocale()'
\r
87 public void testToLocale() {
\r
88 assertEquals(sampleLocale, new ULocale("ll", "cc", "VVVV").toLocale());
\r
92 * Test method for 'com.ibm.icu.x.util.ULocale.getDefault()'
\r
94 public void testGetDefault() {
\r
95 assertEquals(Locale.getDefault(), ULocale.getDefault().toLocale());
\r
99 * Test method for 'com.ibm.icu.x.util.ULocale.setDefault(ULocale)'
\r
101 public void testSetDefault() {
\r
102 Locale oldLocale = Locale.getDefault();
\r
103 ULocale oldULocale = ULocale.getDefault();
\r
105 ULocale.setDefault(longULocale);
\r
106 ICUTestCase.assertNotEqual(Locale.getDefault(), oldLocale);
\r
107 ICUTestCase.assertNotEqual(ULocale.getDefault(), oldULocale);
\r
108 assertEquals(longULocale, ULocale.getDefault());
\r
109 assertEquals(sampleLocale, Locale.getDefault());
\r
112 ULocale.setDefault(oldULocale);
\r
113 Locale.setDefault(oldLocale); // in case of some error
\r
118 * Test method for 'com.ibm.icu.x.util.ULocale.clone()'
\r
120 public void testClone() {
\r
121 // see testHashcode
\r
125 * Test method for 'com.ibm.icu.x.util.ULocale.equals(Object)'
\r
127 public void testEqualsObject() {
\r
128 // see testHashcode
\r
132 * Test method for 'com.ibm.icu.x.util.ULocale.getAvailableLocales()'
\r
134 public void testGetAvailableLocales() {
\r
135 ULocale[] ulocales = ULocale.getAvailableLocales();
\r
136 if (ICUTestCase.testingWrapper) {
\r
137 Locale[] locales = Locale.getAvailableLocales();
\r
138 for (int i = 0; i < ulocales.length; ++i) {
\r
139 assertEquals(ulocales[i].toLocale(), locales[i]);
\r
142 // else nothing to test except that the function returned.
\r
146 * Test method for 'com.ibm.icu.x.util.ULocale.getISOCountries()'
\r
148 public void testGetISOCountries() {
\r
149 String[] ucountries = ULocale.getISOCountries();
\r
150 assertNotNull(ucountries);
\r
151 if (ICUTestCase.testingWrapper) {
\r
152 // keep our own data for now
\r
153 // our data doesn't match java's so this test would fail
\r
154 // TODO: enable if we decide to use java's data
\r
155 // String[] countries = Locale.getISOCountries();
\r
156 // TestBoilerplate.assertArraysEqual(ucountries, countries);
\r
158 // else nothing to test except that the function returned.
\r
162 * Test method for 'com.ibm.icu.x.util.ULocale.getISOLanguages()'
\r
164 public void testGetISOLanguages() {
\r
165 String[] ulanguages = ULocale.getISOLanguages();
\r
166 assertNotNull(ulanguages);
\r
167 if (ICUTestCase.testingWrapper) {
\r
168 // keep our own data for now
\r
169 // our data doesn't match java's so this test would fail
\r
170 // TODO: enable if we decide to use java's data
\r
171 // String[] languages = Locale.getISOLanguages();
\r
172 // TestBoilerplate.assertArraysEqual(ulanguages, languages);
\r
174 // else nothing to test except that the function returned.
\r
178 * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage()'
\r
180 public void testGetLanguage() {
\r
181 assertEquals("ll", longULocale.getLanguage());
\r
182 assertEquals("ll", longULocale.toLocale().getLanguage());
\r
186 * Test method for 'com.ibm.icu.x.util.ULocale.getLanguage(String)'
\r
188 public void testGetLanguageString() {
\r
189 assertEquals("ll", ULocale.getLanguage(longULocale.getName()));
\r
193 * Test method for 'com.ibm.icu.x.util.ULocale.getScript()'
\r
195 public void testGetScript() {
\r
196 assertEquals("Ssss", longULocale.getScript());
\r
200 * Test method for 'com.ibm.icu.x.util.ULocale.getScript(String)'
\r
202 public void testGetScriptString() {
\r
203 assertEquals("Ssss", ULocale.getScript(longULocale.getName()));
\r
207 * Test method for 'com.ibm.icu.x.util.ULocale.getCountry()'
\r
209 public void testGetCountry() {
\r
210 assertEquals("CC", longULocale.getCountry());
\r
211 assertEquals("CC", longULocale.toLocale().getCountry());
\r
215 * Test method for 'com.ibm.icu.x.util.ULocale.getCountry(String)'
\r
217 public void testGetCountryString() {
\r
218 assertEquals("CC", ULocale.getCountry(longULocale.getName()));
\r
222 * Test method for 'com.ibm.icu.x.util.ULocale.getVariant()'
\r
224 public void testGetVariant() {
\r
225 assertEquals("VVVV", longULocale.getVariant());
\r
226 assertEquals("VVVV", longULocale.toLocale().getVariant());
\r
230 * Test method for 'com.ibm.icu.x.util.ULocale.getVariant(String)'
\r
232 public void testGetVariantString() {
\r
233 assertEquals("VVVV", ULocale.getVariant(longULocale.getName()));
\r
237 * Test method for 'com.ibm.icu.x.util.ULocale.getFallback(String)'
\r
239 public void testGetFallbackString() {
\r
240 assertEquals(ULocale.GERMAN, ULocale.getFallback(ULocale.GERMANY.getName()));
\r
244 * Test method for 'com.ibm.icu.x.util.ULocale.getFallback()'
\r
246 public void testGetFallback() {
\r
247 assertEquals(ULocale.GERMAN, ULocale.GERMANY.getFallback());
\r
251 * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName()'
\r
253 public void testGetBaseName() {
\r
254 assertEquals(longULocaleBasename, longULocale.getBaseName());
\r
258 * Test method for 'com.ibm.icu.x.util.ULocale.getBaseName(String)'
\r
260 public void testGetBaseNameString() {
\r
261 assertEquals(longULocaleBasename, longULocale.getBaseName());
\r
265 * Test method for 'com.ibm.icu.x.util.ULocale.getName()'
\r
267 public void testGetName() {
\r
268 assertEquals(longULocaleName, longULocale.getName());
\r
272 * Test method for 'com.ibm.icu.x.util.ULocale.getName(String)'
\r
274 public void testGetNameString() {
\r
275 assertEquals(longULocaleName, ULocale.getName(nonNormalizedName));
\r
279 * Test method for 'com.ibm.icu.x.util.ULocale.toString()'
\r
281 public void testToString() {
\r
282 assertEquals(longULocaleName, longULocale.toString());
\r
286 * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords()'
\r
288 public void testGetKeywords() {
\r
289 Iterator iter = longULocale.getKeywords();
\r
290 assertEquals(iter.next(), "collation");
\r
291 assertEquals(iter.next(), "key");
\r
292 assertFalse(iter.hasNext());
\r
296 * Test method for 'com.ibm.icu.x.util.ULocale.getKeywords(String)'
\r
298 public void testGetKeywordsString() {
\r
299 Iterator iter = ULocale.getKeywords(nonNormalizedName);
\r
300 assertEquals(iter.next(), "collation");
\r
301 assertEquals(iter.next(), "key");
\r
302 assertFalse(iter.hasNext());
\r
306 * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String)'
\r
308 public void testGetKeywordValueString() {
\r
309 assertEquals("value", longULocale.getKeywordValue("key"));
\r
310 assertEquals("phonebook", longULocale.getKeywordValue("collation"));
\r
311 assertNull(longULocale.getKeywordValue("zzyzx"));
\r
315 * Test method for 'com.ibm.icu.x.util.ULocale.getKeywordValue(String, String)'
\r
317 public void testGetKeywordValueStringString() {
\r
318 assertEquals("value", ULocale.getKeywordValue(longULocaleName, "key"));
\r
319 assertEquals("phonebook", ULocale.getKeywordValue(longULocaleName, "collation"));
\r
320 assertNull(ULocale.getKeywordValue(longULocaleName, "zzyzx"));
\r
325 * Test method for 'com.ibm.icu.x.util.ULocale.canonicalize(String)'
\r
327 public void testCanonicalize() {
\r
328 assertEquals("de@collation=phonebook", ULocale.canonicalize("de__PHONEBOOK"));
\r
332 * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String)'
\r
334 public void testSetKeywordValueStringString() {
\r
335 ULocale munged = longULocale.setKeywordValue("key", "C#");
\r
336 assertEquals("C#", munged.getKeywordValue("key"));
\r
337 munged = munged.setKeywordValue("zzyzx", "grue");
\r
338 assertEquals("grue", munged.getKeywordValue("zzyzx"));
\r
342 * Test method for 'com.ibm.icu.x.util.ULocale.setKeywordValue(String, String, String)'
\r
344 public void testSetKeywordValueStringStringString() {
\r
345 String munged = ULocale.setKeywordValue(longULocaleName, "key", "C#");
\r
346 assertEquals("C#", ULocale.getKeywordValue(munged, "key"));
\r
347 munged = ULocale.setKeywordValue(munged, "zzyzx", "grue");
\r
348 assertEquals("grue", ULocale.getKeywordValue(munged, "zzyzx"));
\r
352 * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language()'
\r
354 public void testGetISO3Language() {
\r
355 String il = ULocale.GERMANY.getISO3Language();
\r
356 String jl = Locale.GERMANY.getISO3Language();
\r
357 assertEquals(il, jl);
\r
361 * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Language(String)'
\r
363 public void testGetISO3LanguageString() {
\r
364 String il = ULocale.getISO3Language(ULocale.GERMANY.getName());
\r
365 String jl = Locale.GERMANY.getISO3Language();
\r
366 assertEquals(il, jl);
\r
370 * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country()'
\r
372 public void testGetISO3Country() {
\r
373 String ic = ULocale.GERMANY.getISO3Country();
\r
374 String jc = Locale.GERMANY.getISO3Country();
\r
375 assertEquals(ic, jc);
\r
379 * Test method for 'com.ibm.icu.x.util.ULocale.getISO3Country(String)'
\r
381 public void testGetISO3CountryString() {
\r
382 String ic = ULocale.getISO3Country(ULocale.GERMANY.getName());
\r
383 String jc = Locale.GERMANY.getISO3Country();
\r
384 assertEquals(ic, jc);
\r
388 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage()'
\r
390 public void testGetDisplayLanguage() {
\r
391 String idl = ULocale.GERMANY.getDisplayLanguage();
\r
392 String jdl = Locale.GERMANY.getDisplayLanguage();
\r
393 assertEquals(idl, jdl);
\r
397 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(ULocale)'
\r
399 public void testGetDisplayLanguageULocale() {
\r
400 String idl = ULocale.GERMANY.getDisplayLanguage(ULocale.GERMANY);
\r
401 String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
\r
402 assertEquals(idl, jdl);
\r
406 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, String)'
\r
408 public void testGetDisplayLanguageStringString() {
\r
409 String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), "de_DE");
\r
410 String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
\r
411 assertEquals(idl, jdl);
\r
415 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayLanguage(String, ULocale)'
\r
417 public void testGetDisplayLanguageStringULocale() {
\r
418 String idl = ULocale.getDisplayLanguage(ULocale.GERMANY.getName(), ULocale.GERMANY);
\r
419 String jdl = Locale.GERMANY.getDisplayLanguage(Locale.GERMANY);
\r
420 assertEquals(idl, jdl);
\r
424 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript()'
\r
426 public void testGetDisplayScript() {
\r
427 String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript();
\r
428 if (ICUTestCase.testingWrapper) {
\r
429 assertEquals("Hant", is);
\r
431 assertEquals("Traditional Chinese", is);
\r
436 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(ULocale)'
\r
438 public void testGetDisplayScriptULocale() {
\r
439 String is = ULocale.TRADITIONAL_CHINESE.getDisplayScript(ULocale.GERMANY);
\r
440 if (ICUTestCase.testingWrapper) {
\r
441 assertEquals("Hant", is);
\r
443 // TODO: look up expected value
\r
444 assertEquals("Hant", is);
\r
449 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, String)'
\r
451 public void testGetDisplayScriptStringString() {
\r
452 String is = ULocale.getDisplayScript("zh_Hant", "de_DE");
\r
453 if (ICUTestCase.testingWrapper) {
\r
454 assertEquals("Hant", is);
\r
456 // TODO: look up expected value
\r
457 assertEquals("Hant", is);
\r
462 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayScript(String, ULocale)'
\r
464 public void testGetDisplayScriptStringULocale() {
\r
465 String is = ULocale.getDisplayScript("zh_Hant", ULocale.GERMANY);
\r
466 if (ICUTestCase.testingWrapper) {
\r
467 assertEquals("Hant", is);
\r
469 // TODO: look up expected value
\r
470 assertEquals("Hant", is);
\r
475 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry()'
\r
477 public void testGetDisplayCountry() {
\r
478 String idc = ULocale.GERMANY.getDisplayCountry();
\r
479 String jdc = Locale.GERMANY.getDisplayCountry();
\r
480 assertEquals(idc, jdc);
\r
484 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(ULocale)'
\r
486 public void testGetDisplayCountryULocale() {
\r
487 String idc = ULocale.GERMANY.getDisplayCountry(ULocale.GERMANY);
\r
488 String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
\r
489 assertEquals(idc, jdc);
\r
493 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, String)'
\r
495 public void testGetDisplayCountryStringString() {
\r
496 String idc = ULocale.getDisplayCountry("de_DE", "de_DE");
\r
497 String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
\r
498 assertEquals(idc, jdc);
\r
502 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayCountry(String, ULocale)'
\r
504 public void testGetDisplayCountryStringULocale() {
\r
505 String idc = ULocale.getDisplayCountry("de_DE", ULocale.GERMANY);
\r
506 String jdc = Locale.GERMANY.getDisplayCountry(Locale.GERMANY);
\r
507 assertEquals(idc, jdc);
\r
511 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant()'
\r
513 public void testGetDisplayVariant() {
\r
514 String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant();
\r
515 String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant();
\r
516 assertEquals(jdv, idv);
\r
520 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(ULocale)'
\r
522 public void testGetDisplayVariantULocale() {
\r
523 String idv = new ULocale("de_DE_PHONEBOOK").getDisplayVariant(ULocale.GERMANY);
\r
524 String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
\r
525 assertEquals(jdv, idv);
\r
529 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, String)'
\r
531 public void testGetDisplayVariantStringString() {
\r
532 String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", "de_DE");
\r
533 String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
\r
534 assertEquals(jdv, idv);
\r
538 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayVariant(String, ULocale)'
\r
540 public void testGetDisplayVariantStringULocale() {
\r
541 String idv = ULocale.getDisplayVariant("de_DE_PHONEBOOK", ULocale.GERMANY);
\r
542 String jdv = new Locale("de", "DE", "PHONEBOOK").getDisplayVariant(Locale.GERMANY);
\r
543 assertEquals(jdv, idv);
\r
547 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String)'
\r
549 public void testGetDisplayKeywordString() {
\r
550 String idk = ULocale.getDisplayKeyword("collation");
\r
551 assertEquals("collation", idk);
\r
555 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, String)'
\r
557 public void testGetDisplayKeywordStringString() {
\r
558 String idk = ULocale.getDisplayKeyword("collation", "de_DE");
\r
559 if (ICUTestCase.testingWrapper) {
\r
560 assertEquals("collation", idk);
\r
562 // TODO: find real value
\r
563 assertEquals("collation", idk);
\r
568 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeyword(String, ULocale)'
\r
570 public void testGetDisplayKeywordStringULocale() {
\r
571 String idk = ULocale.getDisplayKeyword("collation", ULocale.GERMANY);
\r
572 if (ICUTestCase.testingWrapper) {
\r
573 assertEquals("collation", idk);
\r
575 // TODO: find real value
\r
576 assertEquals("collation", idk);
\r
581 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String)'
\r
583 public void testGetDisplayKeywordValueString() {
\r
584 ULocale ul = new ULocale("de_DE@collation=phonebook");
\r
585 String idk = ul.getDisplayKeywordValue("collation");
\r
586 if (ICUTestCase.testingWrapper) {
\r
587 assertEquals("phonebook", idk);
\r
589 // TODO: find real value
\r
590 assertEquals("phonebook", idk);
\r
595 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, ULocale)'
\r
597 public void testGetDisplayKeywordValueStringULocale() {
\r
598 ULocale ul = new ULocale("de_DE@collation=phonebook");
\r
599 String idk = ul.getDisplayKeywordValue("collation", ULocale.GERMANY);
\r
600 if (ICUTestCase.testingWrapper) {
\r
601 assertEquals("phonebook", idk);
\r
603 // TODO: find real value
\r
604 assertEquals("phonebook", idk);
\r
609 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, String)'
\r
611 public void testGetDisplayKeywordValueStringStringString() {
\r
612 String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", "de_DE");
\r
613 if (ICUTestCase.testingWrapper) {
\r
614 assertEquals("phonebook", idk);
\r
616 // TODO: find real value
\r
617 assertEquals("phonebook", idk);
\r
622 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayKeywordValue(String, String, ULocale)'
\r
624 public void testGetDisplayKeywordValueStringStringULocale() {
\r
625 String idk = ULocale.getDisplayKeywordValue("de_DE@collation=phonebook", "collation", ULocale.GERMANY);
\r
626 if (ICUTestCase.testingWrapper) {
\r
627 assertEquals("phonebook", idk);
\r
629 // TODO: find real value
\r
630 assertEquals("phonebook", idk);
\r
635 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName()'
\r
637 public void testGetDisplayName() {
\r
638 String idn = ULocale.GERMANY.getDisplayName();
\r
639 String jdn = Locale.GERMANY.getDisplayName();
\r
640 assertEquals(idn, jdn);
\r
644 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(ULocale)'
\r
646 public void testGetDisplayNameULocale() {
\r
647 String idn = ULocale.GERMANY.getDisplayName(ULocale.GERMANY);
\r
648 String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
\r
649 assertEquals(idn, jdn);
\r
653 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, String)'
\r
655 public void testGetDisplayNameStringString() {
\r
656 String idn = ULocale.getDisplayName("de_DE", "de_DE");
\r
657 String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
\r
658 assertEquals(idn, jdn);
\r
662 * Test method for 'com.ibm.icu.x.util.ULocale.getDisplayName(String, ULocale)'
\r
664 public void testGetDisplayNameStringULocale() {
\r
665 String idn = ULocale.getDisplayName("de_DE", ULocale.GERMANY);
\r
666 String jdn = Locale.GERMANY.getDisplayName(Locale.GERMANY);
\r
667 assertEquals(idn, jdn);
\r
671 * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, ULocale[], boolean[])'
\r
673 public void testAcceptLanguageStringULocaleArrayBooleanArray() {
\r
674 boolean[] fallback = new boolean[1];
\r
675 ULocale[] locales = {
\r
676 new ULocale("en_CA"),
\r
677 new ULocale("es_US"),
\r
679 ULocale result = ULocale.acceptLanguage("en-US, en-GB, en-CA, es-US", locales, fallback);
\r
680 assertEquals(new ULocale("en_CA"), result);
\r
681 assertFalse(fallback[0]);
\r
682 result = ULocale.acceptLanguage("en-US, en-GB, es-US-NEWMEXICO", locales, fallback);
\r
683 assertEquals(new ULocale("es_US"), result);
\r
684 assertTrue(fallback[0]);
\r
688 * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], ULocale[], boolean[])'
\r
690 public void testAcceptLanguageULocaleArrayULocaleArrayBooleanArray() {
\r
691 boolean[] fallback = new boolean[1];
\r
692 ULocale[] locales = {
\r
693 new ULocale("en_CA"),
\r
694 new ULocale("es_US"),
\r
696 ULocale[] accept_locales = {
\r
697 new ULocale("en_US"),
\r
698 new ULocale("en_GB"),
\r
699 new ULocale("en_CA"),
\r
700 new ULocale("es_US"),
\r
702 ULocale[] accept_locales2 = {
\r
703 new ULocale("en_US"),
\r
704 new ULocale("en_GB"),
\r
705 new ULocale("es_US_NEWMEXICO"),
\r
707 ULocale result = ULocale.acceptLanguage(accept_locales, locales, fallback);
\r
708 assertEquals(new ULocale("en_CA"), result);
\r
709 assertFalse(fallback[0]);
\r
710 result = ULocale.acceptLanguage(accept_locales2, locales, fallback);
\r
711 assertEquals(new ULocale("es_US"), result);
\r
712 assertTrue(fallback[0]);
\r
716 * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(String, boolean[])'
\r
718 public void testAcceptLanguageStringBooleanArray() {
\r
719 boolean[] fallback = new boolean[1];
\r
720 ULocale result = ULocale.acceptLanguage("en-CA, en-GB, es-US", fallback);
\r
721 assertEquals(new ULocale("en_CA"), result);
\r
722 assertFalse(fallback[0]);
\r
723 result = ULocale.acceptLanguage("es-US-NEWMEXICO", fallback);
\r
724 assertNotNull(result); // actual result depends on jdk
\r
725 assertTrue(fallback[0]);
\r
729 * Test method for 'com.ibm.icu.x.util.ULocale.acceptLanguage(ULocale[], boolean[])'
\r
731 public void testAcceptLanguageULocaleArrayBooleanArray() {
\r
732 boolean[] fallback = new boolean[1];
\r
733 ULocale[] accept_locales = {
\r
734 new ULocale("en_CA"),
\r
735 new ULocale("en_GB"),
\r
736 new ULocale("es_US"),
\r
738 ULocale[] accept_locales2 = {
\r
739 new ULocale("es_US_NEWMEXICO"),
\r
741 ULocale result = ULocale.acceptLanguage(accept_locales, fallback);
\r
742 assertEquals(new ULocale("en_CA"), result);
\r
743 assertFalse(fallback[0]);
\r
744 result = ULocale.acceptLanguage(accept_locales2, fallback);
\r
745 assertNotNull(result); // actual result depends on jdk
\r
746 assertTrue(fallback[0]);
\r