CharacterReader { String consumeToEnd() { String data = cacheString(pos, length-pos); pos = length; return data; } CharacterReader(String input); @Override String toString();  }
@Test public void consumeToEnd() { String in = "one two three"; CharacterReader r = new CharacterReader(in); String toEnd = r.consumeToEnd(); assertEquals(in, toEnd); assertTrue(r.isEmpty()); }