public void TestConsumeHe() { var buffer = Encoding.ASCII.GetBytes("Hello world.!"); var slice = new BufferSlice(buffer, 0, buffer.Length); var reader = new StringBufferSliceReader(slice, slice.Count); reader.Consume('H', 'e'); Assert.Equal('l', reader.Current); Assert.Equal('l', reader.Peek); }
public void TestConsume() { var buffer = Encoding.ASCII.GetBytes("Hello world.!"); var slice = new BufferSlice(buffer, 0, buffer.Length); var reader = new StringBufferSliceReader(slice, slice.Count); reader.Consume(); Assert.Equal(slice.Count, reader.Length); Assert.Equal(slice.Offset - slice.Count, reader.RemainingLength); Assert.Equal('e', reader.Current); Assert.Equal('l', reader.Peek); Assert.True(reader.HasMore); }
public void TestConsumeEnd() { var buffer = Encoding.ASCII.GetBytes("Hello \tworld.!"); var slice = new BufferSlice(buffer, 0, buffer.Length); var reader = new StringBufferSliceReader(slice, slice.Count); reader.ReadUntil('!'); Assert.Equal('!', reader.Current); reader.Consume(); Assert.True(reader.EndOfFile); Assert.Equal(0, reader.RemainingLength); }