public void ReadPreviousUnaffectedByPeek() { var str = "Hello World!"; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str))) using (var bs = new BencodeStream(ms)) { bs.Read(1); Assert.Equal('H', bs.ReadPrevious()); Assert.Equal('e', bs.Peek()); Assert.Equal('H', bs.ReadPrevious()); } }
public void PeekUnnaffectedByReadPrevious() { var str = "abcdefghijkl"; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str))) using (var bs = new BencodeStream(ms)) { bs.Read(0); Assert.Equal('a', bs.Peek()); bs.ReadPrevious(); Assert.Equal('a', bs.Peek()); bs.Read(1); Assert.Equal('b', bs.Peek()); bs.ReadPrevious(); Assert.Equal('b', bs.Peek()); } }
public void ReadPrevious() { var str = "Hello World!"; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str))) using (var bs = new BencodeStream(ms)) { Assert.Equal(-1, bs.ReadPrevious()); Assert.Equal('H', bs.Read()); Assert.Equal('H', bs.ReadPrevious()); Assert.Equal('e', bs.Read()); Assert.Equal('e', bs.ReadPrevious()); bs.Position = 20; Assert.Equal(-1, bs.ReadPrevious()); } }
public void ReadPreviousAtStartOfStream() { var str = "Hello World!"; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str))) using (var bs = new BencodeStream(ms)) { Assert.Equal(-1, bs.ReadPrevious()); } }