예제 #1
0
        public void MastNotFail_4_1()
        {
            LineArray  lines      = new LineArray(4);
            Controller controller = new Controller(lines);

            lines.SetText(File.ReadAllText("../test_code_4.txt"));

            controller.PutCursor(new Place(1, 56 - 1), false);
            controller.PutNewCursor(new Place(1, 59 - 1));
            controller.PutNewCursor(new Place(1, 61 - 1));
            controller.PutNewCursor(new Place(1, 67 - 1));
            controller.PutNewCursor(new Place(1, 69 - 1));
            controller.PutNewCursor(new Place(1, 79 - 1));
            controller.PutNewCursor(new Place(1, 145 - 1));
            controller.PutNewCursor(new Place(1, 168 - 1));
            controller.PutNewCursor(new Place(1, 171 - 1));
            controller.PutNewCursor(new Place(1, 316 - 1));
            controller.PutNewCursor(new Place(1, 321 - 1));
            controller.PutNewCursor(new Place(1, 326 - 1));
            controller.PutNewCursor(new Place(1, 342 - 1));
            controller.MoveDown(true);
            controller.MoveDown(true);

            controller.EraseSelection();

            Assert.AreEqual(File.ReadAllText("../test_code_4_1_after.txt"), lines.GetText());
        }
        public void TokenIteratorTest5()
        {
            LineArray lines = new LineArray();

            lines.SetText(@"public class A {
				private char a = '}';
				private char b = '""';
				private char c = '\'';
				private char d = '\n';
				
				public void Method0(char c = 'c')
				{
				}
				
				public void Method1()
				{
				}
			}"            );
            CSTokenIterator iterator = new CSTokenIterator(lines);

            Assert.AreEqual("[<<public>>, <<class>>, <<A>>, '{', " +
                            "<<private>>, <<char>>, <<a>>, '=', <<'}'>>, ';', " +
                            "<<private>>, <<char>>, <<b>>, '=', <<'\"'>>, ';', " +
                            "<<private>>, <<char>>, <<c>>, '=', <<'\\''>>, ';', " +
                            "<<private>>, <<char>>, <<d>>, '=', <<'\\n'>>, ';', " +
                            "<<public>>, <<void>>, <<Method0>>, '(', <<char>>, <<c>>, '=', <<'c'>>, ')', '{', '}', " +
                            "<<public>>, <<void>>, <<Method1>>, '(', ')', '{', '}', " +
                            "'}']", ListUtil.ToString(iterator.tokens));
        }
예제 #3
0
 private void Init(string text)
 {
     lines         = new LineArray(200);
     lines.tabSize = 4;
     lines.SetText(text);
     line = lines[0];
 }
        private void AssertParse(string expected, string text)
        {
            LineArray lines = new LineArray();

            lines.SetText(text);
            CSTextNodeParser parser = new CSTextNodeParser(null);
            Node             node   = parser.Parse(lines);

            Assert.AreEqual(expected, StringOfNode(node));
        }
예제 #5
0
        public void MastNotFail_3()
        {
            LineArray  lines      = new LineArray(3);
            Controller controller = new Controller(lines);

            lines.SetText(File.ReadAllText("../test_code_3.txt"));
            controller.PutCursor(new Place(1, 45), false);
            controller.PutCursor(new Place(1, 44), true);
            controller.EraseSelection();
            Assert.AreEqual(File.ReadAllText("../test_code_3_after.txt"), lines.GetText());
        }
예제 #6
0
        public void MastNotFail_2()
        {
            LineArray  lines      = new LineArray(10);
            Controller controller = new Controller(lines);

            lines.SetText(File.ReadAllText("../test_code_2.txt"));
            controller.PutCursor(new Place(0, 9), false);
            controller.PutCursor(new Place(0, 20), true);
            controller.Cut();
            Assert.AreEqual(File.ReadAllText("../test_code_2_after.txt"), lines.GetText());
        }
예제 #7
0
        public void AlwaysHasOneLine()
        {
            LineArray lines = new LineArray(4);

            Assert.AreEqual(1, lines.LinesCount);
            Assert.AreEqual("", lines[0].Text);

            lines.SetText("");
            Assert.AreEqual(0, lines.charsCount);
            Assert.AreEqual(1, lines.LinesCount);
            Assert.AreEqual("", lines[0].Text);
        }
예제 #8
0
        public void MastNotFail_1()
        {
            LineArray  lines      = new LineArray(100);
            Controller controller = new Controller(lines);

            lines.SetText(GetTextExample());
            controller.PutCursor(new Place(0, 299), false);
            controller.PutCursor(new Place(0, 298), true);
            controller.Cut();
            controller.PutCursor(new Place(0, 305), false);
            controller.Paste();
            Assert.AreEqual(File.ReadAllText("../test_code_after.txt"), lines.GetText());
        }
        public void TokenIteratorTest()
        {
            LineArray lines = new LineArray();

            lines.SetText(@"public class A {
				private B b;
				public void C() { }
			}"            );
            CSTokenIterator iterator = new CSTokenIterator(lines);

            Assert.AreEqual("[" +
                            "<<public>>, <<class>>, <<A>>, '{', <<private>>, <<B>>, <<b>>, ';', " +
                            "<<public>>, <<void>>, <<C>>, '(', ')', '{', '}', '}'" +
                            "]", ListUtil.ToString(iterator.tokens));
        }
예제 #10
0
        public void MastNotFail_4()
        {
            LineArray  lines      = new LineArray(4);
            Controller controller = new Controller(lines);

            lines.SetText(File.ReadAllText("../test_code_4.txt"));

            controller.PutCursor(new Place(1, 316 - 1), false);
            controller.PutCursor(new Place(1, 316 - 0), true);

            controller.PutNewCursor(new Place(1, 321 - 1));
            controller.PutCursor(new Place(1, 321 - 0), true);

            controller.EraseSelection();

            Assert.AreEqual(File.ReadAllText("../test_code_4_after.txt"), lines.GetText());
        }
예제 #11
0
        public void TokenIteratorTest4()
        {
            LineArray lines = new LineArray();

            lines.SetText(@"public class Test
			{
				private string text = ""ab\""c\n"";
				private string text2 = @""ab""""c"";
				private string text3 = @""ab"                 + "\n" + @"c"";
			}"            );
            CSTokenIterator iterator = new CSTokenIterator(lines);

            Assert.AreEqual("[" +
                            "<<public>>, <<class>>, <<Test>>, '{', " +
                            "<<private>>, <<string>>, <<text>>, '=', <<\"ab\\\"c\\n\">>, ';', " +
                            "<<private>>, <<string>>, <<text2>>, '=', <<@\"ab\"\"c\">>, ';', " +
                            "<<private>>, <<string>>, <<text3>>, '=', <<@\"ab\nc\">>, ';', '}'" +
                            "]", ListUtil.ToString(iterator.tokens));
        }
예제 #12
0
        public void TokenIteratorTest3()
        {
            LineArray lines = new LineArray();

            lines.SetText(@"public class Test
			{
				/*public */void Method0()
				{
				}
				
				public void Method1()//}
				{
				}
			}"            );
            CSTokenIterator iterator = new CSTokenIterator(lines);

            Assert.AreEqual("[" +
                            "<<public>>, <<class>>, <<Test>>, '{', " +
                            "<<void>>, <<Method0>>, '(', ')', '{', '}', " +
                            "<<public>>, <<void>>, <<Method1>>, '(', ')', '{', '}', '}'" +
                            "]", ListUtil.ToString(iterator.tokens));
        }
예제 #13
0
        public void SetText()
        {
            Init();

            lines.SetText("text");
            Assert.AreEqual(4, lines.charsCount);
            Assert.AreEqual(1, lines.LinesCount);
            Assert.AreEqual(4, lines[0].charsCount);
            Assert.AreEqual("text", lines[0].Text);

            lines.SetText("line0\nline1 text\n\r\nline3 text text text");
            Assert.AreEqual("line0#line1 text###line3 text text text".Length, lines.charsCount);
            Assert.AreEqual(4, lines.LinesCount);
            Assert.AreEqual("line0\n", lines[0].Text);
            Assert.AreEqual("line1 text\n", lines[1].Text);
            Assert.AreEqual("\r\n", lines[2].Text);
            Assert.AreEqual("line3 text text text", lines[3].Text);

            lines.SetText("\r\n\r\n\r\n\n\n\r\r\r");
            Assert.AreEqual("rnrnrnnnrrr".Length, lines.charsCount);
            CollectionAssert.AreEqual(new string[] { "\r\n", "\r\n", "\r\n", "\n", "\n", "\r", "\r", "\r", "" }, lines.Debug_GetLinesText());
            Assert.AreEqual(9, lines.LinesCount);
        }
예제 #14
0
 private void Init(string text)
 {
     lines = new LineArray(4);
     lines.SetText(text);
 }