InputTextReader { public void goBack() { _backtracked++; _index--; checkBacktrackLoop(1); } InputTextReader(String content); char read(); String peek(int numberChars); char peekChar(int offset); boolean canReadChars(int numberChars); boolean eof(); int getPosition(); int getBacktrackedCount(); void seek(int position); void goBack();  }
@Test public void testGoBack() { InputTextReader reader = new InputTextReader(CONTENT); Assert.assertEquals(reader.read(), CONTENT.charAt(0)); reader.goBack(); Assert.assertEquals(reader.read(), CONTENT.charAt(0)); Assert.assertEquals(reader.read(), CONTENT.charAt(1)); Assert.assertEquals(reader.read(), CONTENT.charAt(2)); reader.goBack(); reader.goBack(); Assert.assertEquals(reader.read(), CONTENT.charAt(1)); Assert.assertEquals(reader.read(), CONTENT.charAt(2)); }