public void UpdateLocationDoesNotAdvanceLineIndexOnNonNewlineCharacter() { // Arrange var tracker = new SourceLocationTracker(TestStartLocation); // Act tracker.UpdateLocation('f', 'o'); // Assert Assert.Equal(42, tracker.CurrentLocation.LineIndex); }
public void UpdateLocationAdvancesLineIndexOnSlashN() { // Arrange var tracker = new SourceLocationTracker(TestStartLocation); // Act tracker.UpdateLocation('\n', 'o'); // Assert Assert.Equal(43, tracker.CurrentLocation.LineIndex); }
public BufferingTextReader(TextReader source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } InnerReader = source; _locationTracker = new SourceLocationTracker(); UpdateCurrentCharacter(); }
public void UpdateLocationAdvancesCorrectlyForMultiLineString() { // Arrange var tracker = new SourceLocationTracker(TestStartLocation); // Act tracker.UpdateLocation("foo\nbar\rbaz\r\nbox"); // Assert Assert.Equal(26, tracker.CurrentLocation.AbsoluteIndex); Assert.Equal(45, tracker.CurrentLocation.LineIndex); Assert.Equal(3, tracker.CurrentLocation.CharacterIndex); }
public SpanFactory() { LocationTracker = new SourceLocationTracker(); }
public void UpdateLocationAdvancesCharacterIndexOnSlashRFollowedBySlashN() { // Arrange var tracker = new SourceLocationTracker(TestStartLocation); // Act tracker.UpdateLocation('\r', '\n'); // Assert Assert.Equal(46, tracker.CurrentLocation.CharacterIndex); }
public void UpdateLocationResetsCharacterIndexOnSlashRFollowedByNonNewlineCharacter() { // Arrange var tracker = new SourceLocationTracker(TestStartLocation); // Act tracker.UpdateLocation('\r', 'o'); // Assert Assert.Equal(0, tracker.CurrentLocation.CharacterIndex); }
public void ChangeStart(SourceLocation newStart) { _start = newStart; var current = this; var tracker = new SourceLocationTracker(newStart); tracker.UpdateLocation(Content); while ((current = current.Next) != null) { current._start = tracker.CurrentLocation; tracker.UpdateLocation(current.Content); } }