]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-52_1/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java
Clean up imports.
[Dictionary.git] / jars / icu4j-52_1 / main / tests / core / src / com / ibm / icu / dev / test / util / ULocaleTest.java
1 /*
2  **********************************************************************
3  * Copyright (c) 2004-2013, International Business Machines
4  * Corporation and others.  All Rights Reserved.
5  **********************************************************************
6  * Author: Alan Liu
7  * Created: January 14 2004
8  * Since: ICU 2.8
9  **********************************************************************
10  */
11 package com.ibm.icu.dev.test.util;
12
13 import java.lang.reflect.InvocationTargetException;
14 import java.lang.reflect.Method;
15 import java.util.HashMap;
16 import java.util.HashSet;
17 import java.util.Iterator;
18 import java.util.Locale;
19 import java.util.Map;
20 import java.util.Set;
21 import java.util.TreeMap;
22
23 import com.ibm.icu.dev.test.TestFmwk;
24 import com.ibm.icu.lang.UCharacter;
25 import com.ibm.icu.text.DateFormat;
26 import com.ibm.icu.text.DecimalFormat;
27 import com.ibm.icu.text.DisplayContext;
28 import com.ibm.icu.text.LocaleDisplayNames;
29 import com.ibm.icu.text.LocaleDisplayNames.DialectHandling;
30 import com.ibm.icu.text.NumberFormat;
31 import com.ibm.icu.text.NumberFormat.SimpleNumberFormatFactory;
32 import com.ibm.icu.text.SimpleDateFormat;
33 import com.ibm.icu.util.Calendar;
34 import com.ibm.icu.util.IllformedLocaleException;
35 import com.ibm.icu.util.LocaleData;
36 import com.ibm.icu.util.ULocale;
37 import com.ibm.icu.util.ULocale.Builder;
38 import com.ibm.icu.util.ULocale.Category;
39 import com.ibm.icu.util.UResourceBundle;
40 import com.ibm.icu.util.VersionInfo;
41
42 public class ULocaleTest extends TestFmwk {
43
44     private static final boolean JAVA7_OR_LATER = (VersionInfo.javaVersion().compareTo(VersionInfo.getInstance(1, 7)) >= 0);
45
46     public static void main(String[] args) throws Exception {
47         new ULocaleTest().run(args);
48     }
49
50     public void TestCalendar() {
51         // TODO The CalendarFactory mechanism is not public,
52         // so we can't test it yet.  If it becomes public,
53         // enable this code.
54
55         // class CFactory implements CalendarFactory {
56         //     Locale loc;
57         //     Calendar proto;
58         //     public CFactory(Locale locale, Calendar prototype) {
59         //         loc = locale;
60         //         proto = prototype;
61         //     }
62         //     public Calendar create(TimeZone tz, Locale locale) {
63         //         // ignore tz -- not relevant to this test
64         //         return locale.equals(loc) ?
65         //             (Calendar) proto.clone() : null;
66         //     }
67         //     public String factoryName() {
68         //         return "CFactory";
69         //     }
70         // };
71
72         checkService("en_US_BROOKLYN", new ServiceFacade() {
73             public Object create(ULocale req) {
74                 return Calendar.getInstance(req);
75             }
76             // }, null, new Registrar() {
77             //     public Object register(ULocale loc, Object prototype) {
78             //         CFactory f = new CFactory(loc, (Calendar) prototype);
79             //         return Calendar.register(f, loc);
80             //     }
81             //     public boolean unregister(Object key) {
82             //         return Calendar.unregister(key);
83             //     }
84         });
85     }
86
87     // Currency getLocale API is obsolete in 3.2.  Since it now returns ULocale.ROOT,
88     // and this is not equal to the requested locale zh_TW_TAIPEI, the
89     // checkService call would always fail.  So we now omit the test.
90     /*
91     public void TestCurrency() {
92         checkService("zh_TW_TAIPEI", new ServiceFacade() {
93                 public Object create(ULocale req) {
94                     return Currency.getInstance(req);
95                 }
96             }, null, new Registrar() {
97                     public Object register(ULocale loc, Object prototype) {
98                         return Currency.registerInstance((Currency) prototype, loc);
99                     }
100                     public boolean unregister(Object key) {
101                         return Currency.unregister(key);
102                     }
103                 });
104     }
105      */
106
107     public void TestDateFormat() {
108         checkService("de_CH_ZURICH", new ServiceFacade() {
109             public Object create(ULocale req) {
110                 return DateFormat.getDateInstance(DateFormat.DEFAULT, req);
111             }
112         }, new Subobject() {
113             public Object get(Object parent) {
114                 return ((SimpleDateFormat) parent).getDateFormatSymbols();
115             }
116         }, null);
117     }
118
119     public void TestNumberFormat() {
120         class NFactory extends SimpleNumberFormatFactory {
121             NumberFormat proto;
122             ULocale locale;
123             public NFactory(ULocale loc, NumberFormat fmt) {
124                 super(loc);
125                 this.locale = loc;
126                 this.proto = fmt;
127             }
128             public NumberFormat createFormat(ULocale loc, int formatType) {
129                 return (NumberFormat) (locale.equals(loc) ?
130                         proto.clone() : null);
131             }
132         }
133
134         checkService("fr_FR_NICE", new ServiceFacade() {
135             public Object create(ULocale req) {
136                 return NumberFormat.getInstance(req);
137             }
138         }, new Subobject() {
139             public Object get(Object parent) {
140                 return ((DecimalFormat) parent).getDecimalFormatSymbols();
141             }
142         }, new Registrar() {
143             public Object register(ULocale loc, Object prototype) {
144                 NFactory f = new NFactory(loc, (NumberFormat) prototype);
145                 return NumberFormat.registerFactory(f);
146             }
147             public boolean unregister(Object key) {
148                 return NumberFormat.unregister(key);
149             }
150         });
151     }
152
153     public void TestSetULocaleKeywords() {
154         ULocale uloc = new ULocale("en_Latn_US");
155         uloc = uloc.setKeywordValue("Foo", "FooValue");
156         if (!"en_Latn_US@foo=FooValue".equals(uloc.getName())) {
157             errln("failed to add foo keyword, got: " + uloc.getName());
158         }
159         uloc = uloc.setKeywordValue("Bar", "BarValue");
160         if (!"en_Latn_US@bar=BarValue;foo=FooValue".equals(uloc.getName())) {
161             errln("failed to add bar keyword, got: " + uloc.getName());
162         }
163         uloc = uloc.setKeywordValue("BAR", "NewBarValue");
164         if (!"en_Latn_US@bar=NewBarValue;foo=FooValue".equals(uloc.getName())) {
165             errln("failed to change bar keyword, got: " + uloc.getName());
166         }
167         uloc = uloc.setKeywordValue("BaR", null);
168         if (!"en_Latn_US@foo=FooValue".equals(uloc.getName())) {
169             errln("failed to delete bar keyword, got: " + uloc.getName());
170         }
171         uloc = uloc.setKeywordValue(null, null);
172         if (!"en_Latn_US".equals(uloc.getName())) {
173             errln("failed to delete all keywords, got: " + uloc.getName());
174         }
175     }
176
177     /*
178      * ticket#5060
179      */
180     public void TestJavaLocaleCompatibility() {
181         Locale backupDefault = Locale.getDefault();
182         ULocale orgUlocDefault = ULocale.getDefault();
183
184         // Java Locale for ja_JP with Japanese calendar
185         Locale jaJPJP = new Locale("ja", "JP", "JP");
186         Locale jaJP = new Locale("ja", "JP");
187         // Java Locale for th_TH with Thai digits
188         Locale thTHTH = new Locale("th", "TH", "TH");
189
190         Calendar cal = Calendar.getInstance(jaJPJP);
191         String caltype = cal.getType();
192         if (!caltype.equals("japanese")) {
193             errln("FAIL: Invalid calendar type: " + caltype + " /expected: japanese");
194         }
195
196         cal = Calendar.getInstance(jaJP);
197         caltype = cal.getType();
198         if (!caltype.equals("gregorian")) {
199             errln("FAIL: Invalid calendar type: " + caltype + " /expected: gregorian");
200         }
201
202         // Default locale
203         Locale.setDefault(jaJPJP);
204         ULocale defUloc = ULocale.getDefault();
205         if (JAVA7_OR_LATER) {
206             if (!defUloc.toString().equals("ja_JP_JP@calendar=japanese")) {
207                 errln("FAIL: Invalid default ULocale: " + defUloc + " /expected: ja_JP_JP@calendar=japanese");
208             }
209         } else {
210             if (!defUloc.toString().equals("ja_JP@calendar=japanese")) {
211                 errln("FAIL: Invalid default ULocale: " + defUloc + " /expected: ja_JP@calendar=japanese");
212             }
213         }
214         // Check calendar type
215         cal = Calendar.getInstance();
216         caltype = cal.getType();
217         if (!caltype.equals("japanese")) {
218             errln("FAIL: Invalid calendar type: " + caltype + " /expected: japanese");
219         }
220         Locale.setDefault(backupDefault);
221
222         // Set default via ULocale
223         ULocale ujaJP_calJP = new ULocale("ja_JP@calendar=japanese");
224         ULocale.setDefault(ujaJP_calJP);
225         if (!JAVA7_OR_LATER && !Locale.getDefault().equals(jaJPJP)) {
226             errln("FAIL: ULocale#setDefault failed to set Java Locale ja_JP_JP /actual: " + Locale.getDefault());
227         }
228         // Ticket#6672 - missing keywords
229         defUloc = ULocale.getDefault();
230         if (!defUloc.equals(ujaJP_calJP)) {
231             errln("FAIL: ULocale#getDefault returned " + defUloc + " /expected: ja_JP@calendar=japanese");
232         }
233         // Set a incompatible base locale via Locale#setDefault
234         Locale.setDefault(Locale.US);
235         defUloc = ULocale.getDefault();
236         if (defUloc.equals(ujaJP_calJP)) {
237             errln("FAIL: ULocale#getDefault returned " + defUloc + " /expected: " + ULocale.forLocale(Locale.US));
238         }
239
240         Locale.setDefault(backupDefault);
241
242         // We also want to map ICU locale ja@calendar=japanese to Java ja_JP_JP
243         ULocale.setDefault(new ULocale("ja@calendar=japanese"));
244         if (!JAVA7_OR_LATER && !Locale.getDefault().equals(jaJPJP)) {
245             errln("FAIL: ULocale#setDefault failed to set Java Locale ja_JP_JP /actual: " + Locale.getDefault());
246         }
247         Locale.setDefault(backupDefault);
248
249         // Java no_NO_NY
250         Locale noNONY = new Locale("no", "NO", "NY");
251         Locale.setDefault(noNONY);
252         defUloc = ULocale.getDefault();
253         if (!defUloc.toString().equals("nn_NO")) {
254             errln("FAIL: Invalid default ULocale: " + defUloc + " /expected: nn_NO");
255         }
256         Locale.setDefault(backupDefault);
257
258         // Java th_TH_TH -> ICU th_TH@numbers=thai
259         ULocale.setDefault(new ULocale("th@numbers=thai"));
260         if (!JAVA7_OR_LATER && !Locale.getDefault().equals(thTHTH)) {
261             errln("FAIL: ULocale#setDefault failed to set Java Locale th_TH_TH /actual: " + Locale.getDefault());
262         }
263         Locale.setDefault(backupDefault);
264
265         // Set default via ULocale
266         ULocale.setDefault(new ULocale("nn_NO"));
267         if (!JAVA7_OR_LATER && !Locale.getDefault().equals(noNONY)) {
268             errln("FAIL: ULocale#setDefault failed to set Java Locale no_NO_NY /actual: " + Locale.getDefault());
269         }
270         Locale.setDefault(backupDefault);        
271
272         // We also want to map ICU locale nn to Java no_NO_NY
273         ULocale.setDefault(new ULocale("nn"));
274         if (!JAVA7_OR_LATER && !Locale.getDefault().equals(noNONY)) {
275             errln("FAIL: ULocale#setDefault failed to set Java Locale no_NO_NY /actual: " + Locale.getDefault());
276         }
277         Locale.setDefault(backupDefault);
278
279         // Make sure default ULocale is restored
280         if (!ULocale.getDefault().equals(orgUlocDefault)) {
281             errln("FAIL: Original default ULocale is not restored - " + ULocale.getDefault() + ", expected(orginal) - " + orgUlocDefault);
282         }
283     }
284
285     // ================= Infrastructure =================
286
287     /**
288      * Compare two locale IDs.  If they are equal, return 0.  If `string'
289      * starts with `prefix' plus an additional element, that is, string ==
290      * prefix + '_' + x, then return 1.  Otherwise return a value < 0.
291      */
292     static int loccmp(String string, String prefix) {
293         int slen = string.length(),
294                 plen = prefix.length();
295         /* 'root' is "less than" everything */
296         if (prefix.equals("root")) {
297             return string.equals("root") ? 0 : 1;
298         }
299         // ON JAVA (only -- not on C -- someone correct me if I'm wrong)
300         // consider "" to be an alternate name for "root".
301         if (plen == 0) {
302             return slen == 0 ? 0 : 1;
303         }
304         if (!string.startsWith(prefix)) return -1; /* mismatch */
305         if (slen == plen) return 0;
306         if (string.charAt(plen) == '_') return 1;
307         return -2; /* false match, e.g. "en_USX" cmp "en_US" */
308     }
309
310     /**
311      * Check the relationship between requested locales, and report problems.
312      * The caller specifies the expected relationships between requested
313      * and valid (expReqValid) and between valid and actual (expValidActual).
314      * Possible values are:
315      * "gt" strictly greater than, e.g., en_US > en
316      * "ge" greater or equal,      e.g., en >= en
317      * "eq" equal,                 e.g., en == en
318      */
319     void checklocs(String label,
320             String req,
321             Locale validLoc,
322             Locale actualLoc,
323             String expReqValid,
324             String expValidActual) {
325         String valid = validLoc.toString();
326         String actual = actualLoc.toString();
327         int reqValid = loccmp(req, valid);
328         int validActual = loccmp(valid, actual);
329         boolean reqOK = (expReqValid.equals("gt") && reqValid > 0) ||
330                 (expReqValid.equals("ge") && reqValid >= 0) ||
331                 (expReqValid.equals("eq") && reqValid == 0);
332         boolean valOK = (expValidActual.equals("gt") && validActual > 0) ||
333                 (expValidActual.equals("ge") && validActual >= 0) ||
334                 (expValidActual.equals("eq") && validActual == 0);
335         if (reqOK && valOK) {
336             logln("Ok: " + label + "; req=" + req + ", valid=" + valid +
337                     ", actual=" + actual);
338         } else {
339             errln("FAIL: " + label + "; req=" + req + ", valid=" + valid +
340                     ", actual=" + actual +
341                     (reqOK ? "" : "\n  req !" + expReqValid + " valid") +
342                     (valOK ? "" : "\n  val !" + expValidActual + " actual"));
343         }
344     }
345
346     /**
347      * Interface used by checkService defining a protocol to create an
348      * object, given a requested locale.
349      */
350     interface ServiceFacade {
351         Object create(ULocale requestedLocale);
352     }
353
354     /**
355      * Interface used by checkService defining a protocol to get a
356      * contained subobject, given its parent object.
357      */
358     interface Subobject {
359         Object get(Object parent);
360     }
361
362     /**
363      * Interface used by checkService defining a protocol to register
364      * and unregister a service object prototype.
365      */
366     interface Registrar {
367         Object register(ULocale loc, Object prototype);
368         boolean unregister(Object key);
369     }
370
371     /**
372      * Use reflection to call getLocale() on the given object to
373      * determine both the valid and the actual locale.  Verify these
374      * for correctness.
375      */
376     void checkObject(String requestedLocale, Object obj,
377             String expReqValid, String expValidActual) {
378         Class[] getLocaleParams = new Class[] { ULocale.Type.class };
379         try {
380             Class cls = obj.getClass();
381             Method getLocale = cls.getMethod("getLocale", getLocaleParams);
382             ULocale valid = (ULocale) getLocale.invoke(obj, new Object[] {
383                     ULocale.VALID_LOCALE });
384             ULocale actual = (ULocale) getLocale.invoke(obj, new Object[] {
385                     ULocale.ACTUAL_LOCALE });
386             checklocs(cls.getName(), requestedLocale,
387                     valid.toLocale(), actual.toLocale(),
388                     expReqValid, expValidActual);
389         }
390
391         // Make the following exceptions _specific_ -- do not
392         // catch(Exception), since that will catch the exception
393         // that errln throws.
394         catch(NoSuchMethodException e1) {
395             // no longer an error, Currency has no getLocale
396             // errln("FAIL: reflection failed: " + e1);
397         } catch(SecurityException e2) {
398             errln("FAIL: reflection failed: " + e2);
399         } catch(IllegalAccessException e3) {
400             errln("FAIL: reflection failed: " + e3);
401         } catch(IllegalArgumentException e4) {
402             errln("FAIL: reflection failed: " + e4);
403         } catch(InvocationTargetException e5) {
404             // no longer an error, Currency has no getLocale
405             // errln("FAIL: reflection failed: " + e5);
406         }
407     }
408
409     /**
410      * Verify the correct getLocale() behavior for the given service.
411      * @param requestedLocale the locale to request.  This MUST BE
412      * FAKE.  In other words, it should be something like
413      * en_US_FAKEVARIANT so this method can verify correct fallback
414      * behavior.
415      * @param svc a factory object that can create the object to be
416      * tested.  This isn't necessary here (one could just pass in the
417      * object) but is required for the overload of this method that
418      * takes a Registrar.
419      */
420     void checkService(String requestedLocale, ServiceFacade svc) {
421         checkService(requestedLocale, svc, null, null);
422     }
423
424     /**
425      * Verify the correct getLocale() behavior for the given service.
426      * @param requestedLocale the locale to request.  This MUST BE
427      * FAKE.  In other words, it should be something like
428      * en_US_FAKEVARIANT so this method can verify correct fallback
429      * behavior.
430      * @param svc a factory object that can create the object to be
431      * tested.
432      * @param sub an object that can be used to retrieve a subobject
433      * which should also be tested.  May be null.
434      * @param reg an object that supplies the registration and
435      * unregistration functionality to be tested.  May be null.
436      */
437     void checkService(String requestedLocale, ServiceFacade svc,
438             Subobject sub, Registrar reg) {
439         ULocale req = new ULocale(requestedLocale);
440         Object obj = svc.create(req);
441         checkObject(requestedLocale, obj, "gt", "ge");
442         if (sub != null) {
443             Object subobj = sub.get(obj);
444             checkObject(requestedLocale, subobj, "gt", "ge");
445         }
446         if (reg != null) {
447             logln("Info: Registering service");
448             Object key = reg.register(req, obj);
449             Object objReg = svc.create(req);
450             checkObject(requestedLocale, objReg, "eq", "eq");
451             if (sub != null) {
452                 Object subobj = sub.get(obj);
453                 // Assume subobjects don't come from services, so
454                 // their metadata should be structured normally.
455                 checkObject(requestedLocale, subobj, "gt", "ge");
456             }
457             logln("Info: Unregistering service");
458             if (!reg.unregister(key)) {
459                 errln("FAIL: unregister failed");
460             }
461             Object objUnreg = svc.create(req);
462             checkObject(requestedLocale, objUnreg, "gt", "ge");
463         }
464     }
465     private static final int LOCALE_SIZE = 9;
466     private static final String[][] rawData2 = new String[][]{
467         /* language code */
468         {   "en",   "fr",   "ca",   "el",   "no",   "zh",   "de",   "es",  "ja"    },
469         /* script code */
470         {   "",     "",     "",     "",     "",     "Hans", "", "", ""  },
471         /* country code */
472         {   "US",   "FR",   "ES",   "GR",   "NO",   "CN", "DE", "", "JP"    },
473         /* variant code */
474         {   "",     "",     "",     "",     "NY",   "", "", "", ""      },
475         /* full name */
476         {   "en_US",    "fr_FR",    "ca_ES",
477             "el_GR",    "no_NO_NY", "zh_Hans_CN",
478             "de_DE@collation=phonebook", "es@collation=traditional",  "ja_JP@calendar=japanese" },
479             /* ISO-3 language */
480             {   "eng",  "fra",  "cat",  "ell",  "nor",  "zho", "deu", "spa", "jpn"   },
481             /* ISO-3 country */
482             {   "USA",  "FRA",  "ESP",  "GRC",  "NOR",  "CHN", "DEU", "", "JPN"   },
483             /* LCID */
484             {   "409", "40c", "403", "408", "814",  "804", "407", "a", "411"     },
485
486             /* display language (English) */
487             {   "English",  "French",   "Catalan", "Greek",    "Norwegian", "Chinese", "German", "Spanish", "Japanese"    },
488             /* display script code (English) */
489             {   "",     "",     "",     "",     "",     "Simplified Han", "", "", ""       },
490             /* display country (English) */
491             {   "United States",    "France",   "Spain",  "Greece",   "Norway", "China", "Germany", "", "Japan"       },
492             /* display variant (English) */
493             {   "",     "",     "",     "",     "NY",  "", "", "", ""       },
494             /* display name (English) */
495             {   "English (United States)", "French (France)", "Catalan (Spain)",
496                 "Greek (Greece)", "Norwegian (Norway, NY)", "Chinese (Simplified Han, China)",
497                 "German (Germany, Collation=Phonebook Sort Order)", "Spanish (Collation=Traditional)", "Japanese (Japan, Calendar=Japanese Calendar)" },
498
499                 /* display language (French) */
500                 {   "anglais",  "fran\\u00E7ais",   "catalan", "grec",    "norv\\u00E9gien",    "chinois", "allemand", "espagnol", "japonais"     },
501                 /* display script code (French) */
502                 {   "",     "",     "",     "",     "",     "Hans", "", "", ""         },
503                 /* display country (French) */
504                 {   "\\u00C9tats-Unis",    "France",   "Espagne",  "Gr\\u00E8ce",   "Norv\\u00E8ge",    "Chine", "Allemagne", "", "Japon"       },
505                 /* display variant (French) */
506                 {   "",     "",     "",     "",     "NY",   "", "", "", ""       },
507                 /* display name (French) */
508                 {   "anglais (\\u00C9tats-Unis)", "fran\\u00E7ais (France)", "catalan (Espagne)",
509                     "grec (Gr\\u00E8ce)", "norv\\u00E9gien (Norv\\u00E8ge, NY)",  "chinois (Hans, Chine)",
510                     "allemand (Allemagne, Ordonnancement=Ordre de l'annuaire)", "espagnol (Ordonnancement=Ordre traditionnel)", "japonais (Japon, Calendrier=Calendrier japonais)" },
511
512                     /* display language (Catalan) */
513                     {   "angl\\u00E8s", "franc\\u00E8s", "catal\\u00E0", "grec",  "noruec", "xin\\u00E9s", "alemany", "espanyol", "japon\\u00E8s"    },
514                     /* display script code (Catalan) */
515                     {   "",     "",     "",     "",     "",     "Hans", "", "", ""         },
516                     /* display country (Catalan) */
517                     {   "Estats Units", "Fran\\u00E7a", "Espanya",  "Gr\\u00E8cia", "Noruega",  "Xina", "Alemanya", "", "Jap\\u00F3"    },
518                     /* display variant (Catalan) */
519                     {   "", "", "",                    "", "NY",    "", "", "", ""    },
520                     /* display name (Catalan) */
521                     {   "angl\\u00E8s (Estats Units)", "franc\\u00E8s (Fran\\u00E7a)", "catal\\u00E0 (Espanya)",
522                         "grec (Gr\\u00E8cia)", "noruec (Noruega, NY)", "xin\\u00E9s (Hans, Xina)",
523                         "alemany (Alemanya, COLLATION=PHONEBOOK)", "espanyol (COLLATION=TRADITIONAL)", "japon\\u00E8s (Jap\\u00F3, CALENDAR=JAPANESE)" },
524
525                         /* display language (Greek) */
526                         {
527                             "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac",
528                             "\\u0393\\u03b1\\u03bb\\u03bb\\u03b9\\u03ba\\u03ac",
529                             "\\u039a\\u03b1\\u03c4\\u03b1\\u03bb\\u03b1\\u03bd\\u03b9\\u03ba\\u03ac",
530                             "\\u0395\\u03bb\\u03bb\\u03b7\\u03bd\\u03b9\\u03ba\\u03ac",
531                             "\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03b9\\u03ba\\u03ac",
532                             "\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC",
533                             "\\u0393\\u03B5\\u03C1\\u03BC\\u03B1\\u03BD\\u03B9\\u03BA\\u03AC",
534                             "\\u0399\\u03C3\\u03C0\\u03B1\\u03BD\\u03B9\\u03BA\\u03AC",
535                             "\\u0399\\u03B1\\u03C0\\u03C9\\u03BD\\u03B9\\u03BA\\u03AC"
536                         },
537                         /* display script code (Greek) */
538                         {   "",     "",     "",     "",     "",     "Hans", "", "", ""         },
539                         /* display country (Greek) */
540                         {
541                             "\\u0397\\u03bd\\u03c9\\u03bc\\u03ad\\u03bd\\u03b5\\u03c2 \\u03a0\\u03bf\\u03bb\\u03b9\\u03c4\\u03b5\\u03af\\u03b5\\u03c2",
542                             "\\u0393\\u03b1\\u03bb\\u03bb\\u03af\\u03b1",
543                             "\\u0399\\u03c3\\u03c0\\u03b1\\u03bd\\u03af\\u03b1",
544                             "\\u0395\\u03bb\\u03bb\\u03ac\\u03b4\\u03b1",
545                             "\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03af\\u03b1",
546                             "\\u039A\\u03AF\\u03BD\\u03B1",
547                             "\\u0393\\u03B5\\u03C1\\u03BC\\u03B1\\u03BD\\u03AF\\u03B1",
548                             "",
549                             "\\u0399\\u03B1\\u03C0\\u03C9\\u03BD\\u03AF\\u03B1"
550                         },
551                         /* display variant (Greek) */
552                         {   "", "", "", "", "NY", "", "", "", ""    }, /* TODO: currently there is no translation for NY in Greek fix this test when we have it */
553                         /* display name (Greek) */
554                         {
555                             "\\u0391\\u03b3\\u03b3\\u03bb\\u03b9\\u03ba\\u03ac (\\u0397\\u03bd\\u03c9\\u03bc\\u03ad\\u03bd\\u03b5\\u03c2 \\u03a0\\u03bf\\u03bb\\u03b9\\u03c4\\u03b5\\u03af\\u03b5\\u03c2)",
556                             "\\u0393\\u03b1\\u03bb\\u03bb\\u03b9\\u03ba\\u03ac (\\u0393\\u03b1\\u03bb\\u03bb\\u03af\\u03b1)",
557                             "\\u039a\\u03b1\\u03c4\\u03b1\\u03bb\\u03b1\\u03bd\\u03b9\\u03ba\\u03ac (\\u0399\\u03c3\\u03c0\\u03b1\\u03bd\\u03af\\u03b1)",
558                             "\\u0395\\u03bb\\u03bb\\u03b7\\u03bd\\u03b9\\u03ba\\u03ac (\\u0395\\u03bb\\u03bb\\u03ac\\u03b4\\u03b1)",
559                             "\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03b9\\u03ba\\u03ac (\\u039d\\u03bf\\u03c1\\u03b2\\u03b7\\u03b3\\u03af\\u03b1, NY)",
560                             "\\u039A\\u03B9\\u03BD\\u03B5\\u03B6\\u03B9\\u03BA\\u03AC (Hans, \\u039A\\u03AF\\u03BD\\u03B1)",
561                             "\\u0393\\u03B5\\u03C1\\u03BC\\u03B1\\u03BD\\u03B9\\u03BA\\u03AC (\\u0393\\u03B5\\u03C1\\u03BC\\u03B1\\u03BD\\u03AF\\u03B1, COLLATION=PHONEBOOK)",
562                             "\\u0399\\u03C3\\u03C0\\u03B1\\u03BD\\u03B9\\u03BA\\u03AC (COLLATION=TRADITIONAL)",
563                             "\\u0399\\u03B1\\u03C0\\u03C9\\u03BD\\u03B9\\u03BA\\u03AC (\\u0399\\u03B1\\u03C0\\u03C9\\u03BD\\u03AF\\u03B1, CALENDAR=JAPANESE)"
564                         }
565     };
566     //    private static final int ENGLISH = 0;
567     //    private static final int FRENCH = 1;
568     //    private static final int CATALAN = 2;
569     //    private static final int GREEK = 3;
570     //    private static final int NORWEGIAN = 4;
571     private static final int LANG = 0;
572     private static final int SCRIPT = 1;
573     private static final int CTRY = 2;
574     private static final int VAR = 3;
575     private static final int NAME = 4;
576     //    private static final int LANG3 = 5;
577     //    private static final int CTRY3 = 6;
578     //    private static final int LCID = 7;
579     //    private static final int DLANG_EN = 8;
580     //    private static final int DSCRIPT_EN = 9;
581     //    private static final int DCTRY_EN = 10;
582     //    private static final int DVAR_EN = 11;
583     //    private static final int DNAME_EN = 12;
584     //    private static final int DLANG_FR = 13;
585     //    private static final int DSCRIPT_FR = 14;
586     //    private static final int DCTRY_FR = 15;
587     //    private static final int DVAR_FR = 16;
588     //    private static final int DNAME_FR = 17;
589     //    private static final int DLANG_CA = 18;
590     //    private static final int DSCRIPT_CA = 19;
591     //    private static final int DCTRY_CA = 20;
592     //    private static final int DVAR_CA = 21;
593     //    private static final int DNAME_CA = 22;
594     //    private static final int DLANG_EL = 23;
595     //    private static final int DSCRIPT_EL = 24;
596     //    private static final int DCTRY_EL = 25;
597     //    private static final int DVAR_EL = 26;
598     //    private static final int DNAME_EL = 27;
599
600     public void TestBasicGetters() {
601         int i;
602         logln("Testing Basic Getters\n");
603         for (i = 0; i < LOCALE_SIZE; i++) {
604             String testLocale=(rawData2[NAME][i]);
605             logln("Testing "+ testLocale+".....\n");
606
607             String lang =ULocale.getLanguage(testLocale);
608             if (0 !=lang.compareTo(rawData2[LANG][i]))    {
609                 errln("  Language code mismatch: "+lang+" versus "+  rawData2[LANG][i]);
610             }
611
612             String ctry=ULocale.getCountry(testLocale);
613             if (0 !=ctry.compareTo(rawData2[CTRY][i]))    {
614                 errln("  Country code mismatch: "+ctry+" versus "+  rawData2[CTRY][i]);
615             }
616
617             String var=ULocale.getVariant(testLocale);
618             if (0 !=var.compareTo(rawData2[VAR][i]))    {
619                 errln("  Variant code mismatch: "+var+" versus "+  rawData2[VAR][i]);
620             }
621
622             String name = ULocale.getName(testLocale);
623             if (0 !=name.compareTo(rawData2[NAME][i]))    {
624                 errln("  Name mismatch: "+name+" versus "+  rawData2[NAME][i]);
625             }
626
627         }
628     }
629
630     public void TestPrefixes() {
631         // POSIX ids are no longer handled by getName, so POSIX failures are ignored
632         final String [][] testData = new String[][]{
633                 /* null canonicalize() column means "expect same as getName()" */
634                 {"sv", "", "FI", "AL", "sv-fi-al", "sv_FI_AL", null},
635                 {"en", "", "GB", "", "en-gb", "en_GB", null},
636                 {"i-hakka", "", "MT", "XEMXIJA", "i-hakka_MT_XEMXIJA", "i-hakka_MT_XEMXIJA", null},
637                 {"i-hakka", "", "CN", "", "i-hakka_CN", "i-hakka_CN", null},
638                 {"i-hakka", "", "MX", "", "I-hakka_MX", "i-hakka_MX", null},
639                 {"x-klingon", "", "US", "SANJOSE", "X-KLINGON_us_SANJOSE", "x-klingon_US_SANJOSE", null},
640
641                 {"de", "", "", "1901", "de-1901", "de__1901", null},
642                 {"mr", "", "", "", "mr.utf8", "mr.utf8", "mr"},
643                 {"de", "", "TV", "", "de-tv.koi8r", "de_TV.koi8r", "de_TV"},
644                 {"x-piglatin", "", "ML", "", "x-piglatin_ML.MBE", "x-piglatin_ML.MBE", "x-piglatin_ML"},  /* Multibyte English */
645                 {"i-cherokee", "","US", "", "i-Cherokee_US.utf7", "i-cherokee_US.utf7", "i-cherokee_US"},
646                 {"x-filfli", "", "MT", "FILFLA", "x-filfli_MT_FILFLA.gb-18030", "x-filfli_MT_FILFLA.gb-18030", "x-filfli_MT_FILFLA"},
647                 {"no", "", "NO", "NY_B", "no-no-ny.utf32@B", "no_NO_NY.utf32@B", "no_NO_NY_B"},
648                 {"no", "", "NO", "B",  "no-no.utf32@B", "no_NO.utf32@B", "no_NO_B"},
649                 {"no", "", "",   "NY", "no__ny", "no__NY", null},
650                 {"no", "", "",   "NY", "no@ny", "no@ny", "no__NY"},
651                 {"el", "Latn", "", "", "el-latn", "el_Latn", null},
652                 {"en", "Cyrl", "RU", "", "en-cyrl-ru", "en_Cyrl_RU", null},
653                 {"zh", "Hant", "TW", "STROKE", "zh-hant_TW_STROKE", "zh_Hant_TW_STROKE", "zh_Hant_TW@collation=stroke"},
654                 {"zh", "Hant", "CN", "STROKE", "zh-hant_CN_STROKE", "zh_Hant_CN_STROKE", "zh_Hant_CN@collation=stroke"},
655                 {"zh", "Hant", "TW", "PINYIN", "zh-hant_TW_PINYIN", "zh_Hant_TW_PINYIN", "zh_Hant_TW@collation=pinyin"},
656                 {"qq", "Qqqq", "QQ", "QQ", "qq_Qqqq_QQ_QQ", "qq_Qqqq_QQ_QQ", null},
657                 {"qq", "Qqqq", "", "QQ", "qq_Qqqq__QQ", "qq_Qqqq__QQ", null},
658                 {"ab", "Cdef", "GH", "IJ", "ab_cdef_gh_ij", "ab_Cdef_GH_IJ", null}, /* total garbage */
659
660                 // odd cases
661                 {"", "", "", "", "@FOO=bar", "@foo=bar", null},
662                 {"", "", "", "", "_@FOO=bar", "@foo=bar", null},
663                 {"", "", "", "", "__@FOO=bar", "@foo=bar", null},
664                 {"", "", "", "FOO", "__foo@FOO=bar", "__FOO@foo=bar", null}, // we have some of these prefixes
665         };
666
667         String loc, buf,buf1;
668         final String [] testTitles = {
669                 "ULocale.getLanguage()",
670                 "ULocale.getScript()",
671                 "ULocale.getCountry()",
672                 "ULocale.getVariant()",
673                 "name",
674                 "ULocale.getName()",
675                 "canonicalize()",
676         };
677         ULocale uloc;
678
679         for(int row=0;row<testData.length;row++) {
680             loc = testData[row][NAME];
681             logln("Test #"+row+": "+loc);
682
683             uloc = new ULocale(loc);
684
685             for(int n=0;n<=(NAME+2);n++) {
686                 if(n==NAME) continue;
687
688                 switch(n) {
689                 case LANG:
690                     buf  = ULocale.getLanguage(loc);
691                     buf1 = uloc.getLanguage();
692                     break;
693
694                 case SCRIPT:
695                     buf  = ULocale.getScript(loc);
696                     buf1 = uloc.getScript();
697                     break;
698
699                 case CTRY:
700                     buf  = ULocale.getCountry(loc);
701                     buf1 = uloc.getCountry();
702                     break;
703
704                 case VAR:
705                     buf  = ULocale.getVariant(loc);
706                     buf1 = buf;
707                     break;
708
709                 case NAME+1:
710                     buf  = ULocale.getName(loc);
711                 buf1 = uloc.getName();
712                 break;
713
714                 case NAME+2:
715                     buf = ULocale.canonicalize(loc);
716                 buf1 = ULocale.createCanonical(loc).getName();
717                 break;
718
719                 default:
720                     buf = "**??";
721                     buf1 = buf;
722                 }
723
724                 logln("#"+row+": "+testTitles[n]+" on "+loc+": -> ["+buf+"]");
725
726                 String expected = testData[row][n];
727                 if (expected == null && n == (NAME+2)) {
728                     expected = testData[row][NAME+1];
729                 }
730
731                 // ignore POSIX failures in getName, we don't spec behavior in this case
732                 if (n == NAME+1 &&
733                         (expected.indexOf('.') != -1 ||
734                         expected.indexOf('@') != -1)) {
735                     continue;
736                 }
737
738                 if(buf.compareTo(expected)!=0) {
739                     errln("#"+row+": "+testTitles[n]+" on "+loc+": -> ["+buf+"] (expected '"+expected+"'!)");
740                 }
741                 if(buf1.compareTo(expected)!=0) {
742                     errln("#"+row+": "+testTitles[n]+" on ULocale object "+loc+": -> ["+buf1+"] (expected '"+expected+"'!)");
743                 }
744             }
745         }
746     }
747
748     public void TestObsoleteNames(){
749         final String[][] tests = new String[][]{
750                 /* locale, language3, language2, Country3, country2 */
751                 { "eng_USA", "eng", "en", "USA", "US" },
752                 { "kok",  "kok", "kok", "", "" },
753                 { "in",  "ind", "in", "", "" },
754                 { "id",  "ind", "id", "", "" }, /* NO aliasing */
755                 { "sh",  "srp", "sh", "", "" },
756                 { "zz_CS",  "", "zz", "SCG", "CS" },
757                 { "zz_FX",  "", "zz", "FXX", "FX" },
758                 { "zz_RO",  "", "zz", "ROU", "RO" },
759                 { "zz_TP",  "", "zz", "TMP", "TP" },
760                 { "zz_TL",  "", "zz", "TLS", "TL" },
761                 { "zz_ZR",  "", "zz", "ZAR", "ZR" },
762                 { "zz_FXX",  "", "zz", "FXX", "FX" }, /* no aliasing. Doesn't go to PS(PSE). */
763                 { "zz_ROM",  "", "zz", "ROU", "RO" },
764                 { "zz_ROU",  "", "zz", "ROU", "RO" },
765                 { "zz_ZAR",  "", "zz", "ZAR", "ZR" },
766                 { "zz_TMP",  "", "zz", "TMP", "TP" },
767                 { "zz_TLS",  "", "zz", "TLS", "TL" },
768                 { "zz_YUG",  "", "zz", "YUG", "YU" },
769                 { "mlt_PSE", "mlt", "mt", "PSE", "PS" },
770                 { "iw", "heb", "iw", "", "" },
771                 { "ji", "yid", "ji", "", "" },
772                 { "jw", "jaw", "jw", "", "" },
773                 { "sh", "srp", "sh", "", "" },
774                 { "", "", "", "", "" }
775         };
776
777         for(int i=0;i<tests.length;i++){
778             String locale = tests[i][0];
779             logln("** Testing : "+ locale);
780             String buff, buff1;
781             ULocale uloc  = new ULocale(locale);
782
783             buff = ULocale.getISO3Language(locale);
784             if(buff.compareTo(tests[i][1])!=0){
785                 errln("FAIL: ULocale.getISO3Language("+locale+")=="+
786                         buff+",\t expected "+tests[i][1]);
787             }else{
788                 logln("   ULocale.getISO3Language("+locale+")=="+buff);
789             }
790
791             buff1 = uloc.getISO3Language();
792             if(buff1.compareTo(tests[i][1])!=0){
793                 errln("FAIL: ULocale.getISO3Language("+locale+")=="+
794                         buff+",\t expected "+tests[i][1]);
795             }else{
796                 logln("   ULocale.getISO3Language("+locale+")=="+buff);
797             }
798
799             buff = ULocale.getLanguage(locale);
800             if(buff.compareTo(tests[i][2])!=0){
801                 errln("FAIL: ULocale.getLanguage("+locale+")=="+
802                         buff+",\t expected "+tests[i][2]);
803             }else{
804                 logln("   ULocale.getLanguage("+locale+")=="+buff);
805             }
806
807             buff = ULocale.getISO3Country(locale);
808             if(buff.compareTo(tests[i][3])!=0){
809                 errln("FAIL: ULocale.getISO3Country("+locale+")=="+
810                         buff+",\t expected "+tests[i][3]);
811             }else{
812                 logln("   ULocale.getISO3Country("+locale+")=="+buff);
813             }
814
815             buff1 = uloc.getISO3Country();
816             if(buff1.compareTo(tests[i][3])!=0){
817                 errln("FAIL: ULocale.getISO3Country("+locale+")=="+
818                         buff+",\t expected "+tests[i][3]);
819             }else{
820                 logln("   ULocale.getISO3Country("+locale+")=="+buff);
821             }
822
823             buff = ULocale.getCountry(locale);
824             if(buff.compareTo(tests[i][4])!=0){
825                 errln("FAIL: ULocale.getCountry("+locale+")=="+
826                         buff+",\t expected "+tests[i][4]);
827             }else{
828                 logln("   ULocale.getCountry("+locale+")=="+buff);
829             }
830         }
831
832         if (ULocale.getLanguage("iw_IL").compareTo( ULocale.getLanguage("he_IL"))==0) {
833             errln("he,iw ULocale.getLanguage mismatch");
834         }
835
836         String buff = ULocale.getLanguage("kok_IN");
837         if(buff.compareTo("kok")!=0){
838             errln("ULocale.getLanguage(\"kok\") failed. Expected: kok Got: "+buff);
839         }
840     }
841     public void TestCanonicalization(){
842         final String[][]testCases = new String[][]{
843                 { "ca_ES_PREEURO", "ca_ES_PREEURO", "ca_ES@currency=ESP" },
844                 { "de_AT_PREEURO", "de_AT_PREEURO", "de_AT@currency=ATS" },
845                 { "de_DE_PREEURO", "de_DE_PREEURO", "de_DE@currency=DEM" },
846                 { "de_LU_PREEURO", "de_LU_PREEURO", "de_LU@currency=EUR" },
847                 { "el_GR_PREEURO", "el_GR_PREEURO", "el_GR@currency=GRD" },
848                 { "en_BE_PREEURO", "en_BE_PREEURO", "en_BE@currency=BEF" },
849                 { "en_IE_PREEURO", "en_IE_PREEURO", "en_IE@currency=IEP" },
850                 { "es_ES_PREEURO", "es_ES_PREEURO", "es_ES@currency=ESP" },
851                 { "eu_ES_PREEURO", "eu_ES_PREEURO", "eu_ES@currency=ESP" },
852                 { "fi_FI_PREEURO", "fi_FI_PREEURO", "fi_FI@currency=FIM" },
853                 { "fr_BE_PREEURO", "fr_BE_PREEURO", "fr_BE@currency=BEF" },
854                 { "fr_FR_PREEURO", "fr_FR_PREEURO", "fr_FR@currency=FRF" },
855                 { "fr_LU_PREEURO", "fr_LU_PREEURO", "fr_LU@currency=LUF" },
856                 { "ga_IE_PREEURO", "ga_IE_PREEURO", "ga_IE@currency=IEP" },
857                 { "gl_ES_PREEURO", "gl_ES_PREEURO", "gl_ES@currency=ESP" },
858                 { "it_IT_PREEURO", "it_IT_PREEURO", "it_IT@currency=ITL" },
859                 { "nl_BE_PREEURO", "nl_BE_PREEURO", "nl_BE@currency=BEF" },
860                 { "nl_NL_PREEURO", "nl_NL_PREEURO", "nl_NL@currency=NLG" },
861                 { "pt_PT_PREEURO", "pt_PT_PREEURO", "pt_PT@currency=PTE" },
862                 { "de__PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" },
863                 { "de_PHONEBOOK", "de__PHONEBOOK", "de@collation=phonebook" },
864                 { "en_GB_EURO", "en_GB_EURO", "en_GB@currency=EUR" },
865                 { "en_GB@EURO", null, "en_GB@currency=EUR" }, /* POSIX ID */
866                 { "es__TRADITIONAL", "es__TRADITIONAL", "es@collation=traditional" },
867                 { "hi__DIRECT", "hi__DIRECT", "hi@collation=direct" },
868                 { "ja_JP_TRADITIONAL", "ja_JP_TRADITIONAL", "ja_JP@calendar=japanese" },
869                 { "th_TH_TRADITIONAL", "th_TH_TRADITIONAL", "th_TH@calendar=buddhist" },
870                 { "zh_TW_STROKE", "zh_TW_STROKE", "zh_TW@collation=stroke" },
871                 { "zh__PINYIN", "zh__PINYIN", "zh@collation=pinyin" },
872                 { "zh@collation=pinyin", "zh@collation=pinyin", "zh@collation=pinyin" },
873                 { "zh_CN@collation=pinyin", "zh_CN@collation=pinyin", "zh_CN@collation=pinyin" },
874                 { "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin", "zh_CN_CA@collation=pinyin" },
875                 { "en_US_POSIX", "en_US_POSIX", "en_US_POSIX" },
876                 { "hy_AM_REVISED", "hy_AM_REVISED", "hy_AM_REVISED" },
877                 { "no_NO_NY", "no_NO_NY", "no_NO_NY" /* not: "nn_NO" [alan ICU3.0] */ },
878                 { "no@ny", null, "no__NY" /* not: "nn" [alan ICU3.0] */ }, /* POSIX ID */
879                 { "no-no.utf32@B", null, "no_NO_B" /* not: "nb_NO_B" [alan ICU3.0] */ }, /* POSIX ID */
880                 { "qz-qz@Euro", null, "qz_QZ@currency=EUR" }, /* qz-qz uses private use iso codes */
881                 { "en-BOONT", "en__BOONT", "en__BOONT" }, /* registered name */
882                 { "de-1901", "de__1901", "de__1901" }, /* registered name */
883                 { "de-1906", "de__1906", "de__1906" }, /* registered name */
884                 { "sr-SP-Cyrl", "sr_SP_CYRL", "sr_Cyrl_RS" }, /* .NET name */
885                 { "sr-SP-Latn", "sr_SP_LATN", "sr_Latn_RS" }, /* .NET name */
886                 { "sr_YU_CYRILLIC", "sr_YU_CYRILLIC", "sr_Cyrl_RS" }, /* Linux name */
887                 { "uz-UZ-Cyrl", "uz_UZ_CYRL", "uz_Cyrl_UZ" }, /* .NET name */
888                 { "uz-UZ-Latn", "uz_UZ_LATN", "uz_Latn_UZ" }, /* .NET name */
889                 { "zh-CHS", "zh_CHS", "zh_Hans" }, /* .NET name */
890                 { "zh-CHT", "zh_CHT", "zh_Hant" }, /* .NET name This may change back to zh_Hant */
891
892                 /* posix behavior that used to be performed by getName */
893                 { "mr.utf8", null, "mr" },
894                 { "de-tv.koi8r", null, "de_TV" },
895                 { "x-piglatin_ML.MBE", null, "x-piglatin_ML" },
896                 { "i-cherokee_US.utf7", null, "i-cherokee_US" },
897                 { "x-filfli_MT_FILFLA.gb-18030", null, "x-filfli_MT_FILFLA" },
898                 { "no-no-ny.utf8@B", null, "no_NO_NY_B" /* not: "nn_NO" [alan ICU3.0] */ }, /* @ ignored unless variant is empty */
899
900                 /* fleshing out canonicalization */
901                 /* sort keywords, ';' is separator so not present at end in canonical form */
902                 { "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" },
903                 /* already-canonical ids are not changed */
904                 { "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" },
905                 /* PRE_EURO and EURO conversions don't affect other keywords */
906                 /* not in spec
907                { "es_ES_PREEURO@CALendar=Japanese", "es_ES_PREEURO@calendar=Japanese", "es_ES@calendar=Japanese;currency=ESP" },
908                { "es_ES_EURO@SHOUT=zipeedeedoodah", "es_ES_EURO@shout=zipeedeedoodah", "es_ES@currency=EUR;shout=zipeedeedoodah" },
909                  */
910                 /* currency keyword overrides PRE_EURO and EURO currency */
911                 /* not in spec
912                { "es_ES_PREEURO@currency=EUR", "es_ES_PREEURO@currency=EUR", "es_ES@currency=EUR" },
913                { "es_ES_EURO@currency=ESP", "es_ES_EURO@currency=ESP", "es_ES@currency=ESP" },
914                  */
915                 /* norwegian is just too weird, if we handle things in their full generality */
916                 /* this is a negative test to show that we DO NOT handle 'lang=no,var=NY' specially. */
917                 { "no-Hant-GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$", "no_Hant_GB_NY@currency=$$$" /* not: "nn_Hant_GB@currency=$$$" [alan ICU3.0] */ },
918
919                 /* test cases reflecting internal resource bundle usage */
920                 /* root is just a language */
921                 { "root@kw=foo", "root@kw=foo", "root@kw=foo" },
922                 /* level 2 canonicalization should not touch basename when there are keywords and it is null */
923                 { "@calendar=gregorian", "@calendar=gregorian", "@calendar=gregorian" },
924         };
925
926         for(int i = 0; i< testCases.length;i++){
927             String[] testCase = testCases[i];
928             String source = testCase[0];
929             String level1Expected = testCase[1];
930             String level2Expected = testCase[2];
931
932             if (level1Expected != null) { // null means we have no expectations for how this case is handled
933                 String level1 = ULocale.getName(source);
934                 if (!level1.equals(level1Expected)) {
935                     errln("ULocale.getName error for: '" + source +
936                             "' expected: '" + level1Expected + "' but got: '" + level1 + "'");
937                 } else {
938                     logln("Ulocale.getName for: '" + source + "' returned: '" + level1 + "'");
939                 }
940             } else {
941                 logln("ULocale.getName skipped: '" + source + "'");
942             }
943
944             if (level2Expected != null) {
945                 String level2 = ULocale.canonicalize(source);
946                 if(!level2.equals(level2Expected)){
947                     errln("ULocale.getName error for: '" + source +
948                             "' expected: '" + level2Expected + "' but got: '" + level2 + "'");
949                 } else {
950                     logln("Ulocale.canonicalize for: '" + source + "' returned: '" + level2 + "'");
951                 }
952             } else {
953                 logln("ULocale.canonicalize skipped: '" + source + "'");
954             }
955         }
956     }
957
958     public void TestGetAvailable(){
959         ULocale[] locales = ULocale.getAvailableLocales();
960         if(locales.length<10){
961             errln("Did not get the correct result from getAvailableLocales");
962         }
963         if(!locales[locales.length-1].getName().equals("zu_ZA")){
964             errln("Did not get the expected result");
965         }
966     }
967
968     public void TestDisplayNames() {
969         // consistency check, also check that all data is available
970         {
971             ULocale[] locales = ULocale.getAvailableLocales();
972             for (int i = 0; i < locales.length; ++i) {
973                 ULocale l = locales[i];
974                 String name = l.getDisplayName();
975
976                 logln(l + " --> " + name +
977                         ", " + l.getDisplayName(ULocale.GERMAN) +
978                         ", " + l.getDisplayName(ULocale.FRANCE));
979
980                 String language = l.getDisplayLanguage();
981                 String script = l.getDisplayScriptInContext();
982                 String country = l.getDisplayCountry();
983                 String variant = l.getDisplayVariant();
984
985                 checkName(name, language, script, country, variant, ULocale.getDefault());
986
987                 for (int j = 0; j < locales.length; ++j) {
988                     ULocale dl = locales[j];
989
990                     name = l.getDisplayName(dl);
991                     language = l.getDisplayLanguage(dl);
992                     script = l.getDisplayScriptInContext(dl);
993                     country = l.getDisplayCountry(dl);
994                     variant = l.getDisplayVariant(dl);
995
996                     if (!checkName(name, language, script, country, variant, dl)) {
997                         break;
998                     }
999                 }
1000             }
1001         }
1002         // spot check
1003         {
1004             ULocale[] locales = {
1005                     ULocale.US, ULocale.GERMANY, ULocale.FRANCE
1006             };
1007             String[] names = {
1008                     "Chinese (China)", "Chinesisch (China)", "chinois (Chine)"
1009             };
1010             String[] names2 = {
1011                     "Simplified Chinese (China)", "Chinesisch (vereinfacht) (China)", "chinois simplifi\u00E9 (Chine)"
1012             };
1013             ULocale locale = new ULocale("zh_CN");
1014             ULocale locale2 = new ULocale("zh_Hans_CN");
1015
1016             for (int i = 0; i < locales.length; ++i) {
1017                 String name = locale.getDisplayName(locales[i]);
1018                 if (!names[i].equals(name)) {
1019                     errln("expected '" + names[i] + "' but got '" + name + "'");
1020                 }
1021             }
1022             for (int i = 0; i < locales.length; ++i) {
1023                 String name = locale2.getDisplayNameWithDialect(locales[i]);
1024                 if (!names2[i].equals(name)) {
1025                     errln("expected '" + names2[i] + "' but got '" + name + "'");
1026                 }
1027             }
1028         }
1029         // test use of context
1030         {
1031             class TestContextItem {
1032                 public String displayLocale;
1033                 public DisplayContext dialectHandling;
1034                 public DisplayContext capitalization;
1035                 public String localeToBeNamed;
1036                 public String result;
1037                 public TestContextItem(String dLoc, DisplayContext dia, DisplayContext cap, String locToName, String res) {
1038                     displayLocale = dLoc;
1039                     dialectHandling = dia;
1040                     capitalization = cap;
1041                     localeToBeNamed = locToName;
1042                     result = res;
1043                 }
1044             };
1045             final TestContextItem[] items = {
1046                     new TestContextItem( "da", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,    "en",    "engelsk" ),
1047                     new TestContextItem( "da", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, "en",    "Engelsk" ),
1048                     new TestContextItem( "da", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU,       "en",    "Engelsk" ),
1049                     new TestContextItem( "da", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,    "en_US", "engelsk (USA)" ),
1050                     new TestContextItem( "da", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, "en_US", "Engelsk (USA)" ),
1051                     new TestContextItem( "da", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU,       "en_US", "Engelsk (USA)" ),
1052                     new TestContextItem( "da", DisplayContext.DIALECT_NAMES,  DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,    "en_US", "amerikansk engelsk" ),
1053                     new TestContextItem( "da", DisplayContext.DIALECT_NAMES,  DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, "en_US", "Amerikansk engelsk" ),
1054                     new TestContextItem( "da", DisplayContext.DIALECT_NAMES,  DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU,       "en_US", "Amerikansk engelsk" ),
1055                     new TestContextItem( "es", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,    "en",    "ingl\u00E9s" ),
1056                     new TestContextItem( "es", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, "en",    "Ingl\u00E9s" ),
1057                     new TestContextItem( "es", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU,       "en",    "Ingl\u00E9s" ),
1058                     new TestContextItem( "es", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,    "en_US", "ingl\u00E9s (Estados Unidos)" ),
1059                     new TestContextItem( "es", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, "en_US", "Ingl\u00E9s (Estados Unidos)" ),
1060                     new TestContextItem( "es", DisplayContext.STANDARD_NAMES, DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU,       "en_US", "Ingl\u00E9s (Estados Unidos)" ),
1061                     new TestContextItem( "es", DisplayContext.DIALECT_NAMES,  DisplayContext.CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE,    "en_US", "ingl\u00E9s estadounidense" ),
1062                     new TestContextItem( "es", DisplayContext.DIALECT_NAMES,  DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, "en_US", "Ingl\u00E9s estadounidense" ),
1063                     new TestContextItem( "es", DisplayContext.DIALECT_NAMES,  DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU,       "en_US", "Ingl\u00E9s estadounidense" ),
1064             };
1065             for (TestContextItem item: items) {
1066                 ULocale locale = new ULocale(item.displayLocale);
1067                 LocaleDisplayNames ldn = LocaleDisplayNames.getInstance(locale, item.dialectHandling, item.capitalization);
1068                 DisplayContext dialectHandling = ldn.getContext(DisplayContext.Type.DIALECT_HANDLING);
1069                 DisplayContext capitalization = ldn.getContext(DisplayContext.Type.CAPITALIZATION);
1070                 if (dialectHandling != item.dialectHandling || capitalization != item.capitalization) {
1071                     errln("FAIL: displayLocale: " + item.displayLocale + ", dialectHandling: " + item.dialectHandling +
1072                             ", capitalization: " + item.capitalization + ", localeToName: " + item.localeToBeNamed +
1073                             ", => read back dialectHandling: " + dialectHandling + ", capitalization: " + capitalization);
1074                 } else {
1075                     String result = ldn.localeDisplayName(item.localeToBeNamed);
1076                     if (!result.equals(item.result)) {
1077                         errln("FAIL: displayLocale: " + item.displayLocale + ", dialectHandling: " + item.dialectHandling +
1078                                 ", capitalization: " + item.capitalization + ", localeToName: " + item.localeToBeNamed +
1079                                 ", => expected result: " + item.result + ", got: " + result);
1080                     } 
1081                 }
1082             }
1083         }
1084     }
1085
1086     private boolean checkName(String name, String language, String script, String country, String variant, ULocale dl) {
1087         if (!checkInclusion(dl, name, language, "language")) {
1088             return false;
1089         }
1090         if (!checkInclusion(dl, name, script, "script")) {
1091             return false;
1092         }
1093         if (!checkInclusion(dl, name, country, "country")) {
1094             return false;
1095         }
1096         if (!checkInclusion(dl, name, variant, "variant")) {
1097             return false;
1098         }
1099         return true;
1100     }
1101
1102     private boolean checkInclusion(ULocale dl, String name, String substring, String substringName) {
1103         if (substring.length() > 0 && name.indexOf(substring) == -1) {
1104             String country2 = substring.replace('(', '[').replace(')',']').replace('(', '[').replace(')',']');
1105             if (name.indexOf(country2) == -1) {
1106                 errln("loc: " + dl + " name '" + name + "' does not contain " +
1107                                 substringName +
1108                                 " '" + substring + "'");
1109                 return false;
1110             }
1111         }
1112         return true;
1113     }
1114
1115     public void TestCoverage() {
1116         {
1117             //Cover displayXXX
1118             int i, j;
1119             String localeID="zh_CN";
1120             String name, language, script, country, variant;
1121             logln("Covering APIs with signature displayXXX(String, String)");
1122             for (i = 0; i < LOCALE_SIZE; i++) {
1123                 //localeID String
1124                 String testLocale=(rawData2[NAME][i]);
1125
1126                 logln("Testing "+ testLocale+".....");
1127                 name = ULocale.getDisplayName(localeID, testLocale);
1128                 language = ULocale.getDisplayLanguage(localeID, testLocale);
1129                 script = ULocale.getDisplayScriptInContext(localeID, testLocale);
1130                 country = ULocale.getDisplayCountry(localeID, testLocale);
1131                 variant = ULocale.getDisplayVariant(localeID, testLocale);
1132                 if (!checkName(name, language, script, country, variant, new ULocale(testLocale))) {
1133                     break;
1134                 }
1135             }
1136
1137             logln("Covering APIs with signature displayXXX(String, ULocale)\n");
1138             for (j = 0; j < LOCALE_SIZE; j++) {
1139                 String testLocale=(rawData2[NAME][j]);
1140                 ULocale loc = new ULocale(testLocale);
1141
1142                 logln("Testing "+ testLocale+".....");
1143                 name = ULocale.getDisplayName(localeID, loc);
1144                 language = ULocale.getDisplayLanguage(localeID, loc);
1145                 script = ULocale.getDisplayScriptInContext(localeID, loc);
1146                 country = ULocale.getDisplayCountry(localeID, loc);
1147                 variant = ULocale.getDisplayVariant(localeID, loc);
1148
1149                 if (!checkName(name, language, script, country, variant, loc)) {
1150                     break;
1151                 }
1152             }
1153         }
1154         ULocale loc1 = new ULocale("en_US_BROOKLYN");
1155         ULocale loc2 = new ULocale("en","US","BROOKLYN");
1156         if (!loc2.equals(loc1)){
1157             errln("ULocale.ULocale(String a, String b, String c)");
1158         }
1159
1160         ULocale loc3 = new ULocale("en_US");
1161         ULocale loc4 = new ULocale("en","US");
1162         if (!loc4.equals(loc3)){
1163             errln("ULocale.ULocale(String a, String b)");
1164         }
1165
1166         ULocale loc5 = (ULocale) loc4.clone();
1167         if (!loc5.equals(loc4)){
1168             errln("ULocale.clone should get the same ULocale");
1169         }
1170         ULocale.getISOCountries(); // To check the result ?!
1171     }
1172
1173     public void TestBamBm() {
1174         // "bam" shouldn't be there since the official code is 'bm'
1175         String[] isoLanguages = ULocale.getISOLanguages();
1176         for (int i = 0; i < isoLanguages.length; ++i) {
1177             if ("bam".equals(isoLanguages[i])) {
1178                 errln("found bam");
1179             }
1180             if (i > 0 && isoLanguages[i].compareTo(isoLanguages[i-1]) <= 0) {
1181                 errln("language list out of order: '" + isoLanguages[i] + " <= " + isoLanguages[i-1]);
1182             }
1183         }
1184     }
1185
1186     public void TestDisplayKeyword() {
1187         //prepare testing data
1188         initHashtable();
1189         String[] data = {"en_US@collation=phonebook;calendar=islamic-civil",
1190                 "zh_Hans@collation=pinyin;calendar=chinese",
1191         "foo_Bar_BAZ@collation=traditional;calendar=buddhist"};
1192
1193         for (int i = 0; i < data.length; i++) {
1194             String localeID = data[i];
1195             logln("");
1196             logln("Testing locale " + localeID + " ...");
1197             ULocale loc = new ULocale(localeID);
1198
1199             Iterator it = loc.getKeywords();
1200             Iterator it2 = ULocale.getKeywords(localeID);
1201             //it and it2 are not equal here. No way to verify their equivalence yet.
1202             while(it.hasNext()) {
1203                 String key = (String)it.next();
1204                 String key2 = (String)it2.next();
1205                 if (!key.equals(key2)) {
1206                     errln("FAIL: static and non-static getKeywords returned different results.");
1207                 }
1208
1209                 //To verify display of Keyword
1210                 // display the above key in English
1211                 String s0 = ULocale.getDisplayKeyword(key); //display in default locale
1212                 String s1 = ULocale.getDisplayKeyword(key, ULocale.US);
1213                 String s2 = ULocale.getDisplayKeyword(key, "en_US");
1214                 if (!s1.equals(s2)) {
1215                     errln ("FAIL: one of the getDisplayKeyword methods failed.");
1216                 }
1217                 if (ULocale.getDefault().equals(ULocale.US) && !s1.equals(s0)) {
1218                     errln ("FAIL: getDisplayKeyword methods failed for the default locale.");
1219                 }
1220                 if (!s1.equals(h[0].get(key))) {
1221                     errln("Locale " + localeID + " getDisplayKeyword for key: " + key +
1222                             " in English expected \"" + h[0].get(key) + "\" saw \"" + s1 + "\" instead");
1223                 } else {
1224                     logln("OK: getDisplayKeyword for key: " + key + " in English got " + s1);
1225                 }
1226
1227                 // display the key in S-Chinese
1228                 s1 = ULocale.getDisplayKeyword(key, ULocale.CHINA);
1229                 s2 = ULocale.getDisplayKeyword(key, "zh_Hans");
1230                 if (!s1.equals(s2)) {
1231                     errln ("one of the getDisplayKeyword methods failed.");
1232                 }
1233                 if (!s1.equals(h[1].get(key))) {
1234                     errln("Locale " + localeID + " getDisplayKeyword for key: " + key +
1235                             " in Chinese expected \"" + h[1].get(key) + "\" saw \"" + s1 + "\" instead");
1236                 } else {
1237                     logln("OK: getDisplayKeyword for key: " + key + " in Chinese got " + s1);
1238                 }
1239
1240                 //To verify display of Keyword values
1241                 String type = loc.getKeywordValue(key);
1242                 // display type in English
1243                 String ss0 = loc.getDisplayKeywordValue(key);
1244                 String ss1 = loc.getDisplayKeywordValue(key, ULocale.US);
1245                 String ss2 = ULocale.getDisplayKeywordValue(localeID, key, "en_US");
1246                 String ss3 = ULocale.getDisplayKeywordValue(localeID, key, ULocale.US);
1247                 if (!ss1.equals(ss2) || !ss1.equals(ss3)) {
1248                     errln ("FAIL: one of the getDisplayKeywordValue methods failed.");
1249                 }
1250                 if (ULocale.getDefault().equals(ULocale.US) && !ss1.equals(ss0)) {
1251                     errln ("FAIL: getDisplayKeyword methods failed for the default locale.");
1252                 }
1253                 if (!ss1.equals(h[0].get(type))) {
1254                     errln(" Locale " + localeID + " getDisplayKeywordValue for key: " + key +
1255                             " in English expected \"" + h[0].get(type) + "\" saw \"" + ss1 + "\" instead");
1256                 } else {
1257                     logln("OK: getDisplayKeywordValue for key: " + key + " in English got " + ss1);
1258                 }
1259
1260                 // display type in Chinese
1261                 ss0 = loc.getDisplayKeywordValue(key);
1262                 ss1 = loc.getDisplayKeywordValue(key, ULocale.CHINA);
1263                 ss2 = ULocale.getDisplayKeywordValue(localeID, key, "zh_Hans");
1264                 ss3 = ULocale.getDisplayKeywordValue(localeID, key, ULocale.CHINA);
1265                 if (!ss1.equals(ss2) || !ss1.equals(ss3)) {
1266                     errln ("one of the getDisplayKeywordValue methods failed.");
1267                 }
1268                 if (!ss1.equals(h[1].get(type))) {
1269                     errln("Locale " + localeID + " getDisplayKeywordValue for key: " + key +
1270                             " in Chinese expected \"" + h[1].get(type) + "\" saw \"" + ss1 + "\" instead");
1271                 } else {
1272                     logln("OK: getDisplayKeywordValue for key: " + key + " in Chinese got " + ss1);
1273                 }
1274             }
1275         }
1276     }
1277
1278     public void TestDisplayWithKeyword() {
1279         // Note, this test depends on locale display data for the U.S. and Taiwan.
1280         // If the data changes (in particular, the keyTypePattern may change for Taiwan),
1281         // this test will break.
1282         LocaleDisplayNames dn = LocaleDisplayNames.getInstance(ULocale.US,
1283                 DialectHandling.DIALECT_NAMES);
1284         LocaleDisplayNames tdn = LocaleDisplayNames.getInstance(ULocale.TAIWAN,
1285                 DialectHandling.DIALECT_NAMES);
1286         String name = dn.localeDisplayName("de@collation=phonebook");
1287         String target = "German (Phonebook Sort Order)";
1288         assertEquals("collation", target, name);
1289
1290         name = tdn.localeDisplayName("de@collation=phonebook");
1291         target = "德文(電話簿排序)"; // \u5FB7\u6587\uFF08\u96FB\u8A71\u7C3F\u6392\u5E8F\uFF09
1292         assertEquals("collation", target, name);
1293
1294         name = dn.localeDisplayName("de@currency=XYZ");
1295         target = "German (Currency: XYZ)";
1296         assertEquals("currency", target, name);
1297
1298         name = dn.localeDisplayName("de@collation=phonebook;currency=XYZ");
1299         target = "German (Phonebook Sort Order, Currency: XYZ)";
1300         assertEquals("currency", target, name);
1301
1302         name = dn.localeDisplayName("de_Latn_DE");
1303         target = "German (Latin, Germany)";
1304         assertEquals("currency", target, name);
1305
1306         name = tdn.localeDisplayName("de@currency=XYZ");
1307         target = "德文(貨幣:XYZ)";  // \u5FB7\u6587\uFF08\u8CA8\u5E63: XYZ\uFF09
1308         assertEquals("currency", target, name);
1309
1310         name = tdn.localeDisplayName("de@collation=phonebook;currency=XYZ");
1311         target = "德文(電話簿排序,貨幣:XYZ)"; // \u5FB7\u6587\uFF08\u96FB\u8A71\u7C3F\u6392\u5E8F\uFF09,\u5FB7\u6587\uFF08\u8CA8\u5E63: XYZ\uFF09
1312         assertEquals("collation", target, name);
1313
1314         name = dn.localeDisplayName("de@foo=bar");
1315         target = "German (foo=bar)";
1316         assertEquals("foo", target, name);
1317
1318         name = tdn.localeDisplayName("de@foo=bar");
1319         target = "德文(foo=bar)"; // \u5FB7\u6587\uFF08foo=bar\uFF09
1320         assertEquals("foo", target, name);
1321
1322         ULocale locale = ULocale.forLanguageTag("de-x-foobar");
1323         name = dn.localeDisplayName(locale);
1324         target = "German (Private-Use: foobar)";
1325         assertEquals("foobar", target, name);
1326
1327         name = tdn.localeDisplayName(locale);
1328         target = "德文(私人使用:foobar)"; // \u5FB7\u6587\uFF08\u79C1\u4EBA\u4F7F\u7528: foobar\uFF09
1329         assertEquals("foobar", target, name);
1330     }
1331
1332     private void initHashtable() {
1333         h[0] = new HashMap<String, String>();
1334         h[1] = new HashMap<String, String>();
1335
1336         //display in English
1337         h[0].put("collation", "Sort Order");
1338         h[0].put("calendar", "Calendar");
1339         h[0].put("currency", "Currency");
1340         h[0].put("phonebook", "Phonebook Sort Order");
1341         h[0].put("pinyin", "Pinyin Sort Order");
1342         h[0].put("traditional", "Traditional Sort Order");
1343         h[0].put("stroke", "Stroke Order");
1344         h[0].put("japanese", "Japanese Calendar");
1345         h[0].put("buddhist", "Buddhist Calendar");
1346         h[0].put("islamic", "Islamic Calendar");
1347         h[0].put("islamic-civil", "Islamic Calendar (tabular, civil epoch)" );
1348         h[0].put("hebrew", "Hebrew Calendar");
1349         h[0].put("chinese", "Chinese Calendar");
1350         h[0].put("gregorian", "Gregorian Calendar" );
1351
1352         //display in S-Chinese
1353         h[1].put("collation", "\u6392\u5E8F");
1354         h[1].put("calendar", "\u65E5\u5386");
1355         h[1].put("currency", "\u8D27\u5E01");
1356         h[1].put("phonebook", "\u7535\u8BDD\u7C3F\u6392\u5E8F\u987A\u5E8F");
1357         h[1].put("pinyin", "\u62FC\u97F3\u6392\u5E8F");
1358         h[1].put("stroke", "\u7B14\u5212\u987A\u5E8F");
1359         h[1].put("traditional", "\u4F20\u7EDF\u6392\u5E8F\u987A\u5E8F");
1360         h[1].put("japanese", "\u65E5\u672C\u65E5\u5386");
1361         h[1].put("buddhist", "\u4F5B\u6559\u65E5\u5386");
1362         h[1].put("islamic", "\u4F0A\u65AF\u5170\u65E5\u5386");
1363         h[1].put("islamic-civil", "\u4F0A\u65AF\u5170\u5E0C\u5409\u6765\u65E5\u5386");
1364         h[1].put("hebrew", "\u5E0C\u4F2F\u6765\u65E5\u5386");
1365         h[1].put("chinese", "\u519C\u5386");
1366         h[1].put("gregorian", "\u516C\u5386");
1367     }
1368
1369     //Hashtables for storing expected display of keys/types of locale in English and Chinese
1370     private static Map[] h = new Map[2];
1371
1372     private static final String ACCEPT_LANGUAGE_TESTS[][]  =  {
1373         /*#      result  fallback? */
1374         /*0*/ { "mt_MT", "false" },
1375         /*1*/ { "en", "false" },
1376         /*2*/ { "en", "true" }, // fell back from en-zzz to en
1377         /*3*/ { null, "true" },
1378         /*4*/ { "es", "false" }, 
1379         /*5*/ { "de", "false" },
1380         /*6*/ { "zh_TW", "false" },
1381         /*7*/ { "zh", "true" },
1382     };
1383
1384     private static final String ACCEPT_LANGUAGE_HTTP[] = { 
1385         /*0*/ "mt-mt, ja;q=0.76, en-us;q=0.95, en;q=0.92, en-gb;q=0.89, fr;q=0.87, iu-ca;q=0.84, iu;q=0.82, ja-jp;q=0.79, mt;q=0.97, de-de;q=0.74, de;q=0.71, es;q=0.68, it-it;q=0.66, it;q=0.63, vi-vn;q=0.61, vi;q=0.58, nl-nl;q=0.55, nl;q=0.53, th-th-traditional;q=.01",
1386         /*1*/ "ja;q=0.5, en;q=0.8, tlh",
1387         /*2*/ "en-zzz, de-lx;q=0.8",
1388         /*3*/ "mga-ie;q=0.9, tlh",
1389         /*4*/ "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1390                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1391                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1392                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1393                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1394                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1395                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1396                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1397                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1398                 "xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, xxx-yyy;q=.01, "+
1399                 "es",
1400                 /*5*/ "de;q=.9, fr;q=.9, xxx-yyy, sr;q=.8",
1401                 /*6*/ "zh-tw",
1402                 /*7*/ "zh-hant-cn",
1403     };
1404
1405
1406     public void TestAcceptLanguage() {
1407         for(int i = 0 ; i < (ACCEPT_LANGUAGE_HTTP.length); i++) {
1408             Boolean expectBoolean = new Boolean(ACCEPT_LANGUAGE_TESTS[i][1]);
1409             String expectLocale=ACCEPT_LANGUAGE_TESTS[i][0];
1410
1411             logln("#" + i + ": expecting: " + expectLocale + " (" + expectBoolean + ")");
1412
1413             boolean r[] = { false };
1414             ULocale n = ULocale.acceptLanguage(ACCEPT_LANGUAGE_HTTP[i], r);
1415             if((n==null)&&(expectLocale!=null)) {
1416                 errln("result was null! line #" + i);
1417                 continue;
1418             }
1419             if(((n==null)&&(expectLocale==null)) || (n.toString().equals(expectLocale))) {
1420                 logln(" locale: OK." );
1421             } else {
1422                 errln("expected " + expectLocale + " but got " + n.toString());
1423             }
1424             if(expectBoolean.equals(new Boolean(r[0]))) {
1425                 logln(" bool: OK.");
1426             } else {
1427                 errln("bool: not OK, was " + new Boolean(r[0]).toString() + " expected " + expectBoolean.toString());
1428             }
1429         }
1430     }
1431
1432     private ULocale[] StringToULocaleArray(String acceptLanguageList){
1433         //following code is copied from 
1434         //ULocale.acceptLanguage(String acceptLanguageList, ULocale[] availableLocales, boolean[] fallback)
1435         class ULocaleAcceptLanguageQ implements Comparable {
1436             private double q;
1437             private double serial;
1438             public ULocaleAcceptLanguageQ(double theq, int theserial) {
1439                 q = theq;
1440                 serial = theserial;
1441             }
1442             public int compareTo(Object o) {
1443                 ULocaleAcceptLanguageQ other = (ULocaleAcceptLanguageQ) o;
1444                 if(q > other.q) { // reverse - to sort in descending order
1445                     return -1;
1446                 } else if(q < other.q) {
1447                     return 1;
1448                 }
1449                 if(serial < other.serial) {
1450                     return -1;
1451                 } else if(serial > other.serial) {
1452                     return 1;
1453                 } else {
1454                     return 0; // same object
1455                 }
1456             }
1457         }
1458
1459         // 1st: parse out the acceptLanguageList into an array
1460
1461         TreeMap map = new TreeMap();
1462
1463         final int l = acceptLanguageList.length();
1464         int n;
1465         for(n=0;n<l;n++) {
1466             int itemEnd = acceptLanguageList.indexOf(',',n);
1467             if(itemEnd == -1) {
1468                 itemEnd = l;
1469             }
1470             int paramEnd = acceptLanguageList.indexOf(';',n);
1471             double q = 1.0;
1472
1473             if((paramEnd != -1) && (paramEnd < itemEnd)) {
1474                 /* semicolon (;) is closer than end (,) */
1475                 int t = paramEnd + 1;
1476                 while(UCharacter.isWhitespace(acceptLanguageList.charAt(t))) {
1477                     t++;
1478                 }
1479                 if(acceptLanguageList.charAt(t)=='q') {
1480                     t++;
1481                 }
1482                 while(UCharacter.isWhitespace(acceptLanguageList.charAt(t))) {
1483                     t++;
1484                 }
1485                 if(acceptLanguageList.charAt(t)=='=') {
1486                     t++;
1487                 }
1488                 while(UCharacter.isWhitespace(acceptLanguageList.charAt(t))) {
1489                     t++;
1490                 }
1491                 try {
1492                     String val = acceptLanguageList.substring(t,itemEnd).trim();
1493                     q = Double.parseDouble(val);
1494                 } catch (NumberFormatException nfe) {
1495                     q = 1.0;
1496                 }
1497             } else {
1498                 q = 1.0; //default
1499                 paramEnd = itemEnd;
1500             }
1501
1502             String loc = acceptLanguageList.substring(n,paramEnd).trim();
1503             int serial = map.size();
1504             ULocaleAcceptLanguageQ entry = new ULocaleAcceptLanguageQ(q,serial);
1505             map.put(entry, new ULocale(ULocale.canonicalize(loc))); // sort in reverse order..   1.0, 0.9, 0.8 .. etc
1506             n = itemEnd; // get next item. (n++ will skip over delimiter)
1507         }
1508
1509         // 2. pull out the map 
1510         ULocale acceptList[] = (ULocale[])map.values().toArray(new ULocale[map.size()]);
1511         return acceptList;
1512     }
1513
1514     public void TestAcceptLanguage2() {
1515         for(int i = 0 ; i < (ACCEPT_LANGUAGE_HTTP.length); i++) {
1516             Boolean expectBoolean = new Boolean(ACCEPT_LANGUAGE_TESTS[i][1]);
1517             String expectLocale=ACCEPT_LANGUAGE_TESTS[i][0];
1518
1519             logln("#" + i + ": expecting: " + expectLocale + " (" + expectBoolean + ")");
1520
1521             boolean r[] = { false };
1522             ULocale n = ULocale.acceptLanguage(StringToULocaleArray(ACCEPT_LANGUAGE_HTTP[i]), r);
1523             if((n==null)&&(expectLocale!=null)) {
1524                 errln("result was null! line #" + i);
1525                 continue;
1526             }
1527             if(((n==null)&&(expectLocale==null)) || (n.toString().equals(expectLocale))) {
1528                 logln(" locale: OK." );
1529             } else {
1530                 errln("expected " + expectLocale + " but got " + n.toString());
1531             }
1532             if(expectBoolean.equals(new Boolean(r[0]))) {
1533                 logln(" bool: OK.");
1534             } else {
1535                 errln("bool: not OK, was " + new Boolean(r[0]).toString() + " expected " + expectBoolean.toString());
1536             }
1537         }
1538     }
1539
1540     public void TestOrientation() {
1541         {
1542             String toTest [][] = {
1543                     { "ar", "right-to-left", "top-to-bottom" },
1544                     { "ar_Arab", "right-to-left", "top-to-bottom" },
1545                     { "fa", "right-to-left", "top-to-bottom" },
1546                     { "he", "right-to-left", "top-to-bottom" },
1547                     { "ps", "right-to-left", "top-to-bottom" },
1548                     { "ur", "right-to-left", "top-to-bottom" },
1549                     { "en", "left-to-right", "top-to-bottom" }
1550             };
1551
1552             for (int i = 0; i < toTest.length; ++i) {
1553                 ULocale loc = new ULocale(toTest[i][0]);
1554                 String co = loc.getCharacterOrientation();
1555                 String lo = loc.getLineOrientation();
1556                 if (!co.equals(toTest[i][1])) {
1557                     errln("Locale \"" + toTest[i][0] + "\" should have \"" + toTest[i][1] + "\" character orientation, but got \'" + co + "\"");
1558                 }
1559                 else if (!lo.equals(toTest[i][2])) {
1560                     errln("Locale \"" + toTest[i][0] + "\" should have \"" + toTest[i][2] + "\" line orientation, but got \'" + lo + "\"");
1561                 }
1562             }
1563         }
1564     }
1565
1566     public void TestJB3962(){
1567         ULocale loc = new ULocale("de_CH");
1568         String disp = loc.getDisplayName(ULocale.GERMAN);
1569         if(!disp.equals("Deutsch (Schweiz)")){
1570             errln("Did not get the expected display name for de_CH locale. Got: "+ prettify(disp));
1571         }
1572     }
1573
1574     public void TestAddLikelySubtags() {
1575         String[][] data = {
1576                 {"en", "en_Latn_US"},
1577                 {"en_US_BOSTON", "en_Latn_US_BOSTON"},
1578                 {"th@calendar=buddhist", "th_Thai_TH@calendar=buddhist"},
1579                 {"ar_ZZ", "ar_Arab_EG"},
1580                 {"zh", "zh_Hans_CN"},
1581                 {"zh_TW", "zh_Hant_TW"},
1582                 {"zh_HK", "zh_Hant_HK"},
1583                 {"zh_Hant", "zh_Hant_TW"},
1584                 {"zh_Zzzz_CN", "zh_Hans_CN"},
1585                 {"und_US", "en_Latn_US"},
1586                 {"und_HK", "zh_Hant_HK"},
1587                 /* Not yet implemented
1588             {"art_lojban", "arg_lojban"},
1589             {"zh_cmn_Hans", "zh_cmn_Hans"},
1590                  */
1591         };
1592         for (int i = 0; i < data.length; i++) {
1593             ULocale org = new ULocale(data[i][0]);
1594             ULocale res = ULocale.addLikelySubtags(org);
1595             if (!res.toString().equals(data[i][1])) {
1596                 errln("Original: " + data[i][0] + " Expected: " + data[i][1] + " - but got " + res.toString());
1597             }
1598         }
1599
1600         String[][] basic_maximize_data = {
1601                 {
1602                     "zu_Zzzz_Zz",
1603                     "zu_Latn_ZA",
1604                 }, {
1605                     "zu_Zz",
1606                     "zu_Latn_ZA"
1607                 }, {
1608                     "en_Zz",
1609                     "en_Latn_US"
1610                 }, {
1611                     "en_Kore",
1612                     "en_Kore_US"
1613                 }, {
1614                     "en_Kore_Zz",
1615                     "en_Kore_US"
1616                 }, {
1617                     "en_Kore_ZA",
1618                     "en_Kore_ZA"
1619                 }, {
1620                     "en_Kore_ZA_POSIX",
1621                     "en_Kore_ZA_POSIX"
1622                 }, {
1623                     "en_Gujr",
1624                     "en_Gujr_US"
1625                 }, {
1626                     "en_ZA",
1627                     "en_Latn_ZA"
1628                 }, {
1629                     "en_Gujr_Zz",
1630                     "en_Gujr_US"
1631                 }, {
1632                     "en_Gujr_ZA",
1633                     "en_Gujr_ZA"
1634                 }, {
1635                     "en_Gujr_ZA_POSIX",
1636                     "en_Gujr_ZA_POSIX"
1637                 }, {
1638                     "en_US_POSIX_1901",
1639                     "en_Latn_US_POSIX_1901"
1640                 }, {
1641                     "en_Latn__POSIX_1901",
1642                     "en_Latn_US_POSIX_1901"
1643                 }, {
1644                     "en__POSIX_1901",
1645                     "en_Latn_US_POSIX_1901"
1646                 }, {
1647                     "de__POSIX_1901",
1648                     "de_Latn_DE_POSIX_1901"
1649                 }, {
1650                     "zzz",
1651                     ""
1652                 }
1653         };
1654
1655         for (int i = 0; i < basic_maximize_data.length; i++) {
1656             ULocale org = new ULocale(basic_maximize_data[i][0]);
1657             ULocale res = ULocale.addLikelySubtags(org);
1658             String exp = basic_maximize_data[i][1];
1659             if (exp.length() == 0) {
1660                 if (!org.equals(res)) {
1661                     errln("Original: " + basic_maximize_data[i][0] + " expected: " + exp + " - but got " + res.toString());
1662                 }
1663             }
1664             else if (!res.toString().equals(exp)) {
1665                 errln("Original: " + basic_maximize_data[i][0] + " expected: " + exp + " - but got " + res.toString());
1666             }
1667         }
1668
1669         String[][] basic_minimize_data = {
1670                 {
1671                     "en_Latn_US",
1672                     "en"
1673                 }, {
1674                     "en_Latn_US_POSIX_1901",
1675                     "en__POSIX_1901"
1676                 }, {
1677                     "en_Zzzz_US_POSIX_1901",
1678                     "en__POSIX_1901"
1679                 }, {
1680                     "de_Latn_DE_POSIX_1901",
1681                     "de__POSIX_1901"
1682                 }, {
1683                     "und",
1684                     ""
1685                 }
1686         };
1687
1688         for (int i = 0; i < basic_minimize_data.length; i++) {
1689             ULocale org = new ULocale(basic_minimize_data[i][0]);
1690             ULocale res = ULocale.minimizeSubtags(org);
1691             String exp = basic_minimize_data[i][1];
1692             if (exp.length() == 0) {
1693                 if (!org.equals(res)) {
1694                     errln("Original: " + basic_minimize_data[i][0] + " expected: " + exp + " - but got " + res.toString());
1695                 }
1696             }
1697             else if (!res.toString().equals(exp)) {
1698                 errln("Original: " + basic_minimize_data[i][0] + " expected: " + exp + " - but got " + res.toString());
1699             }
1700         }
1701
1702         String[][] full_data = {
1703                 {
1704                     /*   "FROM", */
1705                     /*   "ADD-LIKELY", */
1706                     /*   "REMOVE-LIKELY" */
1707                     /* }, { */
1708                     "aa",
1709                     "aa_Latn_ET",
1710                     "aa"
1711                 }, {
1712                     "af",
1713                     "af_Latn_ZA",
1714                     "af"
1715                 }, {
1716                     "ak",
1717                     "ak_Latn_GH",
1718                     "ak"
1719                 }, {
1720                     "am",
1721                     "am_Ethi_ET",
1722                     "am"
1723                 }, {
1724                     "ar",
1725                     "ar_Arab_EG",
1726                     "ar"
1727                 }, {
1728                     "as",
1729                     "as_Beng_IN",
1730                     "as"
1731                 }, {
1732                     "az",
1733                     "az_Latn_AZ",
1734                     "az"
1735                 }, {
1736                     "be",
1737                     "be_Cyrl_BY",
1738                     "be"
1739                 }, {
1740                     "bg",
1741                     "bg_Cyrl_BG",
1742                     "bg"
1743                 }, {
1744                     "bn",
1745                     "bn_Beng_BD",
1746                     "bn"
1747                 }, {
1748                     "bo",
1749                     "bo_Tibt_CN",
1750                     "bo"
1751                 }, {
1752                     "bs",
1753                     "bs_Latn_BA",
1754                     "bs"
1755                 }, {
1756                     "ca",
1757                     "ca_Latn_ES",
1758                     "ca"
1759                 }, {
1760                     "ch",
1761                     "ch_Latn_GU",
1762                     "ch"
1763                 }, {
1764                     "chk",
1765                     "chk_Latn_FM",
1766                     "chk"
1767                 }, {
1768                     "cs",
1769                     "cs_Latn_CZ",
1770                     "cs"
1771                 }, {
1772                     "cy",
1773                     "cy_Latn_GB",
1774                     "cy"
1775                 }, {
1776                     "da",
1777                     "da_Latn_DK",
1778                     "da"
1779                 }, {
1780                     "de",
1781                     "de_Latn_DE",
1782                     "de"
1783                 }, {
1784                     "dv",
1785                     "dv_Thaa_MV",
1786                     "dv"
1787                 }, {
1788                     "dz",
1789                     "dz_Tibt_BT",
1790                     "dz"
1791                 }, {
1792                     "ee",
1793                     "ee_Latn_GH",
1794                     "ee"
1795                 }, {
1796                     "el",
1797                     "el_Grek_GR",
1798                     "el"
1799                 }, {
1800                     "en",
1801                     "en_Latn_US",
1802                     "en"
1803                 }, {
1804                     "es",
1805                     "es_Latn_ES",
1806                     "es"
1807                 }, {
1808                     "et",
1809                     "et_Latn_EE",
1810                     "et"
1811                 }, {
1812                     "eu",
1813                     "eu_Latn_ES",
1814                     "eu"
1815                 }, {
1816                     "fa",
1817                     "fa_Arab_IR",
1818                     "fa"
1819                 }, {
1820                     "fi",
1821                     "fi_Latn_FI",
1822                     "fi"
1823                 }, {
1824                     "fil",
1825                     "fil_Latn_PH",
1826                     "fil"
1827                 }, {
1828                     "fj",
1829                     "fj_Latn_FJ",
1830                     "fj"
1831                 }, {
1832                     "fo",
1833                     "fo_Latn_FO",
1834                     "fo"
1835                 }, {
1836                     "fr",
1837                     "fr_Latn_FR",
1838                     "fr"
1839                 }, {
1840                     "fur",
1841                     "fur_Latn_IT",
1842                     "fur"
1843                 }, {
1844                     "ga",
1845                     "ga_Latn_IE",
1846                     "ga"
1847                 }, {
1848                     "gaa",
1849                     "gaa_Latn_GH",
1850                     "gaa"
1851                 }, {
1852                     "gl",
1853                     "gl_Latn_ES",
1854                     "gl"
1855                 }, {
1856                     "gn",
1857                     "gn_Latn_PY",
1858                     "gn"
1859                 }, {
1860                     "gu",
1861                     "gu_Gujr_IN",
1862                     "gu"
1863                 }, {
1864                     "ha",
1865                     "ha_Latn_NG",
1866                     "ha"
1867                 }, {
1868                     "haw",
1869                     "haw_Latn_US",
1870                     "haw"
1871                 }, {
1872                     "he",
1873                     "he_Hebr_IL",
1874                     "he"
1875                 }, {
1876                     "hi",
1877                     "hi_Deva_IN",
1878                     "hi"
1879                 }, {
1880                     "hr",
1881                     "hr_Latn_HR",
1882                     "hr"
1883                 }, {
1884                     "ht",
1885                     "ht_Latn_HT",
1886                     "ht"
1887                 }, {
1888                     "hu",
1889                     "hu_Latn_HU",
1890                     "hu"
1891                 }, {
1892                     "hy",
1893                     "hy_Armn_AM",
1894                     "hy"
1895                 }, {
1896                     "id",
1897                     "id_Latn_ID",
1898                     "id"
1899                 }, {
1900                     "ig",
1901                     "ig_Latn_NG",
1902                     "ig"
1903                 }, {
1904                     "ii",
1905                     "ii_Yiii_CN",
1906                     "ii"
1907                 }, {
1908                     "is",
1909                     "is_Latn_IS",
1910                     "is"
1911                 }, {
1912                     "it",
1913                     "it_Latn_IT",
1914                     "it"
1915                 }, {
1916                     "ja",
1917                     "ja_Jpan_JP",
1918                     "ja"
1919                 }, {
1920                     "ka",
1921                     "ka_Geor_GE",
1922                     "ka"
1923                 }, {
1924                     "kaj",
1925                     "kaj_Latn_NG",
1926                     "kaj"
1927                 }, {
1928                     "kam",
1929                     "kam_Latn_KE",
1930                     "kam"
1931                 }, {
1932                     "kk",
1933                     "kk_Cyrl_KZ",
1934                     "kk"
1935                 }, {
1936                     "kl",
1937                     "kl_Latn_GL",
1938                     "kl"
1939                 }, {
1940                     "km",
1941                     "km_Khmr_KH",
1942                     "km"
1943                 }, {
1944                     "kn",
1945                     "kn_Knda_IN",
1946                     "kn"
1947                 }, {
1948                     "ko",
1949                     "ko_Kore_KR",
1950                     "ko"
1951                 }, {
1952                     "kok",
1953                     "kok_Deva_IN",
1954                     "kok"
1955                 }, {
1956                     "kpe",
1957                     "kpe_Latn_LR",
1958                     "kpe"
1959                 }, {
1960                     "ku",
1961                     "ku_Latn_TR",
1962                     "ku"
1963                 }, {
1964                     "ky",
1965                     "ky_Cyrl_KG",
1966                     "ky"
1967                 }, {
1968                     "la",
1969                     "la_Latn_VA",
1970                     "la"
1971                 }, {
1972                     "ln",
1973                     "ln_Latn_CD",
1974                     "ln"
1975                 }, {
1976                     "lo",
1977                     "lo_Laoo_LA",
1978                     "lo"
1979                 }, {
1980                     "lt",
1981                     "lt_Latn_LT",
1982                     "lt"
1983                 }, {
1984                     "lv",
1985                     "lv_Latn_LV",
1986                     "lv"
1987                 }, {
1988                     "mg",
1989                     "mg_Latn_MG",
1990                     "mg"
1991                 }, {
1992                     "mh",
1993                     "mh_Latn_MH",
1994                     "mh"
1995                 }, {
1996                     "mk",
1997                     "mk_Cyrl_MK",
1998                     "mk"
1999                 }, {
2000                     "ml",
2001                     "ml_Mlym_IN",
2002                     "ml"
2003                 }, {
2004                     "mn",
2005                     "mn_Cyrl_MN",
2006                     "mn"
2007                 }, {
2008                     "mr",
2009                     "mr_Deva_IN",
2010                     "mr"
2011                 }, {
2012                     "ms",
2013                     "ms_Latn_MY",
2014                     "ms"
2015                 }, {
2016                     "mt",
2017                     "mt_Latn_MT",
2018                     "mt"
2019                 }, {
2020                     "my",
2021                     "my_Mymr_MM",
2022                     "my"
2023                 }, {
2024                     "na",
2025                     "na_Latn_NR",
2026                     "na"
2027                 }, {
2028                     "ne",
2029                     "ne_Deva_NP",
2030                     "ne"
2031                 }, {
2032                     "niu",
2033                     "niu_Latn_NU",
2034                     "niu"
2035                 }, {
2036                     "nl",
2037                     "nl_Latn_NL",
2038                     "nl"
2039                 }, {
2040                     "nn",
2041                     "nn_Latn_NO",
2042                     "nn"
2043                 }, {
2044                     "nr",
2045                     "nr_Latn_ZA",
2046                     "nr"
2047                 }, {
2048                     "nso",
2049                     "nso_Latn_ZA",
2050                     "nso"
2051                 }, {
2052                     "om",
2053                     "om_Latn_ET",
2054                     "om"
2055                 }, {
2056                     "or",
2057                     "or_Orya_IN",
2058                     "or"
2059                 }, {
2060                     "pa",
2061                     "pa_Guru_IN",
2062                     "pa"
2063                 }, {
2064                     "pa_Arab",
2065                     "pa_Arab_PK",
2066                     "pa_PK"
2067                 }, {
2068                     "pa_PK",
2069                     "pa_Arab_PK",
2070                     "pa_PK"
2071                 }, {
2072                     "pap",
2073                     "pap_Latn_AW",
2074                     "pap"
2075                 }, {
2076                     "pau",
2077                     "pau_Latn_PW",
2078                     "pau"
2079                 }, {
2080                     "pl",
2081                     "pl_Latn_PL",
2082                     "pl"
2083                 }, {
2084                     "ps",
2085                     "ps_Arab_AF",
2086                     "ps"
2087                 }, {
2088                     "pt",
2089                     "pt_Latn_BR",
2090                     "pt"
2091                 }, {
2092                     "rn",
2093                     "rn_Latn_BI",
2094                     "rn"
2095                 }, {
2096                     "ro",
2097                     "ro_Latn_RO",
2098                     "ro"
2099                 }, {
2100                     "ru",
2101                     "ru_Cyrl_RU",
2102                     "ru"
2103                 }, {
2104                     "rw",
2105                     "rw_Latn_RW",
2106                     "rw"
2107                 }, {
2108                     "sa",
2109                     "sa_Deva_IN",
2110                     "sa"
2111                 }, {
2112                     "se",
2113                     "se_Latn_NO",
2114                     "se"
2115                 }, {
2116                     "sg",
2117                     "sg_Latn_CF",
2118                     "sg"
2119                 }, {
2120                     "si",
2121                     "si_Sinh_LK",
2122                     "si"
2123                 }, {
2124                     "sid",
2125                     "sid_Latn_ET",
2126                     "sid"
2127                 }, {
2128                     "sk",
2129                     "sk_Latn_SK",
2130                     "sk"
2131                 }, {
2132                     "sl",
2133                     "sl_Latn_SI",
2134                     "sl"
2135                 }, {
2136                     "sm",
2137                     "sm_Latn_WS",
2138                     "sm"
2139                 }, {
2140                     "so",
2141                     "so_Latn_SO",
2142                     "so"
2143                 }, {
2144                     "sq",
2145                     "sq_Latn_AL",
2146                     "sq"
2147                 }, {
2148                     "sr",
2149                     "sr_Cyrl_RS",
2150                     "sr"
2151                 }, {
2152                     "ss",
2153                     "ss_Latn_ZA",
2154                     "ss"
2155                 }, {
2156                     "st",
2157                     "st_Latn_ZA",
2158                     "st"
2159                 }, {
2160                     "sv",
2161                     "sv_Latn_SE",
2162                     "sv"
2163                 }, {
2164                     "sw",
2165                     "sw_Latn_TZ",
2166                     "sw"
2167                 }, {
2168                     "ta",
2169                     "ta_Taml_IN",
2170                     "ta"
2171                 }, {
2172                     "te",
2173                     "te_Telu_IN",
2174                     "te"
2175                 }, {
2176                     "tet",
2177                     "tet_Latn_TL",
2178                     "tet"
2179                 }, {
2180                     "tg",
2181                     "tg_Cyrl_TJ",
2182                     "tg"
2183                 }, {
2184                     "th",
2185                     "th_Thai_TH",
2186                     "th"
2187                 }, {
2188                     "ti",
2189                     "ti_Ethi_ET",
2190                     "ti"
2191                 }, {
2192                     "tig",
2193                     "tig_Ethi_ER",
2194                     "tig"
2195                 }, {
2196                     "tk",
2197                     "tk_Latn_TM",
2198                     "tk"
2199                 }, {
2200                     "tkl",
2201                     "tkl_Latn_TK",
2202                     "tkl"
2203                 }, {
2204                     "tn",
2205                     "tn_Latn_ZA",
2206                     "tn"
2207                 }, {
2208                     "to",
2209                     "to_Latn_TO",
2210                     "to"
2211                 }, {
2212                     "tpi",
2213                     "tpi_Latn_PG",
2214                     "tpi"
2215                 }, {
2216                     "tr",
2217                     "tr_Latn_TR",
2218                     "tr"
2219                 }, {
2220                     "ts",
2221                     "ts_Latn_ZA",
2222                     "ts"
2223                 }, {
2224                     "tt",
2225                     "tt_Cyrl_RU",
2226                     "tt"
2227                 }, {
2228                     "tvl",
2229                     "tvl_Latn_TV",
2230                     "tvl"
2231                 }, {
2232                     "ty",
2233                     "ty_Latn_PF",
2234                     "ty"
2235                 }, {
2236                     "uk",
2237                     "uk_Cyrl_UA",
2238                     "uk"
2239                 }, {
2240                     "und",
2241                     "en_Latn_US",
2242                     "en"
2243                 }, {
2244                     "und_AD",
2245                     "ca_Latn_AD",
2246                     "ca_AD"
2247                 }, {
2248                     "und_AE",
2249                     "ar_Arab_AE",
2250                     "ar_AE"
2251                 }, {
2252                     "und_AF",
2253                     "fa_Arab_AF",
2254                     "fa_AF"
2255                 }, {
2256                     "und_AL",
2257                     "sq_Latn_AL",
2258                     "sq"
2259                 }, {
2260                     "und_AM",
2261                     "hy_Armn_AM",
2262                     "hy"
2263                 }, {
2264                     "und_AO",
2265                     "pt_Latn_AO",
2266                     "pt_AO"
2267                 }, {
2268                     "und_AR",
2269                     "es_Latn_AR",
2270                     "es_AR"
2271                 }, {
2272                     "und_AS",
2273                     "sm_Latn_AS",
2274                     "sm_AS"
2275                 }, {
2276                     "und_AT",
2277                     "de_Latn_AT",
2278                     "de_AT"
2279                 }, {
2280                     "und_AW",
2281                     "nl_Latn_AW",
2282                     "nl_AW"
2283                 }, {
2284                     "und_AX",
2285                     "sv_Latn_AX",
2286                     "sv_AX"
2287                 }, {
2288                     "und_AZ",
2289                     "az_Latn_AZ",
2290                     "az"
2291                 }, {
2292                     "und_Arab",
2293                     "ar_Arab_EG",
2294                     "ar"
2295                 }, {
2296                     "und_Arab_IN",
2297                     "ur_Arab_IN",
2298                     "ur_IN"
2299                 }, {
2300                     "und_Arab_PK",
2301                     "ur_Arab_PK",
2302                     "ur"
2303                 }, {
2304                     "und_Arab_SN",
2305                     "ar_Arab_SN",
2306                     "ar_SN"
2307                 }, {
2308                     "und_Armn",
2309                     "hy_Armn_AM",
2310                     "hy"
2311                 }, {
2312                     "und_BA",
2313                     "bs_Latn_BA",
2314                     "bs"
2315                 }, {
2316                     "und_BD",
2317                     "bn_Beng_BD",
2318                     "bn"
2319                 }, {
2320                     "und_BE",
2321                     "nl_Latn_BE",
2322                     "nl_BE"
2323                 }, {
2324                     "und_BF",
2325                     "fr_Latn_BF",
2326                     "fr_BF"
2327                 }, {
2328                     "und_BG",
2329                     "bg_Cyrl_BG",
2330                     "bg"
2331                 }, {
2332                     "und_BH",
2333                     "ar_Arab_BH",
2334                     "ar_BH"
2335                 }, {
2336                     "und_BI",
2337                     "rn_Latn_BI",
2338                     "rn"
2339                 }, {
2340                     "und_BJ",
2341                     "fr_Latn_BJ",
2342                     "fr_BJ"
2343                 }, {
2344                     "und_BN",
2345                     "ms_Latn_BN",
2346                     "ms_BN"
2347                 }, {
2348                     "und_BO",
2349                     "es_Latn_BO",
2350                     "es_BO"
2351                 }, {
2352                     "und_BR",
2353                     "pt_Latn_BR",
2354                     "pt"
2355                 }, {
2356                     "und_BT",
2357                     "dz_Tibt_BT",
2358                     "dz"
2359                 }, {
2360                     "und_BY",
2361                     "be_Cyrl_BY",
2362                     "be"
2363                 }, {
2364                     "und_Beng",
2365                     "bn_Beng_BD",
2366                     "bn"
2367                 }, {
2368                     "und_Beng_IN",
2369                     "bn_Beng_IN",
2370                     "bn_IN"
2371                 }, {
2372                     "und_CD",
2373                     "sw_Latn_CD",
2374                     "sw_CD"
2375                 }, {
2376                     "und_CF",
2377                     "fr_Latn_CF",
2378                     "fr_CF"
2379                 }, {
2380                     "und_CG",
2381                     "fr_Latn_CG",
2382                     "fr_CG"
2383                 }, {
2384                     "und_CH",
2385                     "de_Latn_CH",
2386                     "de_CH"
2387                 }, {
2388                     "und_CI",
2389                     "fr_Latn_CI",
2390                     "fr_CI"
2391                 }, {
2392                     "und_CL",
2393                     "es_Latn_CL",
2394                     "es_CL"
2395                 }, {
2396                     "und_CM",
2397                     "fr_Latn_CM",
2398                     "fr_CM"
2399                 }, {
2400                     "und_CN",
2401                     "zh_Hans_CN",
2402                     "zh"
2403                 }, {
2404                     "und_CO",
2405                     "es_Latn_CO",
2406                     "es_CO"
2407                 }, {
2408                     "und_CR",
2409                     "es_Latn_CR",
2410                     "es_CR"
2411                 }, {
2412                     "und_CU",
2413                     "es_Latn_CU",
2414                     "es_CU"
2415                 }, {
2416                     "und_CV",
2417                     "pt_Latn_CV",
2418                     "pt_CV"
2419                 }, {
2420                     "und_CY",
2421                     "el_Grek_CY",
2422                     "el_CY"
2423                 }, {
2424                     "und_CZ",
2425                     "cs_Latn_CZ",
2426                     "cs"
2427                 }, {
2428                     "und_Cyrl",
2429                     "ru_Cyrl_RU",
2430                     "ru"
2431                 }, {
2432                     "und_Cyrl_KZ",
2433                     "ru_Cyrl_KZ",
2434                     "ru_KZ"
2435                 }, {
2436                     "und_DE",
2437                     "de_Latn_DE",
2438                     "de"
2439                 }, {
2440                     "und_DJ",
2441                     "aa_Latn_DJ",
2442                     "aa_DJ"
2443                 }, {
2444                     "und_DK",
2445                     "da_Latn_DK",
2446                     "da"
2447                 }, {
2448                     "und_DO",
2449                     "es_Latn_DO",
2450                     "es_DO"
2451                 }, {
2452                     "und_DZ",
2453                     "ar_Arab_DZ",
2454                     "ar_DZ"
2455                 }, {
2456                     "und_Deva",
2457                     "hi_Deva_IN",
2458                     "hi"
2459                 }, {
2460                     "und_EC",
2461                     "es_Latn_EC",
2462                     "es_EC"
2463                 }, {
2464                     "und_EE",
2465                     "et_Latn_EE",
2466                     "et"
2467                 }, {
2468                     "und_EG",
2469                     "ar_Arab_EG",
2470                     "ar"
2471                 }, {
2472                     "und_EH",
2473                     "ar_Arab_EH",
2474                     "ar_EH"
2475                 }, {
2476                     "und_ER",
2477                     "ti_Ethi_ER",
2478                     "ti_ER"
2479                 }, {
2480                     "und_ES",
2481                     "es_Latn_ES",
2482                     "es"
2483                 }, {
2484                     "und_ET",
2485                     "am_Ethi_ET",
2486                     "am"
2487                 }, {
2488                     "und_Ethi",
2489                     "am_Ethi_ET",
2490                     "am"
2491                 }, {
2492                     "und_Ethi_ER",
2493                     "am_Ethi_ER",
2494                     "am_ER"
2495                 }, {
2496                     "und_FI",
2497                     "fi_Latn_FI",
2498                     "fi"
2499                 }, {
2500                     "und_FM",
2501                     "chk_Latn_FM",
2502                     "chk"
2503                 }, {
2504                     "und_FO",
2505                     "fo_Latn_FO",
2506                     "fo"
2507                 }, {
2508                     "und_FR",
2509                     "fr_Latn_FR",
2510                     "fr"
2511                 }, {
2512                     "und_GA",
2513                     "fr_Latn_GA",
2514                     "fr_GA"
2515                 }, {
2516                     "und_GE",
2517                     "ka_Geor_GE",
2518                     "ka"
2519                 }, {
2520                     "und_GF",
2521                     "fr_Latn_GF",
2522                     "fr_GF"
2523                 }, {
2524                     "und_GL",
2525                     "kl_Latn_GL",
2526                     "kl"
2527                 }, {
2528                     "und_GN",
2529                     "fr_Latn_GN",
2530                     "fr_GN"
2531                 }, {
2532                     "und_GP",
2533                     "fr_Latn_GP",
2534                     "fr_GP"
2535                 }, {
2536                     "und_GQ",
2537                     "es_Latn_GQ",
2538                     "es_GQ"
2539                 }, {
2540                     "und_GR",
2541                     "el_Grek_GR",
2542                     "el"
2543                 }, {
2544                     "und_GT",
2545                     "es_Latn_GT",
2546                     "es_GT"
2547                 }, {
2548                     "und_GU",
2549                     "en_Latn_GU",
2550                     "en_GU"
2551                 }, {
2552                     "und_GW",
2553                     "pt_Latn_GW",
2554                     "pt_GW"
2555                 }, {
2556                     "und_Geor",
2557                     "ka_Geor_GE",
2558                     "ka"
2559                 }, {
2560                     "und_Grek",
2561                     "el_Grek_GR",
2562                     "el"
2563                 }, {
2564                     "und_Gujr",
2565                     "gu_Gujr_IN",
2566                     "gu"
2567                 }, {
2568                     "und_Guru",
2569                     "pa_Guru_IN",
2570                     "pa"
2571                 }, {
2572                     "und_HK",
2573                     "zh_Hant_HK",
2574                     "zh_HK"
2575                 }, {
2576                     "und_HN",
2577                     "es_Latn_HN",
2578                     "es_HN"
2579                 }, {
2580                     "und_HR",
2581                     "hr_Latn_HR",
2582                     "hr"
2583                 }, {
2584                     "und_HT",
2585                     "ht_Latn_HT",
2586                     "ht"
2587                 }, {
2588                     "und_HU",
2589                     "hu_Latn_HU",
2590                     "hu"
2591                 }, {
2592                     "und_Hani",
2593                     "zh_Hani_CN",
2594                     "zh_Hani"
2595                 }, {
2596                     "und_Hans",
2597                     "zh_Hans_CN",
2598                     "zh"
2599                 }, {
2600                     "und_Hant",
2601                     "zh_Hant_TW",
2602                     "zh_TW"
2603                 }, {
2604                     "und_Hebr",
2605                     "he_Hebr_IL",
2606                     "he"
2607                 }, {
2608                     "und_ID",
2609                     "id_Latn_ID",
2610                     "id"
2611                 }, {
2612                     "und_IL",
2613                     "he_Hebr_IL",
2614                     "he"
2615                 }, {
2616                     "und_IN",
2617                     "hi_Deva_IN",
2618                     "hi"
2619                 }, {
2620                     "und_IQ",
2621                     "ar_Arab_IQ",
2622                     "ar_IQ"
2623                 }, {
2624                     "und_IR",
2625                     "fa_Arab_IR",
2626                     "fa"
2627                 }, {
2628                     "und_IS",
2629                     "is_Latn_IS",
2630                     "is"
2631                 }, {
2632                     "und_IT",
2633                     "it_Latn_IT",
2634                     "it"
2635                 }, {
2636                     "und_JO",
2637                     "ar_Arab_JO",
2638                     "ar_JO"
2639                 }, {
2640                     "und_JP",
2641                     "ja_Jpan_JP",
2642                     "ja"
2643                 }, {
2644                     "und_Jpan",
2645                     "ja_Jpan_JP",
2646                     "ja"
2647                 }, {
2648                     "und_KG",
2649                     "ky_Cyrl_KG",
2650                     "ky"
2651                 }, {
2652                     "und_KH",
2653                     "km_Khmr_KH",
2654                     "km"
2655                 }, {
2656                     "und_KM",
2657                     "ar_Arab_KM",
2658                     "ar_KM"
2659                 }, {
2660                     "und_KP",
2661                     "ko_Kore_KP",
2662                     "ko_KP"
2663                 }, {
2664                     "und_KR",
2665                     "ko_Kore_KR",
2666                     "ko"
2667                 }, {
2668                     "und_KW",
2669                     "ar_Arab_KW",
2670                     "ar_KW"
2671                 }, {
2672                     "und_KZ",
2673                     "ru_Cyrl_KZ",
2674                     "ru_KZ"
2675                 }, {
2676                     "und_Khmr",
2677                     "km_Khmr_KH",
2678                     "km"
2679                 }, {
2680                     "und_Knda",
2681                     "kn_Knda_IN",
2682                     "kn"
2683                 }, {
2684                     "und_Kore",
2685                     "ko_Kore_KR",
2686                     "ko"
2687                 }, {
2688                     "und_LA",
2689                     "lo_Laoo_LA",
2690                     "lo"
2691                 }, {
2692                     "und_LB",
2693                     "ar_Arab_LB",
2694                     "ar_LB"
2695                 }, {
2696                     "und_LI",
2697                     "de_Latn_LI",
2698                     "de_LI"
2699                 }, {
2700                     "und_LK",
2701                     "si_Sinh_LK",
2702                     "si"
2703                 }, {
2704                     "und_LS",
2705                     "st_Latn_LS",
2706                     "st_LS"
2707                 }, {
2708                     "und_LT",
2709                     "lt_Latn_LT",
2710                     "lt"
2711                 }, {
2712                     "und_LU",
2713                     "fr_Latn_LU",
2714                     "fr_LU"
2715                 }, {
2716                     "und_LV",
2717                     "lv_Latn_LV",
2718                     "lv"
2719                 }, {
2720                     "und_LY",
2721                     "ar_Arab_LY",
2722                     "ar_LY"
2723                 }, {
2724                     "und_Laoo",
2725                     "lo_Laoo_LA",
2726                     "lo"
2727                 }, {
2728                     "und_Latn_ES",
2729                     "es_Latn_ES",
2730                     "es"
2731                 }, {
2732                     "und_Latn_ET",
2733                     "en_Latn_ET",
2734                     "en_ET"
2735                 }, {
2736                     "und_Latn_GB",
2737                     "en_Latn_GB",
2738                     "en_GB"
2739                 }, {
2740                     "und_Latn_GH",
2741                     "ak_Latn_GH",
2742                     "ak"
2743                 }, {
2744                     "und_Latn_ID",
2745                     "id_Latn_ID",
2746                     "id"
2747                 }, {
2748                     "und_Latn_IT",
2749                     "it_Latn_IT",
2750                     "it"
2751                 }, {
2752                     "und_Latn_NG",
2753                     "en_Latn_NG",
2754                     "en_NG"
2755                 }, {
2756                     "und_Latn_TR",
2757                     "tr_Latn_TR",
2758                     "tr"
2759                 }, {
2760                     "und_Latn_ZA",
2761                     "en_Latn_ZA",
2762                     "en_ZA"
2763                 }, {
2764                     "und_MA",
2765                     "ar_Arab_MA",
2766                     "ar_MA"
2767                 }, {
2768                     "und_MC",
2769                     "fr_Latn_MC",
2770                     "fr_MC"
2771                 }, {
2772                     "und_MD",
2773                     "ro_Latn_MD",
2774                     "ro_MD"
2775                 }, {
2776                     "und_ME",
2777                     "sr_Latn_ME",
2778                     "sr_ME"
2779                 }, {
2780                     "und_MG",
2781                     "mg_Latn_MG",
2782                     "mg"
2783                 }, {
2784                     "und_MK",
2785                     "mk_Cyrl_MK",
2786                     "mk"
2787                 }, {
2788                     "und_ML",
2789                     "bm_Latn_ML",
2790                     "bm"
2791                 }, {
2792                     "und_MM",
2793                     "my_Mymr_MM",
2794                     "my"
2795                 }, {
2796                     "und_MN",
2797                     "mn_Cyrl_MN",
2798                     "mn"
2799                 }, {
2800                     "und_MO",
2801                     "zh_Hant_MO",
2802                     "zh_MO"
2803                 }, {
2804                     "und_MQ",
2805                     "fr_Latn_MQ",
2806                     "fr_MQ"
2807                 }, {
2808                     "und_MR",
2809                     "ar_Arab_MR",
2810                     "ar_MR"
2811                 }, {
2812                     "und_MT",
2813                     "mt_Latn_MT",
2814                     "mt"
2815                 }, {
2816                     "und_MV",
2817                     "dv_Thaa_MV",
2818                     "dv"
2819                 }, {
2820                     "und_MX",
2821                     "es_Latn_MX",
2822                     "es_MX"
2823                 }, {
2824                     "und_MY",
2825                     "ms_Latn_MY",
2826                     "ms"
2827                 }, {
2828                     "und_MZ",
2829                     "pt_Latn_MZ",
2830                     "pt_MZ"
2831                 }, {
2832                     "und_Mlym",
2833                     "ml_Mlym_IN",
2834                     "ml"
2835                 }, {
2836                     "und_Mymr",
2837                     "my_Mymr_MM",
2838                     "my"
2839                 }, {
2840                     "und_NC",
2841                     "fr_Latn_NC",
2842                     "fr_NC"
2843                 }, {
2844                     "und_NE",
2845                     "ha_Latn_NE",
2846                     "ha_NE"
2847                 }, {
2848                     "und_NG",
2849                     "en_Latn_NG",
2850                     "en_NG"
2851                 }, {
2852                     "und_NI",
2853                     "es_Latn_NI",
2854                     "es_NI"
2855                 }, {
2856                     "und_NL",
2857                     "nl_Latn_NL",
2858                     "nl"
2859                 }, {
2860                     "und_NO",
2861                     "nb_Latn_NO",
2862                     "nb"
2863                 }, {
2864                     "und_NP",
2865                     "ne_Deva_NP",
2866                     "ne"
2867                 }, {
2868                     "und_NR",
2869                     "en_Latn_NR",
2870                     "en_NR"
2871                 }, {
2872                     "und_OM",
2873                     "ar_Arab_OM",
2874                     "ar_OM"
2875                 }, {
2876                     "und_Orya",
2877                     "or_Orya_IN",
2878                     "or"
2879                 }, {
2880                     "und_PA",
2881                     "es_Latn_PA",
2882                     "es_PA"
2883                 }, {
2884                     "und_PE",
2885                     "es_Latn_PE",
2886                     "es_PE"
2887                 }, {
2888                     "und_PF",
2889                     "fr_Latn_PF",
2890                     "fr_PF"
2891                 }, {
2892                     "und_PG",
2893                     "tpi_Latn_PG",
2894                     "tpi"
2895                 }, {
2896                     "und_PH",
2897                     "fil_Latn_PH",
2898                     "fil"
2899                 }, {
2900                     "und_PL",
2901                     "pl_Latn_PL",
2902                     "pl"
2903                 }, {
2904                     "und_PM",
2905                     "fr_Latn_PM",
2906                     "fr_PM"
2907                 }, {
2908                     "und_PR",
2909                     "es_Latn_PR",
2910                     "es_PR"
2911                 }, {
2912                     "und_PS",
2913                     "ar_Arab_PS",
2914                     "ar_PS"
2915                 }, {
2916                     "und_PT",
2917                     "pt_Latn_PT",
2918                     "pt_PT"
2919                 }, {
2920                     "und_PW",
2921                     "pau_Latn_PW",
2922                     "pau"
2923                 }, {
2924                     "und_PY",
2925                     "gn_Latn_PY",
2926                     "gn"
2927                 }, {
2928                     "und_QA",
2929                     "ar_Arab_QA",
2930                     "ar_QA"
2931                 }, {
2932                     "und_RE",
2933                     "fr_Latn_RE",
2934                     "fr_RE"
2935                 }, {
2936                     "und_RO",
2937                     "ro_Latn_RO",
2938                     "ro"
2939                 }, {
2940                     "und_RS",
2941                     "sr_Cyrl_RS",
2942                     "sr"
2943                 }, {
2944                     "und_RU",
2945                     "ru_Cyrl_RU",
2946                     "ru"
2947                 }, {
2948                     "und_RW",
2949                     "rw_Latn_RW",
2950                     "rw"
2951                 }, {
2952                     "und_SA",
2953                     "ar_Arab_SA",
2954                     "ar_SA"
2955                 }, {
2956                     "und_SD",
2957                     "ar_Arab_SD",
2958                     "ar_SD"
2959                 }, {
2960                     "und_SE",
2961                     "sv_Latn_SE",
2962                     "sv"
2963                 }, {
2964                     "und_SG",
2965                     "en_Latn_SG",
2966                     "en_SG"
2967                 }, {
2968                     "und_SI",
2969                     "sl_Latn_SI",
2970                     "sl"
2971                 }, {
2972                     "und_SJ",
2973                     "nb_Latn_SJ",
2974                     "nb_SJ"
2975                 }, {
2976                     "und_SK",
2977                     "sk_Latn_SK",
2978                     "sk"
2979                 }, {
2980                     "und_SM",
2981                     "it_Latn_SM",
2982                     "it_SM"
2983                 }, {
2984                     "und_SN",
2985                     "fr_Latn_SN",
2986                     "fr_SN"
2987                 }, {
2988                     "und_SO",
2989                     "so_Latn_SO",
2990                     "so"
2991                 }, {
2992                     "und_SR",
2993                     "nl_Latn_SR",
2994                     "nl_SR"
2995                 }, {
2996                     "und_ST",
2997                     "pt_Latn_ST",
2998                     "pt_ST"
2999                 }, {
3000                     "und_SV",
3001                     "es_Latn_SV",
3002                     "es_SV"
3003                 }, {
3004                     "und_SY",
3005                     "ar_Arab_SY",
3006                     "ar_SY"
3007                 }, {
3008                     "und_Sinh",
3009                     "si_Sinh_LK",
3010                     "si"
3011                 }, {
3012                     "und_Syrc",
3013                     "syr_Syrc_IQ",
3014                     "syr"
3015                 }, {
3016                     "und_TD",
3017                     "fr_Latn_TD",
3018                     "fr_TD"
3019                 }, {
3020                     "und_TG",
3021                     "fr_Latn_TG",
3022                     "fr_TG"
3023                 }, {
3024                     "und_TH",
3025                     "th_Thai_TH",
3026                     "th"
3027                 }, {
3028                     "und_TJ",
3029                     "tg_Cyrl_TJ",
3030                     "tg"
3031                 }, {
3032                     "und_TK",
3033                     "tkl_Latn_TK",
3034                     "tkl"
3035                 }, {
3036                     "und_TL",
3037                     "pt_Latn_TL",
3038                     "pt_TL"
3039                 }, {
3040                     "und_TM",
3041                     "tk_Latn_TM",
3042                     "tk"
3043                 }, {
3044                     "und_TN",
3045                     "ar_Arab_TN",
3046                     "ar_TN"
3047                 }, {
3048                     "und_TO",
3049                     "to_Latn_TO",
3050                     "to"
3051                 }, {
3052                     "und_TR",
3053                     "tr_Latn_TR",
3054                     "tr"
3055                 }, {
3056                     "und_TV",
3057                     "tvl_Latn_TV",
3058                     "tvl"
3059                 }, {
3060                     "und_TW",
3061                     "zh_Hant_TW",
3062                     "zh_TW"
3063                 }, {
3064                     "und_Taml",
3065                     "ta_Taml_IN",
3066                     "ta"
3067                 }, {
3068                     "und_Telu",
3069                     "te_Telu_IN",
3070                     "te"
3071                 }, {
3072                     "und_Thaa",
3073                     "dv_Thaa_MV",
3074                     "dv"
3075                 }, {
3076                     "und_Thai",
3077                     "th_Thai_TH",
3078                     "th"
3079                 }, {
3080                     "und_Tibt",
3081                     "bo_Tibt_CN",
3082                     "bo"
3083                 }, {
3084                     "und_UA",
3085                     "uk_Cyrl_UA",
3086                     "uk"
3087                 }, {
3088                     "und_UY",
3089                     "es_Latn_UY",
3090                     "es_UY"
3091                 }, {
3092                     "und_UZ",
3093                     "uz_Latn_UZ",
3094                     "uz"
3095                 }, {
3096                     "und_VA",
3097                     "la_Latn_VA",
3098                     "la"
3099                 }, {
3100                     "und_VE",
3101                     "es_Latn_VE",
3102                     "es_VE"
3103                 }, {
3104                     "und_VN",
3105                     "vi_Latn_VN",
3106                     "vi"
3107                 }, {
3108                     "und_VU",
3109                     "bi_Latn_VU",
3110                     "bi"
3111                 }, {
3112                     "und_WF",
3113                     "fr_Latn_WF",
3114                     "fr_WF"
3115                 }, {
3116                     "und_WS",
3117                     "sm_Latn_WS",
3118                     "sm"
3119                 }, {
3120                     "und_YE",
3121                     "ar_Arab_YE",
3122                     "ar_YE"
3123                 }, {
3124                     "und_YT",
3125                     "fr_Latn_YT",
3126                     "fr_YT"
3127                 }, {
3128                     "und_Yiii",
3129                     "ii_Yiii_CN",
3130                     "ii"
3131                 }, {
3132                     "ur",
3133                     "ur_Arab_PK",
3134                     "ur"
3135                 }, {
3136                     "uz",
3137                     "uz_Latn_UZ",
3138                     "uz"
3139                 }, {
3140                     "uz_AF",
3141                     "uz_Arab_AF",
3142                     "uz_AF"
3143                 }, {
3144                     "uz_Arab",
3145                     "uz_Arab_AF",
3146                     "uz_AF"
3147                 }, {
3148                     "ve",
3149                     "ve_Latn_ZA",
3150                     "ve"
3151                 }, {
3152                     "vi",
3153                     "vi_Latn_VN",
3154                     "vi"
3155                 }, {
3156                     "wal",
3157                     "wal_Ethi_ET",
3158                     "wal"
3159                 }, {
3160                     "wo",
3161                     "wo_Latn_SN",
3162                     "wo"
3163                 }, {
3164                     "wo_SN",
3165                     "wo_Latn_SN",
3166                     "wo"
3167                 }, {
3168                     "xh",
3169                     "xh_Latn_ZA",
3170                     "xh"
3171                 }, {
3172                     "yo",
3173                     "yo_Latn_NG",
3174                     "yo"
3175                 }, {
3176                     "zh",
3177                     "zh_Hans_CN",
3178                     "zh"
3179                 }, {
3180                     "zh_HK",
3181                     "zh_Hant_HK",
3182                     "zh_HK"
3183                 }, {
3184                     "zh_Hani",
3185                     "zh_Hani_CN",
3186                     "zh_Hani"
3187                 }, {
3188                     "zh_Hant",
3189                     "zh_Hant_TW",
3190                     "zh_TW"
3191                 }, {
3192                     "zh_MO",
3193                     "zh_Hant_MO",
3194                     "zh_MO"
3195                 }, {
3196                     "zh_TW",
3197                     "zh_Hant_TW",
3198                     "zh_TW"
3199                 }, {
3200                     "zu",
3201                     "zu_Latn_ZA",
3202                     "zu"
3203                 }, {
3204                     "und",
3205                     "en_Latn_US",
3206                     "en"
3207                 }, {
3208                     "und_ZZ",
3209                     "en_Latn_US",
3210                     "en"
3211                 }, {
3212                     "und_CN",
3213                     "zh_Hans_CN",
3214                     "zh"
3215                 }, {
3216                     "und_TW",
3217                     "zh_Hant_TW",
3218                     "zh_TW"
3219                 }, {
3220                     "und_HK",
3221                     "zh_Hant_HK",
3222                     "zh_HK"
3223                 }, {
3224                     "und_AQ",
3225                     "und_Latn_AQ",
3226                     "und_AQ"
3227                 }, {
3228                     "und_Zzzz",
3229                     "en_Latn_US",
3230                     "en"
3231                 }, {
3232                     "und_Zzzz_ZZ",
3233                     "en_Latn_US",
3234                     "en"
3235                 }, {
3236                     "und_Zzzz_CN",
3237                     "zh_Hans_CN",
3238                     "zh"
3239                 }, {
3240                     "und_Zzzz_TW",
3241                     "zh_Hant_TW",
3242                     "zh_TW"
3243                 }, {
3244                     "und_Zzzz_HK",
3245                     "zh_Hant_HK",
3246                     "zh_HK"
3247                 }, {
3248                     "und_Zzzz_AQ",
3249                     "und_Latn_AQ",
3250                     "und_AQ"
3251                 }, {
3252                     "und_Latn",
3253                     "en_Latn_US",
3254                     "en"
3255                 }, {
3256                     "und_Latn_ZZ",
3257                     "en_Latn_US",
3258                     "en"
3259                 }, {
3260                     "und_Latn_CN",
3261                     "za_Latn_CN",
3262                     "za"
3263                 }, {
3264                     "und_Latn_TW",
3265                     "trv_Latn_TW",
3266                     "trv"
3267                 }, {
3268                     "und_Latn_HK",
3269                     "zh_Latn_HK",
3270                     "zh_Latn_HK"
3271                 }, {
3272                     "und_Latn_AQ",
3273                     "und_Latn_AQ",
3274                     "und_AQ"
3275                 }, {
3276                     "und_Hans",
3277                     "zh_Hans_CN",
3278                     "zh"
3279                 }, {
3280                     "und_Hans_ZZ",
3281                     "zh_Hans_CN",
3282                     "zh"
3283                 }, {
3284                     "und_Hans_CN",
3285                     "zh_Hans_CN",
3286                     "zh"
3287                 }, {
3288                     "und_Hans_TW",
3289                     "zh_Hans_TW",
3290                     "zh_Hans_TW"
3291                 }, {
3292                     "und_Hans_HK",
3293                     "zh_Hans_HK",
3294                     "zh_Hans_HK"
3295                 }, {
3296                     "und_Hans_AQ",
3297                     "zh_Hans_AQ",
3298                     "zh_AQ"
3299                 }, {
3300                     "und_Hant",
3301                     "zh_Hant_TW",
3302                     "zh_TW"
3303                 }, {
3304                     "und_Hant_ZZ",
3305                     "zh_Hant_TW",
3306                     "zh_TW"
3307                 }, {
3308                     "und_Hant_CN",
3309                     "zh_Hant_CN",
3310                     "zh_Hant_CN"
3311                 }, {
3312                     "und_Hant_TW",
3313                     "zh_Hant_TW",
3314                     "zh_TW"
3315                 }, {
3316                     "und_Hant_HK",
3317                     "zh_Hant_HK",
3318                     "zh_HK"
3319                 }, {
3320                     "und_Hant_AQ",
3321                     "zh_Hant_AQ",
3322                     "zh_Hant_AQ"
3323                 }, {
3324                     "und_Moon",
3325                     "en_Moon_US",
3326                     "en_Moon"
3327                 }, {
3328                     "und_Moon_ZZ",
3329                     "en_Moon_US",
3330                     "en_Moon"
3331                 }, {
3332                     "und_Moon_CN",
3333                     "zh_Moon_CN",
3334                     "zh_Moon"
3335                 }, {
3336                     "und_Moon_TW",
3337                     "zh_Moon_TW",
3338                     "zh_Moon_TW"
3339                 }, {
3340                     "und_Moon_HK",
3341                     "zh_Moon_HK",
3342                     "zh_Moon_HK"
3343                 }, {
3344                     "und_Moon_AQ",
3345                     "und_Moon_AQ",
3346                     "und_Moon_AQ"
3347                 }, {
3348                     "es",
3349                     "es_Latn_ES",
3350                     "es"
3351                 }, {
3352                     "es_ZZ",
3353                     "es_Latn_ES",
3354                     "es"
3355                 }, {
3356                     "es_CN",
3357                     "es_Latn_CN",
3358                     "es_CN"
3359                 }, {
3360                     "es_TW",
3361                     "es_Latn_TW",
3362                     "es_TW"
3363                 }, {
3364                     "es_HK",
3365                     "es_Latn_HK",
3366                     "es_HK"
3367                 }, {
3368                     "es_AQ",
3369                     "es_Latn_AQ",
3370                     "es_AQ"
3371                 }, {
3372                     "es_Zzzz",
3373                     "es_Latn_ES",
3374                     "es"
3375                 }, {
3376                     "es_Zzzz_ZZ",
3377                     "es_Latn_ES",
3378                     "es"
3379                 }, {
3380                     "es_Zzzz_CN",
3381                     "es_Latn_CN",
3382                     "es_CN"
3383                 }, {
3384                     "es_Zzzz_TW",
3385                     "es_Latn_TW",
3386                     "es_TW"
3387                 }, {
3388                     "es_Zzzz_HK",
3389                     "es_Latn_HK",
3390                     "es_HK"
3391                 }, {
3392                     "es_Zzzz_AQ",
3393                     "es_Latn_AQ",
3394                     "es_AQ"
3395                 }, {
3396                     "es_Latn",
3397                     "es_Latn_ES",
3398                     "es"
3399                 }, {
3400                     "es_Latn_ZZ",
3401                     "es_Latn_ES",
3402                     "es"
3403                 }, {
3404                     "es_Latn_CN",
3405                     "es_Latn_CN",
3406                     "es_CN"
3407                 }, {
3408                     "es_Latn_TW",
3409                     "es_Latn_TW",
3410                     "es_TW"
3411                 }, {
3412                     "es_Latn_HK",
3413                     "es_Latn_HK",
3414                     "es_HK"
3415                 }, {
3416                     "es_Latn_AQ",
3417                     "es_Latn_AQ",
3418                     "es_AQ"
3419                 }, {
3420                     "es_Hans",
3421                     "es_Hans_ES",
3422                     "es_Hans"
3423                 }, {
3424                     "es_Hans_ZZ",
3425                     "es_Hans_ES",
3426                     "es_Hans"
3427                 }, {
3428                     "es_Hans_CN",
3429                     "es_Hans_CN",
3430                     "es_Hans_CN"
3431                 }, {
3432                     "es_Hans_TW",
3433                     "es_Hans_TW",
3434                     "es_Hans_TW"
3435                 }, {
3436                     "es_Hans_HK",
3437                     "es_Hans_HK",
3438                     "es_Hans_HK"
3439                 }, {
3440                     "es_Hans_AQ",
3441                     "es_Hans_AQ",
3442                     "es_Hans_AQ"
3443                 }, {
3444                     "es_Hant",
3445                     "es_Hant_ES",
3446                     "es_Hant"
3447                 }, {
3448                     "es_Hant_ZZ",
3449                     "es_Hant_ES",
3450                     "es_Hant"
3451                 }, {
3452                     "es_Hant_CN",
3453                     "es_Hant_CN",
3454                     "es_Hant_CN"
3455                 }, {
3456                     "es_Hant_TW",
3457                     "es_Hant_TW",
3458                     "es_Hant_TW"
3459                 }, {
3460                     "es_Hant_HK",
3461                     "es_Hant_HK",
3462                     "es_Hant_HK"
3463                 }, {
3464                     "es_Hant_AQ",
3465                     "es_Hant_AQ",
3466                     "es_Hant_AQ"
3467                 }, {
3468                     "es_Moon",
3469                     "es_Moon_ES",
3470                     "es_Moon"
3471                 }, {
3472                     "es_Moon_ZZ",
3473                     "es_Moon_ES",
3474                     "es_Moon"
3475                 }, {
3476                     "es_Moon_CN",
3477                     "es_Moon_CN",
3478                     "es_Moon_CN"
3479                 }, {
3480                     "es_Moon_TW",
3481                     "es_Moon_TW",
3482                     "es_Moon_TW"
3483                 }, {
3484                     "es_Moon_HK",
3485                     "es_Moon_HK",
3486                     "es_Moon_HK"
3487                 }, {
3488                     "es_Moon_AQ",
3489                     "es_Moon_AQ",
3490                     "es_Moon_AQ"
3491                 }, {
3492                     "zh",
3493                     "zh_Hans_CN",
3494                     "zh"
3495                 }, {
3496                     "zh_ZZ",
3497                     "zh_Hans_CN",
3498                     "zh"
3499                 }, {
3500                     "zh_CN",
3501                     "zh_Hans_CN",
3502                     "zh"
3503                 }, {
3504                     "zh_TW",
3505                     "zh_Hant_TW",
3506                     "zh_TW"
3507                 }, {
3508                     "zh_HK",
3509                     "zh_Hant_HK",
3510                     "zh_HK"
3511                 }, {
3512                     "zh_AQ",
3513                     "zh_Hans_AQ",
3514                     "zh_AQ"
3515                 }, {
3516                     "zh_Zzzz",
3517                     "zh_Hans_CN",
3518                     "zh"
3519                 }, {
3520                     "zh_Zzzz_ZZ",
3521                     "zh_Hans_CN",
3522                     "zh"
3523                 }, {
3524                     "zh_Zzzz_CN",
3525                     "zh_Hans_CN",
3526                     "zh"
3527                 }, {
3528                     "zh_Zzzz_TW",
3529                     "zh_Hant_TW",
3530                     "zh_TW"
3531                 }, {
3532                     "zh_Zzzz_HK",
3533                     "zh_Hant_HK",
3534                     "zh_HK"
3535                 }, {
3536                     "zh_Zzzz_AQ",
3537                     "zh_Hans_AQ",
3538                     "zh_AQ"
3539                 }, {
3540                     "zh_Latn",
3541                     "zh_Latn_CN",
3542                     "zh_Latn"
3543                 }, {
3544                     "zh_Latn_ZZ",
3545                     "zh_Latn_CN",
3546                     "zh_Latn"
3547                 }, {
3548                     "zh_Latn_CN",
3549                     "zh_Latn_CN",
3550                     "zh_Latn"
3551                 }, {
3552                     "zh_Latn_TW",
3553                     "zh_Latn_TW",
3554                     "zh_Latn_TW"
3555                 }, {
3556                     "zh_Latn_HK",
3557                     "zh_Latn_HK",
3558                     "zh_Latn_HK"
3559                 }, {
3560                     "zh_Latn_AQ",
3561                     "zh_Latn_AQ",
3562                     "zh_Latn_AQ"
3563                 }, {
3564                     "zh_Hans",
3565                     "zh_Hans_CN",
3566                     "zh"
3567                 }, {
3568                     "zh_Hans_ZZ",
3569                     "zh_Hans_CN",
3570                     "zh"
3571                 }, {
3572                     "zh_Hans_TW",
3573                     "zh_Hans_TW",
3574                     "zh_Hans_TW"
3575                 }, {
3576                     "zh_Hans_HK",
3577                     "zh_Hans_HK",
3578                     "zh_Hans_HK"
3579                 }, {
3580                     "zh_Hans_AQ",
3581                     "zh_Hans_AQ",
3582                     "zh_AQ"
3583                 }, {
3584                     "zh_Hant",
3585                     "zh_Hant_TW",
3586                     "zh_TW"
3587                 }, {
3588                     "zh_Hant_ZZ",
3589                     "zh_Hant_TW",
3590                     "zh_TW"
3591                 }, {
3592                     "zh_Hant_CN",
3593                     "zh_Hant_CN",
3594                     "zh_Hant_CN"
3595                 }, {
3596                     "zh_Hant_AQ",
3597                     "zh_Hant_AQ",
3598                     "zh_Hant_AQ"
3599                 }, {
3600                     "zh_Moon",
3601                     "zh_Moon_CN",
3602                     "zh_Moon"
3603                 }, {
3604                     "zh_Moon_ZZ",
3605                     "zh_Moon_CN",
3606                     "zh_Moon"
3607                 }, {
3608                     "zh_Moon_CN",
3609                     "zh_Moon_CN",
3610                     "zh_Moon"
3611                 }, {
3612                     "zh_Moon_TW",
3613                     "zh_Moon_TW",
3614                     "zh_Moon_TW"
3615                 }, {
3616                     "zh_Moon_HK",
3617                     "zh_Moon_HK",
3618                     "zh_Moon_HK"
3619                 }, {
3620                     "zh_Moon_AQ",
3621                     "zh_Moon_AQ",
3622                     "zh_Moon_AQ"
3623                 }, {
3624                     "art",
3625                     "",
3626                     ""
3627                 }, {
3628                     "art_ZZ",
3629                     "",
3630                     ""
3631                 }, {
3632                     "art_CN",
3633                     "",
3634                     ""
3635                 }, {
3636                     "art_TW",
3637                     "",
3638                     ""
3639                 }, {
3640                     "art_HK",
3641                     "",
3642                     ""
3643                 }, {
3644                     "art_AQ",
3645                     "",
3646                     ""
3647                 }, {
3648                     "art_Zzzz",
3649                     "",
3650                     ""
3651                 }, {
3652                     "art_Zzzz_ZZ",
3653                     "",
3654                     ""
3655                 }, {
3656                     "art_Zzzz_CN",
3657                     "",
3658                     ""
3659                 }, {
3660                     "art_Zzzz_TW",
3661                     "",
3662                     ""
3663                 }, {
3664                     "art_Zzzz_HK",
3665                     "",
3666                     ""
3667                 }, {
3668                     "art_Zzzz_AQ",
3669                     "",
3670                     ""
3671                 }, {
3672                     "art_Latn",
3673                     "",
3674                     ""
3675                 }, {
3676                     "art_Latn_ZZ",
3677                     "",
3678                     ""
3679                 }, {
3680                     "art_Latn_CN",
3681                     "",
3682                     ""
3683                 }, {
3684                     "art_Latn_TW",
3685                     "",
3686                     ""
3687                 }, {
3688                     "art_Latn_HK",
3689                     "",
3690                     ""
3691                 }, {
3692                     "art_Latn_AQ",
3693                     "",
3694                     ""
3695                 }, {
3696                     "art_Hans",
3697                     "",
3698                     ""
3699                 }, {
3700                     "art_Hans_ZZ",
3701                     "",
3702                     ""
3703                 }, {
3704                     "art_Hans_CN",
3705                     "",
3706                     ""
3707                 }, {
3708                     "art_Hans_TW",
3709                     "",
3710                     ""
3711                 }, {
3712                     "art_Hans_HK",
3713                     "",
3714                     ""
3715                 }, {
3716                     "art_Hans_AQ",
3717                     "",
3718                     ""
3719                 }, {
3720                     "art_Hant",
3721                     "",
3722                     ""
3723                 }, {
3724                     "art_Hant_ZZ",
3725                     "",
3726                     ""
3727                 }, {
3728                     "art_Hant_CN",
3729                     "",
3730                     ""
3731                 }, {
3732                     "art_Hant_TW",
3733                     "",
3734                     ""
3735                 }, {
3736                     "art_Hant_HK",
3737                     "",
3738                     ""
3739                 }, {
3740                     "art_Hant_AQ",
3741                     "",
3742                     ""
3743                 }, {
3744                     "art_Moon",
3745                     "",
3746                     ""
3747                 }, {
3748                     "art_Moon_ZZ",
3749                     "",
3750                     ""
3751                 }, {
3752                     "art_Moon_CN",
3753                     "",
3754                     ""
3755                 }, {
3756                     "art_Moon_TW",
3757                     "",
3758                     ""
3759                 }, {
3760                     "art_Moon_HK",
3761                     "",
3762                     ""
3763                 }, {
3764                     "art_Moon_AQ",
3765                     "",
3766                     ""
3767                 }
3768         };
3769
3770         for (int i = 0; i < full_data.length; i++) {
3771             ULocale org = new ULocale(full_data[i][0]);
3772             ULocale res = ULocale.addLikelySubtags(org);
3773             String exp = full_data[i][1];
3774             if (exp.length() == 0) {
3775                 if (!org.equals(res)) {
3776                     errln("Original: " + full_data[i][0] + " expected: " + exp + " - but got " + res.toString());
3777                 }
3778             }
3779             else if (!res.toString().equals(exp)) {
3780                 errln("Original: " + full_data[i][0] + " expected: " + exp + " - but got " + res.toString());
3781             }
3782         }
3783
3784         for (int i = 0; i < full_data.length; i++) {
3785             String maximal = full_data[i][1];
3786
3787             if (maximal.length() > 0) {
3788                 ULocale org = new ULocale(maximal);
3789                 ULocale res = ULocale.minimizeSubtags(org);
3790                 String exp = full_data[i][2];
3791                 if (exp.length() == 0) {
3792                     if (!org.equals(res)) {
3793                         errln("Original: " + full_data[i][1] + " expected: " + exp + " - but got " + res.toString());
3794                     }
3795                 }
3796                 else if (!res.toString().equals(exp)) {
3797                     errln("Original: " + full_data[i][1] + " expected: " + exp + " - but got " + res.toString());
3798                 }
3799             }
3800         }
3801     }
3802     public void TestCLDRVersion() {
3803         //VersionInfo zeroVersion = VersionInfo.getInstance(0, 0, 0, 0);
3804         VersionInfo testExpect;
3805         VersionInfo testCurrent;
3806         VersionInfo cldrVersion;
3807
3808         cldrVersion = LocaleData.getCLDRVersion();
3809
3810         this.logln("uloc_getCLDRVersion() returned: '"+cldrVersion+"'");
3811
3812         // why isn't this public for tests somewhere?
3813         final ClassLoader testLoader = ICUResourceBundleTest.class.getClassLoader();
3814         UResourceBundle bundle = (UResourceBundle) UResourceBundle.getBundleInstance("com/ibm/icu/dev/data/testdata", ULocale.ROOT, testLoader);
3815
3816         testExpect = VersionInfo.getInstance(bundle.getString("ExpectCLDRVersionAtLeast"));
3817         testCurrent = VersionInfo.getInstance(bundle.getString("CurrentCLDRVersion"));
3818
3819
3820         logln("(data) ExpectCLDRVersionAtLeast { "+testExpect+""); 
3821         if(cldrVersion.compareTo(testExpect)<0) {
3822             errln("CLDR version is too old, expect at least "+testExpect+".");
3823         }
3824
3825         int r = cldrVersion.compareTo(testCurrent);
3826         if ( r < 0 ) {
3827             logln("CLDR version is behind 'current' (for testdata/root.txt) "+testCurrent+". Some things may fail.\n");
3828         } else if ( r > 0) {
3829             logln("CLDR version is ahead of 'current' (for testdata/root.txt) "+testCurrent+". Some things may fail.\n");
3830         } else {
3831             // CLDR version is OK.
3832         }
3833     }
3834
3835     public void TestToLanguageTag() {
3836         final String[][] locale_to_langtag = {
3837                 {"",            "und"},
3838                 {"en",          "en"},
3839                 {"en_US",       "en-US"},
3840                 {"iw_IL",       "he-IL"},
3841                 {"sr_Latn_SR",  "sr-Latn-SR"},
3842                 {"en_US_POSIX@ca=japanese", "en-US-u-ca-japanese-va-posix"},
3843                 {"en__POSIX",   "en-u-va-posix"},
3844                 {"en_US_POSIX_VAR", "en-US-posix-x-lvariant-var"},  // variant POSIX_VAR is processed as regular variant
3845                 {"en_US_VAR_POSIX", "en-US-x-lvariant-var-posix"},  // variant VAR_POSIX is processed as regular variant
3846                 {"en_US_POSIX@va=posix2",   "en-US-u-va-posix2"},   // if keyword va=xxx already exists, variant POSIX is simply dropped
3847                 {"und_555",     "und-555"},
3848                 {"123",         "und"},
3849                 {"%$#&",        "und"},
3850                 {"_Latn",       "und-Latn"},
3851                 {"_DE",         "und-DE"},
3852                 {"und_FR",      "und-FR"},
3853                 {"th_TH_TH",    "th-TH-x-lvariant-th"},
3854                 {"bogus",       "bogus"},
3855                 {"foooobarrr",  "und"},
3856                 {"aa_BB_CYRL",  "aa-BB-x-lvariant-cyrl"},
3857                 {"en_US_1234",  "en-US-1234"},
3858                 {"en_US_VARIANTA_VARIANTB", "en-US-varianta-variantb"},
3859                 {"en_US_VARIANTB_VARIANTA", "en-US-variantb-varianta"},
3860                 {"ja__9876_5432",   "ja-9876-5432"},
3861                 {"zh_Hant__VAR",    "zh-Hant-x-lvariant-var"},
3862                 {"es__BADVARIANT_GOODVAR",  "es"},
3863                 {"es__GOODVAR_BAD_BADVARIANT",  "es-goodvar-x-lvariant-bad"},
3864                 {"en@calendar=gregorian",   "en-u-ca-gregory"},
3865                 {"de@collation=phonebook;calendar=gregorian",   "de-u-ca-gregory-co-phonebk"},
3866                 {"th@numbers=thai;z=extz;x=priv-use;a=exta",   "th-a-exta-u-nu-thai-z-extz-x-priv-use"},
3867                 {"en@timezone=America/New_York;calendar=japanese",    "en-u-ca-japanese-tz-usnyc"},
3868                 {"en@timezone=US/Eastern",    "en-u-tz-usnyc"},
3869                 {"en@x=x-y-z;a=a-b-c",  "en-x-x-y-z"},
3870                 {"it@collation=badcollationtype;colStrength=identical;cu=usd-eur", "it-u-ks-identic"},
3871                 {"en_US_POSIX", "en-US-u-va-posix"},
3872                 {"en_US_POSIX@calendar=japanese;currency=EUR","en-US-u-ca-japanese-cu-eur-va-posix"},
3873                 {"@x=elmer",    "x-elmer"},
3874                 {"_US@x=elmer", "und-US-x-elmer"},
3875         };
3876
3877         for (int i = 0; i < locale_to_langtag.length; i++) {
3878             ULocale loc = new ULocale(locale_to_langtag[i][0]);
3879             String langtag = loc.toLanguageTag();
3880             if (!langtag.equals(locale_to_langtag[i][1])) {
3881                 errln("FAIL: toLanguageTag returned language tag [" + langtag + "] for locale ["
3882                         + loc + "] - expected: [" + locale_to_langtag[i][1] + "]");
3883             }
3884         }
3885     }
3886
3887     public void TestForLanguageTag() {
3888         final Integer NOERROR = Integer.valueOf(-1);
3889
3890         final Object[][] langtag_to_locale = {
3891                 {"en",                  "en",                   NOERROR},
3892                 {"en-us",               "en_US",                NOERROR},
3893                 {"und-us",              "_US",                  NOERROR},
3894                 {"und-latn",            "_Latn",                NOERROR},
3895                 {"en-us-posix",         "en_US_POSIX",          NOERROR},
3896                 {"de-de_euro",          "de",                   Integer.valueOf(3)},
3897                 {"kok-in",              "kok_IN",               NOERROR},
3898                 {"123",                 "",                     Integer.valueOf(0)},
3899                 {"en_us",               "",                     Integer.valueOf(0)},
3900                 {"en-latn-x",           "en_Latn",              Integer.valueOf(8)},
3901                 {"art-lojban",          "jbo",                  NOERROR},
3902                 {"zh-hakka",            "hak",                  NOERROR},
3903                 {"zh-cmn-CH",           "cmn_CH",               NOERROR},
3904                 {"xxx-yy",              "xxx_YY",               NOERROR},
3905                 {"fr-234",              "fr_234",               NOERROR},
3906                 {"i-default",           "en@x=i-default",       NOERROR},
3907                 {"i-test",              "",                     Integer.valueOf(0)},
3908                 {"ja-jp-jp",            "ja_JP",                Integer.valueOf(6)},
3909                 {"bogus",               "bogus",                NOERROR},
3910                 {"boguslang",           "",                     Integer.valueOf(0)},
3911                 {"EN-lATN-us",          "en_Latn_US",           NOERROR},
3912                 {"und-variant-1234",    "__VARIANT_1234",       NOERROR},
3913                 {"und-varzero-var1-vartwo", "__VARZERO",        Integer.valueOf(12)},
3914                 {"en-u-ca-gregory",     "en@calendar=gregorian",    NOERROR},
3915                 {"en-U-cu-USD",         "en@currency=usd",      NOERROR},
3916                 {"en-us-u-va-posix",    "en_US_POSIX",          NOERROR},
3917                 {"en-us-u-ca-gregory-va-posix", "en_US_POSIX@calendar=gregorian",   NOERROR},
3918                 {"en-us-posix-u-va-posix",  "en_US_POSIX@va=posix", NOERROR},
3919                 {"en-us-u-va-posix2",   "en_US@va=posix2",      NOERROR},
3920                 {"en-us-vari1-u-va-posix",   "en_US_VARI1@va=posix",  NOERROR},
3921                 {"ar-x-1-2-3",          "ar@x=1-2-3",           NOERROR},
3922                 {"fr-u-nu-latn-cu-eur", "fr@currency=eur;numbers=latn", NOERROR},
3923                 {"de-k-kext-u-co-phonebk-nu-latn",  "de@collation=phonebook;k=kext;numbers=latn",   NOERROR},
3924                 {"ja-u-cu-jpy-ca-jp",   "ja@calendar=yes;currency=jpy;jp=yes",  NOERROR},
3925                 {"en-us-u-tz-usnyc",    "en_US@timezone=America/New_York",      NOERROR},
3926                 {"und-a-abc-def",       "@a=abc-def",           NOERROR},
3927                 {"zh-u-ca-chinese-x-u-ca-chinese",  "zh@calendar=chinese;x=u-ca-chinese",   NOERROR},
3928                 {"fr--FR",              "fr",                   Integer.valueOf(3)},
3929                 {"fr-",                 "fr",                   Integer.valueOf(3)},
3930                 {"x-elmer",             "@x=elmer",             NOERROR},
3931                 {"en-US-u-attr1-attr2-ca-gregory", "en_US@attribute=attr1-attr2;calendar=gregorian",    NOERROR},
3932                 {"sr-u-kn",             "sr@colnumeric=yes",    NOERROR},
3933                 {"de-u-kn-co-phonebk",  "de@collation=phonebook;colnumeric=yes",    NOERROR},
3934                 {"en-u-attr2-attr1-kn-kb",  "en@attribute=attr1-attr2;colbackwards=yes;colnumeric=yes", NOERROR},
3935                 {"ja-u-ijkl-efgh-abcd-ca-japanese-xx-yyy-zzz-kn",   "ja@attribute=abcd-efgh-ijkl;calendar=japanese;colnumeric=yes;xx=yyy-zzz",  NOERROR},
3936
3937                 {"de-u-xc-xphonebk-co-phonebk-ca-buddhist-mo-very-lo-extensi-xd-that-de-should-vc-probably-xz-killthebuffer",
3938                     "de@calendar=buddhist;collation=phonebook;de=should;lo=extensi;mo=very;vc=probably;xc=xphonebk;xd=that;xz=yes", Integer.valueOf(92)},
3939
3940         };
3941
3942         for (int i = 0; i < langtag_to_locale.length; i++) {
3943             String tag = (String)langtag_to_locale[i][0];
3944             ULocale expected = new ULocale((String)langtag_to_locale[i][1]);
3945             ULocale loc = ULocale.forLanguageTag(tag);
3946
3947             if (!loc.equals(expected)) {
3948                 errln("FAIL: forLanguageTag returned locale [" + loc + "] for language tag [" + tag
3949                         + "] - expected: [" + expected + "]");
3950             }
3951         }
3952
3953         // Use locale builder to check errors
3954         for (int i = 0; i < langtag_to_locale.length; i++) {
3955             String tag = (String)langtag_to_locale[i][0];
3956             ULocale expected = new ULocale((String)langtag_to_locale[i][1]);
3957             int errorIdx = ((Integer)langtag_to_locale[i][2]).intValue();
3958
3959             try {
3960                 Builder bld = new Builder();
3961                 bld.setLanguageTag(tag);
3962                 ULocale loc = bld.build();
3963
3964                 if (!loc.equals(expected)) {
3965                     errln("FAIL: forLanguageTag returned locale [" + loc + "] for language tag [" + tag
3966                             + "] - expected: [" + expected + "]");
3967                 }
3968                 if (errorIdx != NOERROR.intValue()) {
3969                     errln("FAIL: Builder.setLanguageTag should throw an exception for input tag [" + tag + "]");
3970                 }
3971             } catch (IllformedLocaleException ifle) {
3972                 if (ifle.getErrorIndex() != errorIdx) {
3973                     errln("FAIL: Builder.setLanguageTag returned error index " + ifle.getErrorIndex()
3974                             + " for input language tag [" + tag + "] expected: " + errorIdx);
3975                 }
3976             }
3977         }
3978     }
3979
3980     /*
3981      * Test that if you use any locale without keyword that you will get a NULL
3982      * string returned and not throw and exception.
3983      */
3984     public void Test4735()
3985     {
3986         try {
3987             new ULocale("und").getDisplayKeywordValue("calendar",ULocale.GERMAN);
3988             new ULocale("en").getDisplayKeywordValue("calendar",ULocale.GERMAN);
3989         } catch (Exception e) {
3990             errln("Unexpected exception: " + e.getMessage());
3991         }  
3992     }
3993
3994     public void TestGetFallback() {
3995         // Testing static String getFallback(String)
3996         final String[][] TESTIDS =
3997             {
3998                 {"en_US", "en", "", ""},    // ULocale.getFallback("") should return ""
3999                 {"EN_us_Var", "en_US", "en", ""},   // Case is always normalized
4000                 {"de_DE@collation=phonebook", "de@collation=phonebook", "@collation=phonebook", "@collation=phonebook"},    // Keyword is preserved
4001                 {"en__POSIX", "en", ""},    // Trailing empty segment should be truncated
4002                 {"_US_POSIX", "_US", ""},   // Same as above
4003                 {"root", ""},               // No canonicalization
4004             };
4005
4006         for (String[] chain : TESTIDS) {
4007             for (int i = 1; i < chain.length; i++) {
4008                 String fallback = ULocale.getFallback(chain[i-1]);
4009                 assertEquals("getFallback(\"" + chain[i-1] + "\")", chain[i], fallback);
4010             }
4011         }
4012
4013         // Testing ULocale getFallback()
4014         final ULocale[][] TESTLOCALES = 
4015             {
4016                 {new ULocale("en_US"), new ULocale("en"), ULocale.ROOT, null},
4017                 {new ULocale("en__POSIX"), new ULocale("en"), ULocale.ROOT, null},
4018                 {new ULocale("de_DE@collation=phonebook"), new ULocale("de@collation=phonebook"), new ULocale("@collation=phonebook"), null},
4019                 {new ULocale("_US_POSIX"), new ULocale("_US"), ULocale.ROOT, null},
4020                 {new ULocale("root"), ULocale.ROOT, null},
4021             };
4022
4023         for(ULocale[] chain : TESTLOCALES) {
4024             for (int i = 1; i < chain.length; i++) {
4025                 ULocale fallback = chain[i-1].getFallback();
4026                 assertEquals("ULocale(" + chain[i-1] + ").getFallback()", chain[i], fallback);
4027             }
4028         }
4029     }
4030
4031     public void TestExtension() {
4032         String[][] TESTCASES = {
4033                 // {"<langtag>", "<ext key1>", "<ext val1>", "<ext key2>", "<ext val2>", ....},
4034                 {"en"},
4035                 {"en-a-exta-b-extb", "a", "exta", "b", "extb"},
4036                 {"en-b-extb-a-exta", "a", "exta", "b", "extb"},
4037                 {"de-x-a-bc-def", "x", "a-bc-def"},
4038                 {"ja-JP-u-cu-jpy-ca-japanese-x-java", "u", "ca-japanese-cu-jpy", "x", "java"},
4039         };
4040
4041         for (String[] testcase : TESTCASES) {
4042             ULocale loc = ULocale.forLanguageTag(testcase[0]);
4043
4044             int nExtensions = (testcase.length - 1) / 2;
4045
4046             Set<Character> keys = loc.getExtensionKeys();
4047             if (keys.size() != nExtensions) {
4048                 errln("Incorrect number of extensions: returned="
4049                         + keys.size() + ", expected=" + nExtensions
4050                         + ", locale=" + testcase[0]);
4051             }
4052
4053             for (int i = 0; i < nExtensions; i++) {
4054                 String kstr = testcase[i/2 + 1];
4055                 String ext = loc.getExtension(Character.valueOf(kstr.charAt(0)));
4056                 if (ext == null || !ext.equals(testcase[i/2 + 2])) {
4057                     errln("Incorrect extension value: key=" 
4058                             + kstr + ", returned=" + ext + ", expected=" + testcase[i/2 + 2]
4059                                     + ", locale=" + testcase[0]);
4060                 }
4061             }
4062         }
4063
4064         // Exception handling
4065         boolean sawException = false;
4066         try {
4067             ULocale l = ULocale.forLanguageTag("en-US-a-exta");
4068             l.getExtension('$');
4069         } catch (IllegalArgumentException e) {
4070             sawException = true;
4071         }
4072         if (!sawException) {
4073             errln("getExtension must throw an exception on illegal input key");
4074         }
4075     }
4076
4077     public void TestUnicodeLocaleExtension() {
4078         String[][] TESTCASES = {
4079                 //"<langtag>", "<attr1>,<attr2>,...", "<key1>,<key2>,...", "<type1>", "<type2>", ...},
4080                 {"en", null, null},
4081                 {"en-a-ext1-x-privuse", null, null},
4082                 {"en-u-attr1-attr2", "attr1,attr2", null},
4083                 {"ja-u-ca-japanese-cu-jpy", null, "ca,cu", "japanese", "jpy"},
4084                 {"th-TH-u-number-attr-nu-thai-ca-buddhist", "attr,number", "ca,nu", "buddhist", "thai"},
4085         };
4086
4087         for (String[] testcase : TESTCASES) {
4088             ULocale loc = ULocale.forLanguageTag(testcase[0]);
4089
4090             Set<String> expectedAttributes = new HashSet<String>();
4091             if (testcase[1] != null) {
4092                 String[] attrs = testcase[1].split(",");
4093                 for (String s : attrs) {
4094                     expectedAttributes.add(s);
4095                 }
4096             }
4097
4098             Map<String, String> expectedKeywords = new HashMap<String, String>();
4099             if (testcase[2] != null) {
4100                 String[] ukeys = testcase[2].split(",");
4101                 for (int i = 0; i < ukeys.length; i++) {
4102                     expectedKeywords.put(ukeys[i], testcase[i + 3]);
4103                 }
4104             }
4105
4106             // Check attributes
4107             Set<String> attributes = loc.getUnicodeLocaleAttributes();
4108             if (attributes.size() != expectedAttributes.size()) {
4109                 errln("Incorrect number for Unicode locale attributes: returned=" 
4110                         + attributes.size() + ", expected=" + expectedAttributes.size()
4111                         + ", locale=" + testcase[0]);
4112             }
4113             if (!attributes.containsAll(expectedAttributes) || !expectedAttributes.containsAll(attributes)) {
4114                 errln("Incorrect set of attributes for locale " + testcase[0]);
4115             }
4116
4117             // Check keywords
4118             Set<String> keys = loc.getUnicodeLocaleKeys();
4119             Set<String> expectedKeys = expectedKeywords.keySet();
4120             if (keys.size() != expectedKeys.size()) {
4121                 errln("Incorrect number for Unicode locale keys: returned=" 
4122                         + keys.size() + ", expected=" + expectedKeys.size()
4123                         + ", locale=" + testcase[0]);
4124             }
4125
4126             for (String expKey : expectedKeys) {
4127                 String type = loc.getUnicodeLocaleType(expKey);
4128                 String expType = expectedKeywords.get(expKey);
4129
4130                 if (type == null || !expType.equals(type)) {
4131                     errln("Incorrect Unicode locale type: key=" 
4132                             + expKey + ", returned=" + type + ", expected=" + expType
4133                             + ", locale=" + testcase[0]);
4134                 }
4135             }
4136         }
4137
4138         // Exception handling
4139         boolean sawException = false;
4140         try {
4141             ULocale l = ULocale.forLanguageTag("en-US-u-ca-gregory");
4142             l.getUnicodeLocaleType("$%");
4143         } catch (IllegalArgumentException e) {
4144             sawException = true;
4145         }
4146         if (!sawException) {
4147             errln("getUnicodeLocaleType must throw an exception on illegal input key");
4148         }
4149     }
4150
4151     public void TestForLocale() {
4152         Object[][] DATA = {
4153                 {new Locale(""),                    ""},
4154                 {new Locale("en", "US"),            "en_US"},
4155                 {new Locale("en", "US", "POSIX"),   "en_US_POSIX"},
4156                 {new Locale("", "US"),              "_US"},
4157                 {new Locale("en", "", "POSIX"),     "en__POSIX"},
4158                 {new Locale("no", "NO", "NY"),      "nn_NO"},
4159                 {new Locale("en", "BOGUS"),         "en__BOGUS"}, // ill-formed country is mapped to variant - see #8383 and #8384
4160         };
4161
4162         for (int i = 0; i < DATA.length; i++) {
4163             ULocale uloc = ULocale.forLocale((Locale) DATA[i][0]);
4164             assertEquals("forLocale with " + DATA[i][0], DATA[i][1], uloc.getName());
4165         }
4166
4167         if (JAVA7_OR_LATER) {
4168             Object[][] DATA7 = {
4169                     {new Locale("ja", "JP", "JP"),      "ja_JP_JP@calendar=japanese"},
4170                     {new Locale("th", "TH", "TH"),      "th_TH_TH@numbers=thai"},
4171             };
4172             for (int i = 0; i < DATA7.length; i++) {
4173                 ULocale uloc = ULocale.forLocale((Locale) DATA7[i][0]);
4174                 assertEquals("forLocale with " + DATA7[i][0], DATA7[i][1], uloc.getName());
4175             }
4176
4177             try {
4178                 Method localeForLanguageTag = Locale.class.getMethod("forLanguageTag", String.class);
4179
4180                 String[][] DATA7EXT = {
4181                         {"en-Latn-US",                  "en_Latn_US"},
4182                         {"zh-Hant-TW",                  "zh_Hant_TW"},
4183                         {"und-US-u-cu-usd",             "_US@currency=usd"},
4184                         {"th-TH-u-ca-buddhist-nu-thai", "th_TH@calendar=buddhist;numbers=thai"},
4185                         {"en-US-u-va-POSIX",            "en_US_POSIX"},
4186                         {"de-DE-u-co-phonebk",          "de_DE@collation=phonebook"},
4187                         {"en-a-exta-b-extb-x-privu",    "en@a=exta;b=extb;x=privu"},
4188                         {"fr-u-attr1-attr2-cu-eur",     "fr@attribute=attr1-attr2;currency=eur"},
4189                 };
4190
4191                 for (int i = 0; i < DATA7EXT.length; i++) {
4192                     Locale loc = (Locale) localeForLanguageTag.invoke(null, DATA7EXT[i][0]);
4193                     ULocale uloc = ULocale.forLocale(loc);
4194                     assertEquals("forLocale with " + loc, DATA7EXT[i][1], uloc.getName());
4195                 }
4196             } catch (Exception e) {
4197                 throw new RuntimeException(e);
4198             }
4199
4200         } else {
4201             Object[][] DATA6 = {
4202                     {new Locale("ja", "JP", "JP"),      "ja_JP@calendar=japanese"},
4203                     {new Locale("th", "TH", "TH"),      "th_TH@numbers=thai"},
4204             };
4205             for (int i = 0; i < DATA6.length; i++) {
4206                 ULocale uloc = ULocale.forLocale((Locale) DATA6[i][0]);
4207                 assertEquals("forLocale with " + DATA6[i][0], DATA6[i][1], uloc.getName());
4208             }
4209         }
4210     }
4211
4212     public void TestToLocale() {
4213         Object[][] DATA = {
4214                 {"",                new Locale("")},
4215                 {"en_US",           new Locale("en", "US")},
4216                 {"_US",             new Locale("", "US")},
4217                 {"en__POSIX",       new Locale("en", "", "POSIX")},
4218         };
4219
4220         for (int i = 0; i < DATA.length; i++) {
4221             Locale loc = new ULocale((String) DATA[i][0]).toLocale();
4222             assertEquals("toLocale with " + DATA[i][0], DATA[i][1], loc);
4223         }
4224
4225         if (JAVA7_OR_LATER) {
4226             Object[][] DATA7 = {
4227                     {"nn_NO",                       new Locale("nn", "NO")},
4228                     {"no_NO_NY",                    new Locale("no", "NO", "NY")},
4229             };
4230             for (int i = 0; i < DATA7.length; i++) {
4231                 Locale loc = new ULocale((String) DATA7[i][0]).toLocale();
4232                 assertEquals("toLocale with " + DATA7[i][0], DATA7[i][1], loc);
4233             }
4234
4235             try {
4236                 Method localeForLanguageTag = Locale.class.getMethod("forLanguageTag", String.class);
4237
4238                 String[][] DATA7EXT = {
4239                         {"en_Latn_US",                  "en-Latn-US"},
4240                         {"zh_Hant_TW",                  "zh-Hant-TW"},
4241                         {"ja_JP@calendar=japanese",     "ja-JP-u-ca-japanese"},
4242                         {"ja_JP_JP@calendar=japanese",  "ja-JP-u-ca-japanese-x-lvariant-JP"},
4243                         {"th_TH@numbers=thai",          "th-TH-u-nu-thai"},
4244                         {"th_TH_TH@numbers=thai",       "th-TH-u-nu-thai-x-lvariant-TH"},
4245                         {"de@collation=phonebook",      "de-u-co-phonebk"},
4246                         {"en@a=exta;b=extb;x=privu",    "en-a-exta-b-extb-x-privu"},
4247                         {"fr@attribute=attr1-attr2;currency=eur",   "fr-u-attr1-attr2-cu-eur"},
4248                 };
4249
4250                 for (int i = 0; i < DATA7EXT.length; i++) {
4251                     Locale loc = new ULocale((String) DATA7EXT[i][0]).toLocale();
4252                     Locale expected = (Locale) localeForLanguageTag.invoke(null, DATA7EXT[i][1]);
4253                     assertEquals("toLocale with " + DATA7EXT[i][0], expected, loc);
4254                 }
4255             } catch (Exception e) {
4256                 throw new RuntimeException(e);
4257             }
4258
4259         } else {
4260             Object[][] DATA6 = {
4261                     {"nn_NO",                       new Locale("no", "NO", "NY")},
4262                     {"no_NO_NY",                    new Locale("no", "NO", "NY")},
4263                     {"ja_JP@calendar=japanese",     new Locale("ja", "JP", "JP")},
4264                     {"th_TH@numbers=thai",          new Locale("th", "TH", "TH")},
4265             };
4266             for (int i = 0; i < DATA6.length; i++) {
4267                 Locale loc = new ULocale((String) DATA6[i][0]).toLocale();
4268                 assertEquals("toLocale with " + DATA6[i][0], DATA6[i][1], loc);
4269             }
4270         }
4271     }
4272
4273     public void TestCategoryDefault() {
4274         Locale backupDefault = Locale.getDefault();
4275
4276         ULocale orgDefault = ULocale.getDefault();
4277
4278         // Setting a category default won't change default ULocale
4279         ULocale uJaJp = new ULocale("ja_JP");
4280         ULocale uDeDePhonebook = new ULocale("de_DE@collation=phonebook");
4281
4282         ULocale.setDefault(Category.DISPLAY, uJaJp);
4283         ULocale.setDefault(Category.FORMAT, uDeDePhonebook);
4284
4285         if (!ULocale.getDefault().equals(orgDefault)) {
4286             errln("FAIL: Default ULocale is " + ULocale.getDefault() + ", expected: " + orgDefault);
4287         }
4288
4289         if (!ULocale.getDefault(Category.DISPLAY).equals(uJaJp)) {
4290             errln("FAIL: DISPLAY ULocale is " + ULocale.getDefault(Category.DISPLAY) + ", expected: " + uJaJp);
4291         }
4292
4293         if (!ULocale.getDefault(Category.FORMAT).equals(uDeDePhonebook)) {
4294             errln("FAIL: FORMAT ULocale is " + ULocale.getDefault(Category.FORMAT) + ", expected: " + uDeDePhonebook);
4295         }
4296
4297         // Setting ULocale default will overrides category defaults
4298         ULocale uFrFr = new ULocale("fr_FR");
4299
4300         ULocale.setDefault(uFrFr);
4301
4302         if (!ULocale.getDefault(Category.DISPLAY).equals(uFrFr)) {
4303             errln("FAIL: DISPLAY ULocale is " + ULocale.getDefault(Category.DISPLAY) + ", expected: " + uFrFr);
4304         }
4305
4306         if (!ULocale.getDefault(Category.FORMAT).equals(uFrFr)) {
4307             errln("FAIL: FORMAT ULocale is " + ULocale.getDefault(Category.FORMAT) + ", expected: " + uFrFr);
4308         }
4309
4310         // Setting Locale default will updates ULocale default and category defaults
4311         Locale arEg = new Locale("ar", "EG");
4312         ULocale uArEg = ULocale.forLocale(arEg);
4313
4314         Locale.setDefault(arEg);
4315
4316         if (!ULocale.getDefault().equals(uArEg)) {
4317             errln("FAIL: Default ULocale is " + ULocale.getDefault() + ", expected: " + uArEg);
4318         }
4319
4320         if (!ULocale.getDefault(Category.DISPLAY).equals(uArEg)) {
4321             errln("FAIL: DISPLAY ULocale is " + ULocale.getDefault(Category.DISPLAY) + ", expected: " + uArEg);
4322         }
4323
4324         if (!ULocale.getDefault(Category.FORMAT).equals(uArEg)) {
4325             errln("FAIL: FORMAT ULocale is " + ULocale.getDefault(Category.FORMAT) + ", expected: " + uArEg);
4326         }
4327
4328         // Restore back up
4329         Locale.setDefault(backupDefault);
4330     }
4331 }