|
38 | 38 | import java.nio.charset.Charset; |
39 | 39 | import java.util.ArrayList; |
40 | 40 | import java.util.Iterator; |
| 41 | +import java.util.LinkedList; |
41 | 42 | import java.util.List; |
42 | 43 | import java.util.Map; |
43 | 44 | import java.util.NoSuchElementException; |
@@ -66,6 +67,8 @@ public class CSVParserTest { |
66 | 67 | // + " \"foo\n,,\n\"\",,\n\\\"\",d,e\n"; |
67 | 68 | + " \"foo\n,,\n\"\",,\n\"\"\",d,e\n"; // changed to use standard CSV escaping |
68 | 69 |
|
| 70 | + private static final String CSV_INPUT_1 = "a,b,c,d"; |
| 71 | + |
69 | 72 | private static final String[][] RESULT = { |
70 | 73 | {"a", "b", "c", "d"}, |
71 | 74 | {"a", "b", "1 2"}, |
@@ -511,6 +514,22 @@ public void testGetLineNumberWithLF() throws Exception { |
511 | 514 | this.validateLineNumbers(String.valueOf(LF)); |
512 | 515 | } |
513 | 516 |
|
| 517 | + @Test |
| 518 | + public void testGetOneLine() throws IOException { |
| 519 | + final CSVParser parser = CSVParser.parse(CSV_INPUT_1, CSVFormat.DEFAULT); |
| 520 | + final CSVRecord record = parser.getRecords().get(0); |
| 521 | + assertArrayEquals(RESULT[0], record.values()); |
| 522 | + parser.close(); |
| 523 | + } |
| 524 | + |
| 525 | + @Test |
| 526 | + public void testGetOneLineCustomCollection() throws IOException { |
| 527 | + final CSVParser parser = CSVParser.parse(CSV_INPUT_1, CSVFormat.DEFAULT); |
| 528 | + final CSVRecord record = parser.getRecords(new LinkedList<CSVRecord>()).getFirst(); |
| 529 | + assertArrayEquals(RESULT[0], record.values()); |
| 530 | + parser.close(); |
| 531 | + } |
| 532 | + |
514 | 533 | @Test |
515 | 534 | public void testGetRecordNumberWithCR() throws Exception { |
516 | 535 | this.validateRecordNumbers(String.valueOf(CR)); |
|
0 commit comments