AbstractCharStreamScanner implements CharStreamScanner { @Override public int skipWhile(CharFilter filter) { return skipWhile(filter, Integer.MAX_VALUE); } AbstractCharStreamScanner(); @Override int readDigit(); @Override double readDouble(); @Override float readFloat(); @Override int skipWhile(CharFilter filter); @Override char skipWhileAndPeek(CharFilter filter); @Override char skipWhileAndPeek(CharFilter filter, int max); @Override String readWhile(CharFilter filter); @Override String readUntil(CharFilter filter, boolean acceptEof, String stop); @Override String readUntil(CharFilter filter, boolean acceptEot, String stop, boolean ignoreCase); @Override boolean skipOver(String substring); @Override boolean skipOver(String substring, boolean ignoreCase); @Override String readLine(); @Override boolean expect(String expected); @Override boolean expectStrict(String expected); @Override Character readJavaCharLiteral(); @Override String readJavaStringLiteral();  }
@Test public void testSkipWhile() { String string = "abc def ghi"; CharStreamScanner scanner = scanner(string); int skipCount = scanner.skipWhile(' '); assertThat(skipCount).isEqualTo(0); String read = scanner.read(3); assertThat(read).isEqualTo("abc"); skipCount = scanner.skipWhile(' '); assertThat(skipCount).isEqualTo(1); read = scanner.read(3); assertThat(read).isEqualTo("def"); skipCount = scanner.skipWhile(' '); assertThat(skipCount).isEqualTo(2); read = scanner.read(3); assertThat(read).isEqualTo("ghi"); assertThat(scanner.hasNext()).isFalse(); }
@Test public void testSkipWhileFilter() { String string = "abc def \tghi\t\t \t"; CharFilter filter = new ListCharFilter(true, ' ', '\t'); CharStreamScanner scanner = scanner(string); int skipCount = scanner.skipWhile(filter); assertThat(skipCount).isEqualTo(0); String read = scanner.read(3); assertThat(read).isEqualTo("abc"); skipCount = scanner.skipWhile(filter); assertThat(skipCount).isEqualTo(1); read = scanner.read(3); assertThat(read).isEqualTo("def"); skipCount = scanner.skipWhile(filter); assertThat(skipCount).isEqualTo(2); read = scanner.read(3); assertThat(read).isEqualTo("ghi"); skipCount = scanner.skipWhile(filter, 3); assertThat(skipCount).isEqualTo(3); skipCount = scanner.skipWhile(filter, 5); assertThat(skipCount).isEqualTo(1); assertThat(scanner.hasNext()).isFalse(); }