public void SingeLineCommentIsConsumed() { string text = "lazy// some text \r\n" + "dog"; LookAheadTokenParserBase parser = new LookAheadTokenParserBase( TestUtil.GetTextStream(text), new string[] { }); Assert.AreEqual("lazy", parser.NextToken()); Assert.AreEqual("dog", parser.NextToken()); }
public void TokenReturned() { string text = "lazy dog"; LookAheadTokenParserBase parser = new LookAheadTokenParserBase( TestUtil.GetTextStream(text), new string[] { " " }); Assert.AreEqual("lazy", parser.PeekNextToken()); Assert.AreEqual("lazy", parser.NextToken()); Assert.AreEqual(" ", parser.PeekNextToken()); Assert.AreEqual(" ", parser.NextToken()); Assert.AreEqual("dog", parser.PeekNextToken()); Assert.AreEqual("dog", parser.NextToken()); }
public void NoTokenSpecified() { string text = "the lazy brown dog"; LookAheadTokenParserBase parser = new LookAheadTokenParserBase( TestUtil.GetTextStream(text), new string[] { }); Assert.AreEqual(text, parser.PeekNextToken()); Assert.AreEqual(text, parser.NextToken()); }
public void ExhaustedThrows() { string text = "lazy"; LookAheadTokenParserBase parser = new LookAheadTokenParserBase( TestUtil.GetTextStream(text), new string[] { }); Assert.AreEqual("lazy", parser.PeekNextToken()); Assert.AreEqual("lazy", parser.NextToken()); parser.PeekNextToken(); }
public void LongNonExistentToken() { string text = "#ifdef x #endif"; LookAheadTokenParserBase parser = new LookAheadTokenParserBase( TestUtil.GetTextStream(text), new string[] { "NotToBeFoundTokenButIsIsLongEnoughEh?", "#", "ifdef", "endif", " " }); Assert.AreEqual("#", parser.NextToken()); Assert.AreEqual("ifdef", parser.NextToken()); Assert.AreEqual(" ", parser.NextToken()); Assert.AreEqual("x", parser.NextToken()); Assert.AreEqual(" ", parser.NextToken()); Assert.AreEqual("#", parser.NextToken()); Assert.AreEqual("endif", parser.NextToken()); }