diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index 5a8ae12c..19754394 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -38,6 +38,7 @@ import java.net.URL; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -66,6 +67,8 @@ public class CSVParserTest { // + " \"foo\n,,\n\"\",,\n\\\"\",d,e\n"; + " \"foo\n,,\n\"\",,\n\"\"\",d,e\n"; // changed to use standard CSV escaping + private static final String CSV_INPUT_1 = "a,b,c,d"; + private static final String[][] RESULT = { {"a", "b", "c", "d"}, {"a", "b", "1 2"}, @@ -511,6 +514,22 @@ public class CSVParserTest { this.validateLineNumbers(String.valueOf(LF)); } + @Test + public void testGetOneLine() throws IOException { + final CSVParser parser = CSVParser.parse(CSV_INPUT_1, CSVFormat.DEFAULT); + final CSVRecord record = parser.getRecords().get(0); + assertArrayEquals(RESULT[0], record.values()); + parser.close(); + } + + @Test + public void testGetOneLineCustomCollection() throws IOException { + final CSVParser parser = CSVParser.parse(CSV_INPUT_1, CSVFormat.DEFAULT); + final CSVRecord record = parser.getRecords(new LinkedList()).getFirst(); + assertArrayEquals(RESULT[0], record.values()); + parser.close(); + } + @Test public void testGetRecordNumberWithCR() throws Exception { this.validateRecordNumbers(String.valueOf(CR));