Example #1
0
        public void TestDocumentRemove()
        {
            var document = new Mono.TextEditor.TextDocument();

            string top      = "1234567890\n";
            string testText =
                "12345678\n" +
                "1234567\n" +
                "123456\n" +
                "12345\n" +
                "1234\n" +
                "123\n" +
                "12\n" +
                "1\n" +
                "\n";

            document.Text = top + testText;
            document.RemoveText(0, top.Length);
            Assert.AreEqual(document.Text, testText);

            document.RemoveText(0, document.Length);
            var line = document.GetLine(1);

            Assert.AreEqual(0, line.Offset);
            Assert.AreEqual(0, line.LengthIncludingDelimiter);
            Assert.AreEqual(0, document.Length);
            Assert.AreEqual(1, document.LineCount);
        }
Example #2
0
        public void TestDocumentBug1Test()
        {
            var document = new Mono.TextEditor.TextDocument();

            string top = "1234567890";

            document.Text = top;

            Assert.AreEqual(document.GetLine(1).LengthIncludingDelimiter, document.Length);

            document.RemoveText(0, document.Length);

            var line = document.GetLine(1);

            Assert.AreEqual(0, line.Offset);
            Assert.AreEqual(0, line.LengthIncludingDelimiter);
            Assert.AreEqual(0, document.Length);
            Assert.AreEqual(1, document.LineCount);
        }
Example #3
0
        public void SplitterTest()
        {
            var document = new Mono.TextEditor.TextDocument();

            for (int i = 0; i < 100; i++)
            {
                document.InsertText(0, new string ('c', i) + Environment.NewLine);
            }
            Assert.AreEqual(101, document.LineCount);
            for (int i = 0; i < 100; i++)
            {
                DocumentLine line = document.GetLine(i + 1);
                Assert.AreEqual(99 - i, line.Length);
                Assert.AreEqual(Environment.NewLine.Length, line.DelimiterLength);
            }

            for (int i = 0; i < 100; i++)
            {
                DocumentLine line = document.GetLine(1);
                document.RemoveText(line.Length, line.DelimiterLength);
            }
            Assert.AreEqual(1, document.LineCount);
        }