File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1564,18 +1564,24 @@ public void testTrim() throws Exception {
15641564
15651565 @ Test
15661566 public void testParsingPrintedEmptyFirstColumn () throws Exception {
1567+ String [][] lines = new String [][] {
1568+ {"a" , "b" },
1569+ {"" , "x" }
1570+ };
15671571 Exception firstException = null ;
15681572 for (CSVFormat .Predefined format : CSVFormat .Predefined .values ()) {
15691573 try {
15701574 StringWriter buf = new StringWriter ();
15711575 try (CSVPrinter printer = new CSVPrinter (buf , format .getFormat ())) {
1572- printer .printRecord ("a" , "b" ); // header
1573- printer .printRecord ("" , "x" ); // empty first column
1576+ for (String [] line : lines ) {
1577+ printer .printRecord ((Object []) line );
1578+ }
15741579 }
1575- try (CSVParser csvRecords = new CSVParser (new StringReader (buf .toString ()), format .getFormat (). builder (). setHeader (). build () )) {
1576- for (CSVRecord csvRecord : csvRecords ) {
1577- assertNotNull ( csvRecord );
1580+ try (CSVParser csvRecords = new CSVParser (new StringReader (buf .toString ()), format .getFormat ())) {
1581+ for (String [] line : lines ) {
1582+ assertArrayEquals ( line , csvRecords . nextRecord (). values () );
15781583 }
1584+ assertNull (csvRecords .nextRecord ());
15791585 }
15801586 } catch (Exception | Error e ) {
15811587 Exception detailedException = new RuntimeException ("format: " + format , e );
You can’t perform that action at this time.
0 commit comments