You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2012/03/29 21:50:26 UTC

svn commit: r1307078 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java

Author: sebb
Date: Thu Mar 29 19:50:26 2012
New Revision: 1307078

URL: http://svn.apache.org/viewvc?rev=1307078&view=rev
Log:
CSV-85 Allow comments to be returned in CSVRecord
Added test for comment before header

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=1307078&r1=1307077&r2=1307078&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 Mar 29 19:50:26 2012
@@ -467,6 +467,23 @@ public class CSVParserTest {
     }
 
     @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");