Exemplo n.º 1
0
        public void TestGetTokens()
        {
            var testInput =
                @"open something named{ accessMod type name { someStatement; someOtherStatement; accessMod type name(someArg){someBody;} somefinalStatement; }}";

            var testSubject = new XDocFrame('{', '}');
            var testResults = testSubject.GetTokens(testInput);

            Assert.IsNotNull(testResults);
            Assert.AreNotEqual(0, testResults.Count);

            Assert.AreEqual(4,testResults.Count);
            Assert.AreEqual("0, 142, 142, 0, 0", string.Format("{0}, {1}, {2}, {3}, {4}", testResults[0].Start, testResults[0].End, testResults[0].Span, testResults[0].Register, testResults[0].Tab));
            Assert.AreEqual("20, 141, 121, 1, 0", string.Format("{0}, {1}, {2}, {3}, {4}", testResults[1].Start, testResults[1].End, testResults[1].Span, testResults[1].Register, testResults[1].Tab));
            Assert.AreEqual("42, 140, 98, 2, 1", string.Format("{0}, {1}, {2}, {3}, {4}", testResults[2].Start, testResults[2].End, testResults[2].Span, testResults[2].Register, testResults[2].Tab));
            Assert.AreEqual("107, 118, 11, 3, 2", string.Format("{0}, {1}, {2}, {3}, {4}", testResults[3].Start, testResults[3].End, testResults[3].Span, testResults[3].Register, testResults[3].Tab));

            foreach (var t in testResults)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, {1}, {2}, {3}, {4}", t.Start, t.End, t.Span, t.Register, t.Tab));
            }
        }
Exemplo n.º 2
0
        public void TestGetGaps()
        {
            var testInput =
                @"open something named{ accessMod type name { someStatement; someOtherStatement; accessMod type name(someArg){someBody;} somefinalStatement; }}";
            var testSubject = new XDocFrame('{', '}');

            //technically this is no a valid unit test...
            var contrivedTestInput = testSubject.GetTokens(testInput);

            var testResults = testSubject.GetGaps(contrivedTestInput);
            Assert.IsNotNull(testResults);
            Assert.AreNotEqual(0, testResults);

            foreach (var t in testResults)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("{0}, {1}, {2}, {3}", t.Start, t.End, t.Span, t.ChildTo));
            }
        }