@Test
public void testParsedLineIterator() {

    LineParser lineParser = new LineParser();
    ParsedLine line = lineParser.parseLine("foo bar");
    ParsedLineIterator iterator = line.iterator();
    int counter = 0;
    while(iterator.hasNextWord()) {
        if(counter == 0)
            assertEquals("foo", iterator.pollWord());
        else if(counter == 1)
            assertEquals("bar", iterator.pollWord());
        counter++;
    }
    line = lineParser.parseLine("");
    iterator = line.iterator();
    assertFalse(iterator.hasNextWord());
    assertNull(iterator.pollWord());
    line = lineParser.parseLine("\\ foo ba bar");
    iterator = line.iterator();
    assertEquals(" foo", iterator.peekWord());
    assertEquals(" foo", iterator.pollWord());
    assertFalse(iterator.finished());
    assertEquals('b', iterator.pollChar());
    assertEquals('a', iterator.pollChar());
    assertEquals(' ', iterator.pollChar());
    assertFalse(iterator.finished());
    assertEquals("bar", iterator.peekWord());
    assertEquals("bar", iterator.pollWord());
    assertTrue(iterator.finished());
    line = lineParser.parseLine("\\ foo ba bar");
    iterator = line.iterator();
    assertEquals('\\', iterator.pollChar());
    assertEquals(' ', iterator.pollChar());
    assertEquals('f', iterator.pollChar());
    assertEquals(" foo", iterator.pollWord());
    assertEquals("ba", iterator.pollWord());
    assertEquals('b', iterator.pollChar());
    assertEquals('a', iterator.pollChar());
    assertEquals('r', iterator.pollChar());
    assertTrue(iterator.finished());
    line = lineParser.parseLine("\\ foo ba bar");
    iterator = line.iterator();
    assertEquals(" foo", iterator.pollWord());
}