@Test
public void testIterator() throws Exception {

    final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
    final Iterator<CSVRecord> iterator = CSVFormat.DEFAULT.parse(in).iterator();
    assertTrue(iterator.hasNext());
    try {
        iterator.remove();
        fail("expected UnsupportedOperationException");
    } catch (final UnsupportedOperationException expected) {
        // expected
    }
    assertArrayEquals(new String[]{"a", "b", "c"}, iterator.next().values());
    assertArrayEquals(new String[]{"1", "2", "3"}, iterator.next().values());
    assertTrue(iterator.hasNext());
    assertTrue(iterator.hasNext());
    assertTrue(iterator.hasNext());
    assertArrayEquals(new String[]{"x", "y", "z"}, iterator.next().values());
    assertFalse(iterator.hasNext());
    try {
        iterator.next();
        fail("NoSuchElementException expected");
    } catch (final NoSuchElementException e) {
        // expected
    }
}