public void Test40520_3()
        {
            short font           = 3;
            HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");

            // wrong order => will format 0-6
            r.ApplyFont(0, 2, font);
            r.ApplyFont(5, 7, font);
            r.ApplyFont(0, 2, font);

            r.ApplyFont(0, 2, font);
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(font, r.GetFontAtIndex(i));
            }
            for (int i = 2; i < 5; i++)
            {
                Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(i));
            }
            for (int i = 5; i < 7; i++)
            {
                Assert.AreEqual(font, r.GetFontAtIndex(i));
            }
            for (int i = 7; i < r.Length; i++)
            {
                Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(i));
            }
        }
        public void Test40520_2()
        {
            short font           = 3;
            HSSFRichTextString r = new HSSFRichTextString("f0_123456789012345678901234567890123456789012345678901234567890");

            r.ApplyFont(0, 2, font);
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(font, r.GetFontAtIndex(i));
            }
            for (int i = 2; i < r.Length; i++)
            {
                Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(i));
            }

            r.ApplyFont(0, 2, font);
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(font, r.GetFontAtIndex(i));
            }
            for (int i = 2; i < r.Length; i++)
            {
                Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(i));
            }
        }
        public void TestApplyFont()
        {
            HSSFRichTextString r = new HSSFRichTextString("Testing");

            Assert.AreEqual(0, r.NumFormattingRuns);
            r.ApplyFont(2, 4, new HSSFFont((short)1, null));
            Assert.AreEqual(2, r.NumFormattingRuns);
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(0));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(1));
            Assert.AreEqual(1, r.GetFontAtIndex(2));
            Assert.AreEqual(1, r.GetFontAtIndex(3));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(4));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(5));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(6));

            r.ApplyFont(6, 7, new HSSFFont((short)2, null));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(0));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(1));
            Assert.AreEqual(1, r.GetFontAtIndex(2));
            Assert.AreEqual(1, r.GetFontAtIndex(3));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(4));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(5));
            Assert.AreEqual(2, r.GetFontAtIndex(6));

            r.ApplyFont(HSSFRichTextString.NO_FONT);
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(0));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(1));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(2));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(3));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(4));
            Assert.AreEqual(HSSFRichTextString.NO_FONT, r.GetFontAtIndex(5));

            r.ApplyFont(new HSSFFont((short)1, null));
            Assert.AreEqual(1, r.GetFontAtIndex(0));
            Assert.AreEqual(1, r.GetFontAtIndex(1));
            Assert.AreEqual(1, r.GetFontAtIndex(2));
            Assert.AreEqual(1, r.GetFontAtIndex(3));
            Assert.AreEqual(1, r.GetFontAtIndex(4));
            Assert.AreEqual(1, r.GetFontAtIndex(5));
            Assert.AreEqual(1, r.GetFontAtIndex(6));
        }