public void CanPeekCharWithIndex() { // Arrange. TextBuffer buffer = new TextBuffer("This is some text"); // Act. char c = buffer.PeekChar(10); // Assert. Assert.AreEqual('m', c); }
public void PeekCharDetectsInvalidPosition() { // Arrange. TextBuffer buffer = new TextBuffer("This is some text"); // Act. char c = buffer.PeekChar(20); // Assert. Assert.AreEqual('\0', c); }
public void CanPeekCharFirst() { // Arrange. TextBuffer buffer = new TextBuffer("This is some text"); // Act. char c = buffer.PeekChar(); // Assert. Assert.AreEqual('T', c); }
public void CorrectlyReportsColumnOnSingleLine() { // Arrange. TextBuffer buffer = new TextBuffer(string.Format("Abc{0}Defg{0}C", "\r\n")); // Act. buffer.NextChar(); buffer.NextChar(); // Assert. Assert.AreEqual(2, buffer.Column); }
public void CanGetNextChar() { // Arrange. TextBuffer buffer = new TextBuffer("This is some text"); // Act. char c1 = buffer.NextChar(); char c2 = buffer.NextChar(); // Assert. Assert.AreEqual('T', c1); Assert.AreEqual('h', c2); }
public void CorrectlyReportsRemainingLength() { // Arrange. TextBuffer buffer = new TextBuffer("This is some text"); // Act. buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); // Assert. Assert.AreEqual(12, buffer.RemainingLength); }
public void CorrectlyReportsPosition() { // Arrange. TextBuffer buffer = new TextBuffer(string.Format("Abc{0}Defg{0}C", "\r\n")); // Act. buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); BufferPosition position = buffer.Position; // Assert. Assert.AreEqual(2, position.Column); Assert.AreEqual(1, position.Line); Assert.AreEqual(7, position.Offset); }
public void CorrectlyReportsIsEofWhenTrue() { // Arrange. TextBuffer buffer = new TextBuffer("Abc"); // Act. buffer.NextChar(); buffer.NextChar(); buffer.NextChar(); // Assert. Assert.AreEqual(true, buffer.IsEof); }
protected LexerBase(string path, string text) { _path = path; _buffer = new TextBuffer(text); _value = new StringBuilder(); }