Example #1
0
        public void TestGetFunctionalEquivalent()
        {
            var kw = Collator.Keywords;

            String[] DATA =
            {
                "sv",                          "sv",                    "t",
                "sv@collation=direct",         "sv",                    "t",
                "sv@collation=traditional",    "sv",                    "t",
                "sv@collation=gb2312han",      "sv",                    "t",
                "sv@collation=stroke",         "sv",                    "t",
                "sv@collation=pinyin",         "sv",                    "t",
                "sv@collation=standard",       "sv@collation=standard", "t",
                "sv@collation=reformed",       "sv",                    "t",
                "sv@collation=big5han",        "sv",                    "t",
                "sv_FI",                       "sv",                    "f",
                "sv_FI@collation=direct",      "sv",                    "f",
                "sv_FI@collation=traditional", "sv",                    "f",
                "sv_FI@collation=gb2312han",   "sv",                    "f",
                "sv_FI@collation=stroke",      "sv",                    "f",
                "sv_FI@collation=pinyin",      "sv",                    "f",
                "sv_FI@collation=standard",    "sv@collation=standard", "f",
                "sv_FI@collation=reformed",    "sv",                    "f",
                "sv_FI@collation=big5han",     "sv",                    "f",
                "nl",                          "root",                  "t",
                "nl@collation=direct",         "root",                  "t",
                "nl_BE",                       "root",                  "f",
                "nl_BE@collation=direct",      "root",                  "f",
                "nl_BE@collation=traditional", "root",                  "f",
                "nl_BE@collation=gb2312han",   "root",                  "f",
                "nl_BE@collation=stroke",      "root",                  "f",
                "nl_BE@collation=pinyin",      "root",                  "f",
                "nl_BE@collation=big5han",     "root",                  "f",
                "nl_BE@collation=phonebook",   "root",                  "f",
                "en_US_VALLEYGIRL",            "root",                  "f"
            };
            int DATA_COUNT = (DATA.Length / 3);

            for (int i = 0; i < DATA_COUNT; i++)
            {
                bool[]       isAvailable     = new bool[1];
                UCultureInfo input           = new UCultureInfo(DATA[(i * 3) + 0]);
                UCultureInfo expect          = new UCultureInfo(DATA[(i * 3) + 1]);
                bool         expectAvailable = DATA[(i * 3) + 2].Equals("t");
                UCultureInfo actual          = Collator.GetFunctionalEquivalent(kw[0], input, isAvailable);
                if (!actual.Equals(expect) || (expectAvailable != isAvailable[0]))
                {
                    Errln("#" + i + ": Collator.getFunctionalEquivalent(" + input + ")=" + actual + ", avail " + isAvailable[0] + ", " +
                          "expected " + expect + " avail " + expectAvailable);
                }
                else
                {
                    Logln("#" + i + ": Collator.getFunctionalEquivalent(" + input + ")=" + actual + ", avail " + isAvailable[0]);
                }
            }
        }
Example #2
0
        public void TestSeparateTrees()
        {
            var kw = Collator.Keywords.ToArray();

            if (!assertTrue("getKeywords != null", kw != null))
            {
                return;
            }
            CheckArray("getKeywords", kw, KW);

            String[] kwval = Collator.GetKeywordValues(KW[0]);
            if (!assertTrue("getKeywordValues != null", kwval != null))
            {
                return;
            }
            CheckArray("getKeywordValues", kwval, KWVAL);

            bool[]       isAvailable = new bool[1];
            UCultureInfo equiv       = Collator.GetFunctionalEquivalent(KW[0],
                                                                        new UCultureInfo("de"),
                                                                        isAvailable);

            if (assertTrue("getFunctionalEquivalent(de)!=null", equiv != null))
            {
                assertEquals("getFunctionalEquivalent(de)", "root", equiv.ToString());
            }
            assertTrue("getFunctionalEquivalent(de).isAvailable==true",
                       isAvailable[0] == true);

            equiv = Collator.GetFunctionalEquivalent(KW[0],
                                                     new UCultureInfo("de_DE"),
                                                     isAvailable);
            if (assertTrue("getFunctionalEquivalent(de_DE)!=null", equiv != null))
            {
                assertEquals("getFunctionalEquivalent(de_DE)", "root", equiv.ToString());
            }
            assertTrue("getFunctionalEquivalent(de_DE).isAvailable==false",
                       isAvailable[0] == false);

            equiv = Collator.GetFunctionalEquivalent(KW[0], new UCultureInfo("zh_Hans"));
            if (assertTrue("getFunctionalEquivalent(zh_Hans)!=null", equiv != null))
            {
                assertEquals("getFunctionalEquivalent(zh_Hans)", "zh", equiv.ToString());
            }
        }