public void CurrentSourceLine_Windows(string source, int position, int expected) { var scanner = new TextSourceScanner(source, "\r\n"); scanner.Advance(position); var actual = scanner.CurrentSourceLine; Assert.Equal(expected, actual); }
public void IsAtEnd(string source, int position, bool expected) { var scanner = new TextSourceScanner(source); scanner.Advance(position); var actual = scanner.IsAtEnd(); Assert.Equal(expected, actual); }
public void CurrentWindow(string source, int @base, int position, string expected) { var scanner = new TextSourceScanner(source); scanner.Advance(position); scanner.Base = @base; var actual = scanner.CurrentWindow; Assert.Equal(expected, actual); }
public void CurrentWindow_WithBaseAdjust(string source, int position, int advanceCount, string expected) { var scanner = new TextSourceScanner(source); scanner.Advance(position); scanner.Base = scanner.Position; scanner.Advance(advanceCount); var actual = scanner.CurrentWindow; Assert.Equal(expected, actual); }
public void PeekNext_Happy(string source, int position, int peekCount, char expected) { var scanner = new TextSourceScanner(source); if (position > 0) { scanner.Advance(position); } var startPosition = scanner.Position; var actual = scanner.Peek(peekCount); Assert.Equal(expected, actual); Assert.Equal(startPosition, scanner.Position); }
public void Advance_Happy(string source, int position, int advanceCount, char expected) { var scanner = new TextSourceScanner(source); if (position > 0) { scanner.Advance(position); } var startPosition = scanner.Position; var actual = scanner.Advance(advanceCount); Assert.Equal(expected, actual); if (source.Length > startPosition + advanceCount) { Assert.Equal(startPosition + advanceCount, scanner.Position); } }
public void Advance_NegativeCount(string source, int advanceCount) { var scanner = new TextSourceScanner(source); Assert.Throws <InvalidOperationException>(() => scanner.Advance(advanceCount)); }