Esempio n. 1
0
        public void TestDummyCharTrie()
        {
            CharTrie trie;
            int      initialValue = 0x313, leadUnitValue = 0xaffe;
            int      value;
            int      c;

            trie = new CharTrie(initialValue, leadUnitValue, new DummyGetFoldingOffset());

            /* test that all code points have initialValue */
            for (c = 0; c <= 0x10ffff; ++c)
            {
                value = trie.GetCodePointValue(c);
                if (value != initialValue)
                {
                    Errln("CharTrie/dummy.getCodePointValue(c)(U+" + Hex(c) + ")=0x" + Hex(value) + " instead of 0x" + Hex(initialValue));
                }
            }

            /* test that the lead surrogate code units have leadUnitValue */
            for (c = 0xd800; c <= 0xdbff; ++c)
            {
                value = trie.GetLeadValue((char)c);
                if (value != leadUnitValue)
                {
                    Errln("CharTrie/dummy.getLeadValue(c)(U+" + Hex(c) + ")=0x" + Hex(value) + " instead of 0x" + Hex(leadUnitValue));
                }
            }
        }
Esempio n. 2
0
        public void TestCharValues()
        {
            CharTrie trie = null;

            try
            {
                trie = IBM.ICU.Impl.UCharacterProperty.GetInstance().m_trie_;
            }
            catch (Exception e)
            {
                Warnln("Error creating ucharacter trie");
                return;
            }

            for (int i = 0; i < 0xFFFF; i++)
            {
                if (i < 0xFF &&
                    trie.GetBMPValue((char)i) != trie
                    .GetLatin1LinearValue((char)i))
                {
                    Errln("For latin 1 codepoint, getBMPValue should be the same "
                          + "as getLatin1LinearValue");
                }
                if (trie.GetBMPValue((char)i) != trie.GetCodePointValue(i))
                {
                    Errln("For BMP codepoint, getBMPValue should be the same "
                          + "as getCodepointValue");
                }
            }
            for (int i_0 = 0x10000; i_0 < 0x10ffff; i_0++)
            {
                char lead      = IBM.ICU.Text.UTF16.GetLeadSurrogate(i_0);
                char trail     = IBM.ICU.Text.UTF16.GetTrailSurrogate(i_0);
                char value_ren = trie.GetCodePointValue(i_0);
                if (value_ren != trie.GetSurrogateValue(lead, trail) ||
                    value_ren != trie.GetTrailValue(trie.GetLeadValue(lead),
                                                    trail))
                {
                    Errln("For Non-BMP codepoints, getSurrogateValue should be "
                          + "the same s getCodepointValue and getTrailValue");
                }
            }
        }