public void MappingTest() { string input = "Yes\nNo\nYesNo\n"; var sbtest = new CodeMappingBuilder(input); string line; sbtest.AppendOutputText("Maybe\n"); line = sbtest.ReadLine(); sbtest.AddMappedSection(line.Length); line = sbtest.ReadLine(); sbtest.SkipInputText(line.Length, NHamlTokenType.IdDefinition); line = sbtest.ReadLine(); sbtest.AddMappedSection(3); sbtest.SkipInputText(3, NHamlTokenType.CommentDefinition); var output = sbtest.output; Assert.AreEqual("Maybe\nYes\nYes", output); Assert.AreEqual(2, sbtest.mappings.Length); Assert.AreEqual(2, sbtest.paintings.Length); Assert.AreEqual("Yes\n", input.Substring(sbtest.mappings[0].start1, sbtest.mappings[0].end1 - sbtest.mappings[0].start1)); Assert.AreEqual("Yes", input.Substring(sbtest.mappings[1].start1, sbtest.mappings[1].end1 - sbtest.mappings[1].start1)); Assert.AreEqual("Yes\n", output.Substring(sbtest.mappings[0].start2, sbtest.mappings[0].end2 - sbtest.mappings[0].start2)); Assert.AreEqual("Yes", output.Substring(sbtest.mappings[1].start2, sbtest.mappings[1].end2 - sbtest.mappings[1].start2)); Assert.AreEqual("No\n", input.Substring(sbtest.paintings[0].start, sbtest.paintings[0].end - sbtest.paintings[0].start)); Assert.AreEqual("No\n", input.Substring(sbtest.paintings[1].start, sbtest.paintings[1].end - sbtest.paintings[1].start)); }
public void AppendToOutputTest() { string input = "Line1\nLine2\nLine3\n"; var sbtest = new CodeMappingBuilder(input); string line; sbtest.AppendOutputText("Line0\n"); line = sbtest.ReadLine(); sbtest.SkipInputText(line.Length,NHamlTokenType.CommentDefinition); line = sbtest.ReadLine(); sbtest.AddMappedSection(line.Length); Assert.AreEqual("Line0\nLine2\n",sbtest.output); }
public void AppendToOutputTest() { string input = "Line1\nLine2\nLine3\n"; var sbtest = new CodeMappingBuilder(input); string line; sbtest.AppendOutputText("Line0\n"); line = sbtest.ReadLine(); sbtest.SkipInputText(line.Length, NHamlTokenType.CommentDefinition); line = sbtest.ReadLine(); sbtest.AddMappedSection(line.Length); Assert.AreEqual("Line0\nLine2\n", sbtest.output); }