public void Comments_CustomMarkers() { // Verify that we can handle multiple custom comment prefixes. var input = @"# This is a comment # This is a comment This is a test // This is a comment of the emergency # not a comment broadcasting system # a ab abc "; var expected = @" This is a test of the emergency # not a comment broadcasting system a ab abc "; using (var reader = new PreprocessReader(input)) { reader.ClearCommentMarkers(); reader.AddCommentMarker("#"); reader.AddCommentMarker("//"); var output = reader.ReadToEnd(); Assert.Equal(expected, output); } }
public void Comments_BadMarkers() { // Verify that we validate reasonable markers. using (var reader = new PreprocessReader(string.Empty)) { Assert.Throws <ArgumentNullException>(() => reader.AddCommentMarker(null)); Assert.Throws <ArgumentNullException>(() => reader.AddCommentMarker(string.Empty)); Assert.Throws <ArgumentException>(() => reader.AddCommentMarker(" ")); // Whitespace not allowed Assert.Throws <ArgumentException>(() => reader.AddCommentMarker(" //")); // Whitespace not allowed Assert.Throws <ArgumentException>(() => reader.AddCommentMarker("\t")); // Whitespace not allowed Assert.Throws <ArgumentException>(() => reader.AddCommentMarker("1")); // Not punctation Assert.Throws <ArgumentException>(() => reader.AddCommentMarker("a")); // Not punctation } }