예제 #1
0
        public void get_NormalizedForm_StackedDiacriticsMultipleRuns_NFCAndNFSCDiffer()
        {
            TsString input = CreateStackedDiacriticsInput(singleRun: false);

            var actualNFC  = (TsString)input.get_NormalizedForm(FwNormalizationMode.knmNFC);
            var actualNFSC = (TsString)input.get_NormalizedForm(FwNormalizationMode.knmNFSC);

            Assert.That(actualNFC.Text, Is.EqualTo(stackedDiacriticsExpectedNFSCSingleRun));
            Assert.That(actualNFSC.Text, Is.EqualTo(stackedDiacriticsExpectedNFSCMultipleRuns));
            Assert.That(actualNFC.RunCount, Is.EqualTo(1));
            Assert.That(actualNFSC.RunCount, Is.EqualTo(22));
        }
예제 #2
0
        public void get_NormalizedForm_StackedDiacriticsSingleRun_NFCAndNFSCAreEqual()
        {
            TsString input = CreateStackedDiacriticsInput(singleRun: true);

            var actualNFC  = (TsString)input.get_NormalizedForm(FwNormalizationMode.knmNFC);
            var actualNFSC = (TsString)input.get_NormalizedForm(FwNormalizationMode.knmNFSC);

            Assert.That(actualNFC.Text, Is.EqualTo(stackedDiacriticsExpectedNFSCSingleRun));
            Assert.That(actualNFSC.Text, Is.EqualTo(stackedDiacriticsExpectedNFSCSingleRun));
            Assert.That(actualNFC.RunCount, Is.EqualTo(1));
            Assert.That(actualNFSC.RunCount, Is.EqualTo(1));
            // Also check TsString equality, since that compares properties as well as text
            Assert.That(actualNFSC, Is.EqualTo(actualNFC));
        }
예제 #3
0
        public void get_NormalizedForm_SplitRuns_ShouldVaryBehaviorBetweenNFCAndNFSC(FwNormalizationMode nm, string expected)
        {
            // Setup
            string input     = "A" + COMBINING_DIAERESIS;
            var    intProps1 = new Dictionary <int, TsIntPropValue>
            {
                { (int)FwTextPropType.ktptWs, new TsIntPropValue((int)FwTextPropVar.ktpvDefault, EnglishWS) },
                { (int)FwTextPropType.ktptBold, new TsIntPropValue((int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn) }
            };
            var intProps2 = new Dictionary <int, TsIntPropValue>
            {
                { (int)FwTextPropType.ktptWs, new TsIntPropValue((int)FwTextPropVar.ktpvDefault, SpanishWS) },
                { (int)FwTextPropType.ktptUnderline, new TsIntPropValue((int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn) }
            };
            var runs = new List <TsRun>();

            runs.Add(new TsRun(1, new TsTextProps(intProps1, null)));
            runs.Add(new TsRun(input.Length, new TsTextProps(intProps2, null)));
            var tsInput = new TsString(input, runs);

            // Exercise
            ITsString actual = tsInput.get_NormalizedForm(nm);

            Assert.That(actual.Text, Is.EqualTo(expected));
            Assert.That(actual.get_IsNormalizedForm(nm), Is.True);
        }
예제 #4
0
        public void get_NormalizedForm_NullStrings_AfterNormalizationHaveAlreadyNormalizedFlagSet(FwNormalizationMode nm)
        {
            TsString nullString = new TsString(null, EnglishWS);

            nullString.get_NormalizedForm(nm);             // Don't need result for this test
            Assert.That(nullString.IsAlreadyNormalized(nm), Is.True);
        }
예제 #5
0
        public void get_NormalizedForm_NullStrings_NormalizedFormIsSameObjectAsInput(FwNormalizationMode nm)
        {
            TsString nullString = new TsString(null, EnglishWS);
            TsString actual     = (TsString)nullString.get_NormalizedForm(nm);

            Assert.That(actual, Is.SameAs(nullString));
        }
예제 #6
0
        public void get_NormalizedForm_SimpleCases_WorkAsExpected(FwNormalizationMode nm, string expectedNormalizedText, int expectedStartIndexOfSecondRun)
        {
            TsString  oneRunInput = new TsString(inputForBasicNormalizationTests, EnglishWS);
            ITsString actual      = oneRunInput.get_NormalizedForm(nm);

            Assert.That(actual.Text, Is.EqualTo(expectedNormalizedText));
            Assert.That(((TsString)actual).IsAlreadyNormalized(nm), Is.True);
            Assert.That(actual.get_IsNormalizedForm(nm), Is.True);

            // Make second run starting at the capital C
            ITsStrBldr builder = oneRunInput.GetBldr();

            builder.SetIntPropValues(7, oneRunInput.Length, (int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
            ITsString twoRunInput = builder.GetString();

            actual = twoRunInput.get_NormalizedForm(nm);
            Assert.That(actual.get_MinOfRun(1), Is.EqualTo(expectedStartIndexOfSecondRun));
            // This run does not split any diacritic clusters, so it should not change any normalization results (even NFSC)
            Assert.That(actual.Text, Is.EqualTo(expectedNormalizedText));
        }