示例#1
0
        private void doTestComposedChars(bool compat)
        {
            int options           = Normalizer.IGNORE_HANGUL;
            ComposedCharIter iter = new ComposedCharIter(compat, options);

            char lastChar = (char)0;

            while (iter.HasNext)
            {
                char ch = iter.Next();

                // Test all characters between the last one and this one to make
                // sure that they don't have decompositions
                assertNoDecomp(lastChar, ch, compat, options);
                lastChar = ch;

                // Now make sure that the decompositions for this character
                // make sense
                String chString   = new StringBuffer().Append(ch).ToString();
                String iterDecomp = iter.Decomposition();
                String normDecomp = Normalizer.Decompose(chString, compat);

                if (iterDecomp.Equals(chString))
                {
                    Errln("ERROR: " + Hex(ch) + " has identical decomp");
                }
                else if (!iterDecomp.Equals(normDecomp))
                {
                    Errln("ERROR: Normalizer decomp for " + Hex(ch) + " (" + Hex(normDecomp) + ")"
                          + " != iter decomp (" + Hex(iterDecomp) + ")");
                }
            }
            assertNoDecomp(lastChar, '\uFFFF', compat, options);
        }
示例#2
0
        public void TestRoundTrip()
        {
            int  options = Normalizer.IGNORE_HANGUL;
            bool compat  = false;

            ComposedCharIter iter = new ComposedCharIter(false, options);

            while (iter.HasNext)
            {
                char ch = iter.Next();

                string chStr  = "" + ch;
                string decomp = iter.Decomposition();
                string comp   = Normalizer.Compose(decomp, compat);

                if (UChar.HasBinaryProperty(ch, UProperty.Full_Composition_Exclusion))
                {
                    Logln("Skipped excluded char " + Hex(ch) + " (" + UChar.GetName(ch) + ")");
                    continue;
                }

                // Avoid disparaged characters
                if (decomp.Length == 4)
                {
                    continue;
                }

                if (!comp.Equals(chStr))
                {
                    Errln("ERROR: Round trip invalid: " + Hex(chStr) + " --> " + Hex(decomp)
                          + " --> " + Hex(comp));

                    Errln("  char decomp is '" + decomp + "'");
                }
            }
        }