public void Seek_UpdatesPosition() { IInputReader stream = new StringInputReader("abc"); Position position = stream.GetPosition(); stream.Read(); stream.Read(); stream.Seek(position); Position newPosition = stream.GetPosition(); Assert.AreEqual(position, newPosition); char result = (char)stream.Read(); Assert.AreEqual('a', result); }
public void GetPosition_NothingRead() { IInputReader stream = new StringInputReader(""); Position position = stream.GetPosition(); Assert.AreEqual(0, position.Offset, "offset"); Assert.AreEqual(1, position.Line, "Line"); Assert.AreEqual(1, position.Column, "Column"); }
public void GetPosition_Read_DoesNotUpdateReturnedPosition() { IInputReader stream = new StringInputReader("abc"); Position position = stream.GetPosition(); stream.Read(); Assert.AreEqual(0, position.Offset, "Offset"); Assert.AreEqual(1, position.Line, "Line"); Assert.AreEqual(1, position.Column, "Column"); }
public void GetPosition_ReadChar() { IInputReader stream = new StringInputReader("abc\nxyz"); stream.Read(); Position position = stream.GetPosition(); Assert.AreEqual(1, position.Offset, "offset"); Assert.AreEqual(1, position.Line, "Line"); Assert.AreEqual(2, position.Column, "Column"); }