Exemple #1
0
 public void check(UnicodeMap <String> map1, IDictionary <Integer, String> map2, int counter)
 {
     for (int i = 0; i < LIMIT; ++i)
     {
         String value1 = map1.GetValue(i);
         String value2 = map2.Get(new Integer(i));
         if (!UnicodeMap <string> .AreEqual(value1, value2))
         {
             Errln(counter + " Difference at " + Utility.Hex(i)
                   + "\t UnicodeMap: " + value1
                   + "\t HashMap: " + value2);
             Errln("UnicodeMap: " + map1);
             Errln("Log: " + TestBoilerplate <string> .Show(log));
             Errln("HashMap: " + TestBoilerplate <string> .Show(map2));
         }
     }
 }
Exemple #2
0
        [Timeout(120000)] // ICU4N: This test can take awhile because of the slowness of adding items to SortedSet
        public void TestUnicodeMapGeneralCategory()
        {
            Logln("Setting General Category");
            UnicodeMap <String>           map1 = new UnicodeMap <string>();
            IDictionary <Integer, String> map2 = new JCG.Dictionary <Integer, String>();

            //Map<Integer, String> map3 = new TreeMap<Integer, String>();
            map1 = new UnicodeMap <String>();
            map2 = new JCG.SortedDictionary <Integer, String>();

            for (int cp = 0; cp <= SET_LIMIT; ++cp)
            {
                int enumValue = UChar.GetIntPropertyValue(cp, propEnum);
                //if (enumValue <= 0) continue; // for smaller set
                String value = UChar.GetPropertyValueName(propEnum, enumValue, NameChoice.Long);
                map1.Put(cp, value);
                map2[new Integer(cp)] = value;
            }
            checkNext(map1, map2, int.MaxValue);

            Logln("Comparing General Category");
            check(map1, map2, -1);
            Logln("Comparing Values");
            ISet <String> values1 = new JCG.SortedSet <String>(StringComparer.Ordinal); map1.GetAvailableValues(values1);
            ISet <String> values2 = new JCG.SortedSet <String>(map2.Values.Distinct(), StringComparer.Ordinal); // ICU4N NOTE: Added Distinct()

            if (!TestBoilerplate <string> .VerifySetsIdentical(this, values1, values2))
            {
                throw new ArgumentException("Halting");
            }
            Logln("Comparing Sets");
            foreach (string value in values1)
            {
                Logln(value == null ? "null" : value);
                UnicodeSet set1 = map1.KeySet(value);
                UnicodeSet set2 = TestBoilerplate <string> .GetSet(map2, value);

                if (!TestBoilerplate <string> .VerifySetsIdentical(this, set1, set2))
                {
                    throw new ArgumentException("Halting");
                }
            }
        }