public void PositionTest()
        {
            Assert.AreEqual(0, ScriptPositionReporting.Position("ab", 1, 1));
            Assert.AreEqual(1, ScriptPositionReporting.Position("ab", 1, 2));
            Assert.AreEqual(2, ScriptPositionReporting.Position("ab", 1, 3)); // end of file

            Assert.AreEqual(0, ScriptPositionReporting.Position("a\nbc", 1, 1));
            Assert.AreEqual(1, ScriptPositionReporting.Position("a\nbc", 1, 2));
            Assert.AreEqual(2, ScriptPositionReporting.Position("a\nbc", 2, 1));
            Assert.AreEqual(3, ScriptPositionReporting.Position("a\nbc", 2, 2));
            Assert.AreEqual(4, ScriptPositionReporting.Position("a\nbc", 2, 3)); // end of file

            Assert.AreEqual(0, ScriptPositionReporting.Position("a\r\nbc", 1, 1));
            Assert.AreEqual(1, ScriptPositionReporting.Position("a\r\nbc", 1, 2));
            Assert.AreEqual(3, ScriptPositionReporting.Position("a\r\nbc", 2, 1));
            Assert.AreEqual(4, ScriptPositionReporting.Position("a\r\nbc", 2, 2));
            Assert.AreEqual(5, ScriptPositionReporting.Position("a\r\nbc", 2, 3)); // end of file

            Assert.AreEqual(0, ScriptPositionReporting.Position("\n\nx\n", 1, 1));
            Assert.AreEqual(1, ScriptPositionReporting.Position("\n\nx\n", 2, 1));
            Assert.AreEqual(2, ScriptPositionReporting.Position("\n\nx\n", 3, 1));
            Assert.AreEqual(4, ScriptPositionReporting.Position("\n\nx\n", 4, 1)); // end of file
        }
예제 #2
0
        private string FollowingText_LineColumn(string script, int line, int column, int maxLength)
        {
            int position = ScriptPositionReporting.Position(script, line, column);

            return(ScriptPositionReporting.FollowingText(script, position, maxLength));
        }