### Question:
CharArrayCharacterSource implements CharacterSource { @Override public final boolean consumeIfMatch( char[] match ) { int idx = index; char[] _chars = chars; boolean ok = true; for (int i=0; i < match.length; i++, idx++) { ok &= ( match[i] == _chars[idx] ); if (!ok) break; } if ( ok ) { index = idx; return true; } else { return false; } } CharArrayCharacterSource( char[] chars );  CharArrayCharacterSource( String string ); @Override final int nextChar(); final int safeNextChar(); @Override final char[] findNextChar( final int match, final int esc ); @Override boolean hadEscape(); char[] readNumber(  ); @Override final int currentChar(); @Override final boolean hasChar(); @Override final boolean consumeIfMatch( char[] match ); @Override final int location(); @Override void skipWhiteSpace(); @Override String errorDetails( String message );  }### Answer:
@Test public void consumeIfMatchTest() { String testString = "abc true abc"; source = new CharArrayCharacterSource ( testString ); boolean found = false; loop: while (source.hasChar()) { int i = source.currentChar(); switch ( i ) { case 't': found = true; break loop; } source.nextChar(); } boolean ok = found || die("not found"); ok |= source.consumeIfMatch ( "true".toCharArray() ) || die(); ok |= source.location() == 8 || die("" + source.location()); ok |= source.currentChar() == ' ' || die("" + (char)source.currentChar()); }