CharacterReader { char consume() { char val = pos >= length ? EOF : input[pos]; pos++; return val; } CharacterReader(String input); @Override String toString();  }
@Test public void consume() { CharacterReader r = new CharacterReader("one"); assertEquals(0, r.pos()); assertEquals('o', r.current()); assertEquals('o', r.consume()); assertEquals(1, r.pos()); assertEquals('n', r.current()); assertEquals(1, r.pos()); assertEquals('n', r.consume()); assertEquals('e', r.consume()); assertTrue(r.isEmpty()); assertEquals(CharacterReader.EOF, r.consume()); assertTrue(r.isEmpty()); assertEquals(CharacterReader.EOF, r.consume()); }