CharacterReader { boolean rangeEquals(final int start, int count, final String cached) { if (count == cached.length()) { char one[] = input; int i = start; int j = 0; while (count-- != 0) { if (one[i++] != cached.charAt(j++)) return false; } return true; } return false; } CharacterReader(String input); @Override String toString();  }
@Test public void rangeEquals() { CharacterReader r = new CharacterReader("Check\tCheck\tCheck\tCHOKE"); assertTrue(r.rangeEquals(0, 5, "Check")); assertFalse(r.rangeEquals(0, 5, "CHOKE")); assertFalse(r.rangeEquals(0, 5, "Chec")); assertTrue(r.rangeEquals(6, 5, "Check")); assertFalse(r.rangeEquals(6, 5, "Chuck")); assertTrue(r.rangeEquals(12, 5, "Check")); assertFalse(r.rangeEquals(12, 5, "Cheeky")); assertTrue(r.rangeEquals(18, 5, "CHOKE")); assertFalse(r.rangeEquals(18, 5, "CHIKE")); }