public void CharStream_CanRememberStates(string input, int savedIndex) { var cs = new CharStream(input); for (int i = 0; i < savedIndex; i++) cs.Read(); var expectedChar = cs.Peek().Value; var rp = cs.CreateRestorePoint(); while (cs.Read() != null) ; var end = cs.Read(); Assert.True(!end.HasValue); rp(); var foundChar = cs.Peek(); Assert.True(foundChar.HasValue); Assert.Equal(expectedChar, foundChar.Value); }