Exemple #1
0
        public void CharAtCorrectlyReturnsLocation()
        {
            var buffer = new LineTrackingStringBuffer("foo\rbar\nbaz\r\nbiz", "test.cshtml");
            var chr    = buffer.CharAt(14);

            Assert.Equal('i', chr.Character);
            Assert.Equal(new SourceLocation("test.cshtml", 14, 3, 1), chr.Location);
        }
 private void UpdateState()
 {
     if (_position < _buffer.Length)
     {
         var chr = _buffer.CharAt(_position);
         _current  = chr.Character;
         _location = chr.Location;
     }
     else if (_buffer.Length == 0)
     {
         _current  = -1;
         _location = SourceLocation.Zero;
     }
     else
     {
         _current  = -1;
         _location = _buffer.EndLocation;
     }
 }