]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_8_1_1/main/tests/collate/src/com/ibm/icu/dev/test/util/LocaleAliasCollationTest.java
Added flags.
[Dictionary.git] / jars / icu4j-4_8_1_1 / main / tests / collate / src / com / ibm / icu / dev / test / util / LocaleAliasCollationTest.java
1 /*
2  *******************************************************************************
3  * Copyright (C) 2009, International Business Machines Corporation and         *
4  * others. All Rights Reserved.                                                *
5  *******************************************************************************
6  */
7
8 package com.ibm.icu.dev.test.util;
9
10 import java.util.HashMap;
11
12 import com.ibm.icu.text.Collator;
13 import com.ibm.icu.util.ULocale;
14
15 public class LocaleAliasCollationTest extends com.ibm.icu.dev.test.TestFmwk {
16     private static final ULocale[][] _LOCALES = {
17             {new ULocale("en", "RH"), new ULocale("en", "ZW")},
18             {new ULocale("in"), new ULocale("id")},
19             {new ULocale("in", "ID"), new ULocale("id", "ID")},
20             {new ULocale("iw"), new ULocale("he")},
21             {new ULocale("iw", "IL"), new ULocale("he", "IL")},
22             {new ULocale("ji"), new ULocale("yi")},
23
24             {new ULocale("en", "BU"), new ULocale("en", "MM")},
25             {new ULocale("en", "DY"), new ULocale("en", "BJ")},
26             {new ULocale("en", "HV"), new ULocale("en", "BF")},
27             {new ULocale("en", "NH"), new ULocale("en", "VU")},
28             {new ULocale("en", "TP"), new ULocale("en", "TL")},
29             {new ULocale("en", "ZR"), new ULocale("en", "CD")}
30     };
31
32     private static final int _LOCALE_NUMBER = _LOCALES.length;
33     private static ULocale[] available = null;
34     private HashMap availableMap = new HashMap();
35     private static final ULocale _DEFAULT_LOCALE = ULocale.US;
36
37     public static void main(String[] args) {
38         new LocaleAliasCollationTest().run(args);
39     }
40
41     public LocaleAliasCollationTest() {
42     }
43
44     protected void init(){
45         available = ULocale.getAvailableLocales();
46         for(int i=0; i<available.length;i++){
47             availableMap.put(available[i].toString(),"");
48         }
49     }
50
51     public void TestCollation() {
52         ULocale defLoc = ULocale.getDefault();
53         ULocale.setDefault(_DEFAULT_LOCALE);
54         for (int i=0; i<_LOCALE_NUMBER; i++) {
55             ULocale oldLoc = _LOCALES[i][0];
56             ULocale newLoc = _LOCALES[i][1];
57             if(availableMap.get(_LOCALES[i][1])==null){
58                 logln(_LOCALES[i][1]+" is not available. Skipping!");
59                 continue;
60             }
61             Collator c1 = Collator.getInstance(oldLoc);
62             Collator c2 = Collator.getInstance(newLoc);
63
64             if (!c1.equals(c2)) {
65                 errln("CollationTest: c1!=c2: newLoc= "+newLoc +" oldLoc= "+oldLoc);
66             }
67
68             logln("Collation old:"+oldLoc+"   new:"+newLoc);
69         }
70         ULocale.setDefault(defLoc);
71     }
72 }