Beispiel #1
0
        private static void VerifyNewlyCreatedChars()
        {
            FwUtils.InitializeIcu();

            // The commented out methods below use u_getIntPropertyValue(), which doesn't
            // work reliably with the limited number of data files that we modify.
            //Assert.IsTrue(Icu.Character.IsAlphabetic(kChar1));	// now true
            //Assert.IsTrue(Icu.Character.IsAlphabetic(kChar2));	// now true
            //Assert.IsFalse(Icu.Character.IsAlphabetic(kChar3));
            //Assert.IsFalse(Icu.Character.IsAlphabetic(kChar4));
            Assert.IsFalse(Icu.Character.IsControl(kChar1));
            Assert.IsFalse(Icu.Character.IsControl(kChar2));
            Assert.IsFalse(Icu.Character.IsControl(kChar3));
            Assert.IsFalse(Icu.Character.IsControl(kChar4));
            //Assert.IsFalse(Icu.Character.IsDiacritic(kChar1));
            //Assert.IsFalse(Icu.Character.IsDiacritic(kChar2));
            //Assert.IsFalse(Icu.Character.IsDiacritic(kChar3));
            //Assert.IsFalse(Icu.Character.IsDiacritic(kChar4));
            //Assert.IsFalse(Icu.Character.IsIdeographic(kChar1));
            //Assert.IsFalse(Icu.Character.IsIdeographic(kChar2));
            //Assert.IsFalse(Icu.Character.IsIdeographic(kChar3));
            //Assert.IsFalse(Icu.Character.IsIdeographic(kChar4));
            //Assert.IsFalse(Icu.Character.IsNumeric(kChar1));
            //Assert.IsFalse(Icu.Character.IsNumeric(kChar2));
            //Assert.IsFalse(Icu.Character.IsNumeric(kChar3));
            //Assert.IsTrue(Icu.Character.IsNumeric(kChar4));		// now true
            Assert.IsFalse(Icu.Character.IsPunct(kChar1));
            Assert.IsFalse(Icu.Character.IsPunct(kChar2));
            Assert.IsTrue(Icu.Character.IsPunct(kChar3));                               // now true
            Assert.IsFalse(Icu.Character.IsPunct(kChar4));
            Assert.IsFalse(Icu.Character.IsSpace(kChar1));
            Assert.IsFalse(Icu.Character.IsSpace(kChar2));
            Assert.IsFalse(Icu.Character.IsSpace(kChar3));
            Assert.IsFalse(Icu.Character.IsSpace(kChar4));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar1));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar2));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar3));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar4));

            var cat = Icu.Character.GetCharType(kChar1);

            Assert.AreEqual(Icu.Character.UCharCategory.LOWERCASE_LETTER, cat);
            cat = Icu.Character.GetCharType(kChar2);
            Assert.AreEqual(Icu.Character.UCharCategory.UPPERCASE_LETTER, cat);
            cat = Icu.Character.GetCharType(kChar3);
            Assert.AreEqual(Icu.Character.UCharCategory.OTHER_PUNCTUATION, cat);
            cat = Icu.Character.GetCharType(kChar4);
            Assert.AreEqual(Icu.Character.UCharCategory.DECIMAL_DIGIT_NUMBER, cat);
            var decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar1);

            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar2);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar3);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar4);
            Assert.AreEqual("[none]", decompositionType.Description);
            var numericType = CustomIcu.GetNumericTypeInfo(kChar1);

            Assert.AreEqual("[none]", numericType.Description);
            numericType = CustomIcu.GetNumericTypeInfo(kChar2);
            Assert.AreEqual("[none]", numericType.Description);
            numericType = CustomIcu.GetNumericTypeInfo(kChar3);
            Assert.AreEqual("[none]", numericType.Description);

            // Current implementation (as of ICU50) is not overriding numeric type since we don't use it anywhere.
            // Enhance silmods.c in icu patch if needed.
            //numericType = Icu.GetNumericType(kChar4);
            //Assert.AreEqual("Decimal Digit", numericType.Description);

            // Current implementation (as of ICU50) is not overriding character names since we don't use them anywhere.
            // Enhance silmods.c in icu patch if needed.
            //var prettyName = Icu.GetPrettyICUCharName("\xE000");
            //Assert.AreEqual("My Special Character", prettyName);
            //prettyName = Icu.GetPrettyICUCharName("\xE001");
            //Assert.AreEqual("My Uppercase Character", prettyName);
            //prettyName = Icu.GetPrettyICUCharName(kChar3S);
            //Assert.AreEqual("New Punctuation Mark", prettyName);
            //var rawName = Icu.GetCharName(kChar4);	// can't pass large character code as 16-bit char.
            //Assert.AreEqual("NEW DIGIT NINE", rawName);
        }
Beispiel #2
0
        private static void VerifyNonexistentChars()
        {
            FwUtils.InitializeIcu();

            Assert.IsFalse(Icu.Character.IsAlphabetic(kChar1));
            Assert.IsFalse(Icu.Character.IsAlphabetic(kChar2));
            Assert.IsFalse(Icu.Character.IsAlphabetic(kChar3));
            Assert.IsFalse(Icu.Character.IsAlphabetic(kChar4));
            Assert.IsFalse(Icu.Character.IsControl(kChar1));
            Assert.IsFalse(Icu.Character.IsControl(kChar2));
            Assert.IsFalse(Icu.Character.IsControl(kChar3));
            Assert.IsFalse(Icu.Character.IsControl(kChar4));
            Assert.IsFalse(Icu.Character.IsDiacritic(kChar1));
            Assert.IsFalse(Icu.Character.IsDiacritic(kChar2));
            Assert.IsFalse(Icu.Character.IsDiacritic(kChar3));
            Assert.IsFalse(Icu.Character.IsDiacritic(kChar4));
            Assert.IsFalse(Icu.Character.IsIdeographic(kChar1));
            Assert.IsFalse(Icu.Character.IsIdeographic(kChar2));
            Assert.IsFalse(Icu.Character.IsIdeographic(kChar3));
            Assert.IsFalse(Icu.Character.IsIdeographic(kChar4));
            Assert.IsFalse(Icu.Character.IsNumeric(kChar1));
            Assert.IsFalse(Icu.Character.IsNumeric(kChar2));
            Assert.IsFalse(Icu.Character.IsNumeric(kChar3));
            Assert.IsFalse(Icu.Character.IsNumeric(kChar4));
            Assert.IsFalse(Icu.Character.IsPunct(kChar1));
            Assert.IsFalse(Icu.Character.IsPunct(kChar2));
            Assert.IsFalse(Icu.Character.IsPunct(kChar3));
            Assert.IsFalse(Icu.Character.IsPunct(kChar4));
            Assert.IsFalse(Icu.Character.IsSpace(kChar1));
            Assert.IsFalse(Icu.Character.IsSpace(kChar2));
            Assert.IsFalse(Icu.Character.IsSpace(kChar3));
            Assert.IsFalse(Icu.Character.IsSpace(kChar4));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar1));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar2));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar3));
            Assert.IsFalse(Icu.Character.IsSymbol(kChar4));

            Assert.AreEqual(Icu.Character.UCharCategory.PRIVATE_USE_CHAR, Icu.Character.GetCharType(kChar1));
            Assert.AreEqual(Icu.Character.UCharCategory.PRIVATE_USE_CHAR, Icu.Character.GetCharType(kChar2));
            Assert.AreEqual(Icu.Character.UCharCategory.UNASSIGNED, Icu.Character.GetCharType(kChar3));
            Assert.AreEqual(Icu.Character.UCharCategory.UNASSIGNED, Icu.Character.GetCharType(kChar4));
            var decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar1);

            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar2);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar3);
            Assert.AreEqual("[none]", decompositionType.Description);
            decompositionType = CustomIcu.GetDecompositionTypeInfo(kChar4);
            Assert.AreEqual("[none]", decompositionType.Description);
            var numericType = CustomIcu.GetNumericTypeInfo(kChar1);

            Assert.AreEqual("[none]", numericType.Description);
            numericType = CustomIcu.GetNumericTypeInfo(kChar2);
            Assert.AreEqual("[none]", numericType.Description);
            numericType = CustomIcu.GetNumericTypeInfo(kChar3);
            Assert.AreEqual("[none]", numericType.Description);
            numericType = CustomIcu.GetNumericTypeInfo(kChar4);
            Assert.AreEqual("[none]", numericType.Description);
            var prettyName = Icu.Character.GetPrettyICUCharName("\xE000");

            Assert.IsNull(prettyName);
            prettyName = Icu.Character.GetPrettyICUCharName("\xE001");
            Assert.IsNull(prettyName);
            prettyName = Icu.Character.GetPrettyICUCharName(kChar3S);
            Assert.IsNull(prettyName);
            prettyName = Icu.Character.GetPrettyICUCharName("\xDDDDD");
            Assert.IsNull(prettyName);
        }