Add test that documents behavior of multiple iterators over the same CSVParser.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1513228 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2013-08-12 19:23:16 +00:00
parent 5a30b37043
commit 817561f4d7
1 changed files with 18 additions and 0 deletions

View File

@ -488,6 +488,24 @@ public class CSVParserTest {
}
}
@Test // TODO this may lead to strange behavior, throw an exception if iterator() has already been called?
public void testMultipleIterators() throws Exception {
CSVParser parser = CSVParser.parse("a,b,c" + CR + "d,e,f", CSVFormat.DEFAULT);
Iterator<CSVRecord> itr1 = parser.iterator();
Iterator<CSVRecord> itr2 = parser.iterator();
CSVRecord first = itr1.next();
assertEquals("a", first.get(0));
assertEquals("b", first.get(1));
assertEquals("c", first.get(2));
CSVRecord second = itr2.next();
assertEquals("d", second.get(0));
assertEquals("e", second.get(1));
assertEquals("f", second.get(2));
}
@Test
public void testHeader() throws Exception {
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");