CharacterReader { boolean matches(char c) { return !isEmpty() && input[pos] == c; } CharacterReader(String input); @Override String toString();  }
@Test public void matches() { CharacterReader r = new CharacterReader("One Two Three"); assertTrue(r.matches('O')); assertTrue(r.matches("One Two Three")); assertTrue(r.matches("One")); assertFalse(r.matches("one")); assertEquals('O', r.consume()); assertFalse(r.matches("One")); assertTrue(r.matches("ne Two Three")); assertFalse(r.matches("ne Two Three Four")); assertEquals("ne Two Three", r.consumeToEnd()); assertFalse(r.matches("ne")); }