[CSV-121] Exception that the header contains duplicate names when the column names are empty. Add a test that shows that ONE missing header is OK.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1602166 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1282503fb9
commit
5a9436d462
|
@ -633,6 +633,22 @@ public class CSVParserTest {
|
||||||
assertFalse(records.hasNext());
|
assertFalse(records.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHeaderMissing() throws Exception {
|
||||||
|
final Reader in = new StringReader("a,,c\n1,2,3\nx,y,z");
|
||||||
|
|
||||||
|
final Iterator<CSVRecord> records = CSVFormat.DEFAULT.withHeader().parse(in).iterator();
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
assertTrue(records.hasNext());
|
||||||
|
final CSVRecord record = records.next();
|
||||||
|
assertEquals(record.get(0), record.get("a"));
|
||||||
|
assertEquals(record.get(2), record.get("c"));
|
||||||
|
}
|
||||||
|
|
||||||
|
assertFalse(records.hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHeaderComment() throws Exception {
|
public void testHeaderComment() throws Exception {
|
||||||
final Reader in = new StringReader("# comment\na,b,c\n1,2,3\nx,y,z");
|
final Reader in = new StringReader("# comment\na,b,c\n1,2,3\nx,y,z");
|
||||||
|
|
Loading…
Reference in New Issue