Author: ggregory
Date: Thu Jun 12 13:57:48 2014
New Revision: 1602166

URL: http://svn.apache.org/r1602166
Log:
[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.

Modified:
    
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java

Modified: 
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1602166&r1=1602165&r2=1602166&view=diff
==============================================================================
--- 
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
 (original)
+++ 
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
 Thu Jun 12 13:57:48 2014
@@ -634,6 +634,22 @@ public class CSVParserTest {
     }
 
     @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
     public void testHeaderComment() throws Exception {
         final Reader in = new StringReader("# comment\na,b,c\n1,2,3\nx,y,z");
 


Reply via email to