示例#1
0
  @Test
  public void testIgnoreNext() {

    final String[] fiveFacit = five.split("\n");
    final int[] c = {0, 0}; // callback, ignored

    Parser p =
        new Parser(
            fiveLineIs,
            new ParserCallback<String>() {

              public void callback(String s) {

                assertEquals(
                    fiveFacit[c[IGNORED_COUNT] + c[CALLBACK_COUNT]++],
                    s); // Test the correct lines are sent
              }
            });

    while (true) {

      if (!p.hasNext()) break;

      p.next();

      if (!p.hasNext()) break;

      p.ignoreNext();
      c[IGNORED_COUNT]++;
    }

    assertEquals(
        c[CALLBACK_COUNT] + c[IGNORED_COUNT],
        fiveFacit
            .length); // Test that the callback count + ignored is total the length of the facit
  }