@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")); }
static boolean rangeEquals(final char[] charBuf, final int start, int count, final String cached) { if (count == cached.length()) { int i = start; int j = 0; while (count-- != 0) { if (charBuf[i++] != cached.charAt(j++)) return false; } return true; } return false; }
CharacterReader { static boolean rangeEquals(final char[] charBuf, final int start, int count, final String cached) { if (count == cached.length()) { int i = start; int j = 0; while (count-- != 0) { if (charBuf[i++] != cached.charAt(j++)) return false; } return true; } return false; } }
CharacterReader { static boolean rangeEquals(final char[] charBuf, final int start, int count, final String cached) { if (count == cached.length()) { int i = start; int j = 0; while (count-- != 0) { if (charBuf[i++] != cached.charAt(j++)) return false; } return true; } return false; } CharacterReader(Reader input, int sz);  CharacterReader(Reader input);  CharacterReader(String input); }
CharacterReader { static boolean rangeEquals(final char[] charBuf, final int start, int count, final String cached) { if (count == cached.length()) { int i = start; int j = 0; while (count-- != 0) { if (charBuf[i++] != cached.charAt(j++)) return false; } return true; } return false; } CharacterReader(Reader input, int sz);  CharacterReader(Reader input);  CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString(); }
CharacterReader { static boolean rangeEquals(final char[] charBuf, final int start, int count, final String cached) { if (count == cached.length()) { int i = start; int j = 0; while (count-- != 0) { if (charBuf[i++] != cached.charAt(j++)) return false; } return true; } return false; } CharacterReader(Reader input, int sz);  CharacterReader(Reader input);  CharacterReader(String input); int pos(); boolean isEmpty(); char current(); void advance(); String consumeTo(char c); String consumeToAny(final char... chars); @Override String toString();  }