public void ParsePositionTests() { ParsePosition pos; string text = "abc\r\ndef\rghi\nxyz\n"; List <(int Line, int Column)> values = new List <(int, int)> { (1, 1), // 0 (1, 2), // 1 (1, 3), // 2 (1, 4), // 3 (1, 5), // 4 (2, 1), // 5 (2, 2), // 6 (2, 3), // 7 (2, 4), // 8 (3, 1), // 9 (3, 2), // 10 (3, 3), // 11 (3, 4), // 12 (4, 1), // 13 (4, 2), // 14 (4, 3), // 15 (4, 4), // 16 (5, 1), // 17 }; for (int i = 0; i < values.Count; i++) { pos = ParsePosition.CalculatePosition(text, i); Assert.AreEqual(values[i].Line, pos.Line); Assert.AreEqual(values[i].Column, pos.Column); } ParsingHelper helper = new ParsingHelper(text); helper.SkipTo("ghi"); pos = helper.GetLineColumn(); Assert.AreEqual(3, pos.Line); Assert.AreEqual(1, pos.Column); }