CSV-85 Allow comments to be returned in CSVRecord

Added test for comment before header

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1307078 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2012-03-29 19:50:26 +00:00
parent 29c80daa3c
commit 7d2ec7a053
1 changed files with 17 additions and 0 deletions

View File

@ -466,6 +466,23 @@ public class CSVParserTest {
assertFalse(records.hasNext());
}
@Test
public void testHeaderComment() throws Exception {
Reader in = new StringReader("# comment\na,b,c\n1,2,3\nx,y,z");
Iterator<CSVRecord> records = CSVFormat.DEFAULT.withCommentStart('#').withHeader().parse(in).iterator();
for (int i = 0; i < 2; i++) {
assertTrue(records.hasNext());
CSVRecord record = records.next();
assertEquals(record.get(0), record.get("a"));
assertEquals(record.get(1), record.get("b"));
assertEquals(record.get(2), record.get("c"));
}
assertFalse(records.hasNext());
}
@Test
public void testProvidedHeader() throws Exception {
Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");