public void TestStringLiteralMatcher() { StringLiteralMatcher matcher = new StringLiteralMatcher(); StringTokenizer data = new StringTokenizer("\"str\" \"\"\"test\" \"\\\"\" \"\\n\" \"eof"); SourcePosition streamPos = new SourcePosition(0, 0, 0); // Match basic string Assert.IsNotNull(matcher.MatchNext(data, ref streamPos, Log)); Assert.AreEqual(data.CurrentItem, " "); data.Advance(); // Match empty string Assert.AreEqual(matcher.MatchNext(data, ref streamPos, Log).Value, ""); Assert.AreEqual(data.CurrentItem, "\""); // Ensure non-empty string contents Assert.AreEqual(matcher.MatchNext(data, ref streamPos, Log).Value, "test"); Assert.AreEqual(data.CurrentItem, " "); data.Advance(); // Match escape char Assert.AreEqual(matcher.MatchNext(data, ref streamPos, Log).Value, "\\\""); Assert.AreEqual(data.CurrentItem, " "); data.Advance(); // Include but dont react to other escape chars Assert.AreEqual(matcher.MatchNext(data, ref streamPos, Log).Value, "\\n"); Assert.AreEqual(data.CurrentItem, " "); data.Advance(); // Ensure discarding of string that reaches eof without closing quote Assert.IsNull(matcher.MatchNext(data, ref streamPos, Log)); Assert.AreEqual(data.CurrentItem, "\""); }