This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-csv.git
The following commit(s) were added to refs/heads/master by this push: new bdd72a27 Sort members bdd72a27 is described below commit bdd72a271bd6450b0ec95d7a6e56b0ac6fa45019 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sat Apr 6 08:17:08 2024 -0400 Sort members --- .../java/org/apache/commons/csv/CSVParserTest.java | 70 +++++++++++----------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index fd9de361..261307e6 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -1374,6 +1374,41 @@ public class CSVParserTest { assertEquals("xyz", csvRecord.get(1)); } } + @Test + public void testParsingPrintedEmptyFirstColumn() throws Exception { + String[][] lines = new String[][] { + {"a", "b"}, + {"", "x"} + }; + Exception firstException = null; + for (CSVFormat.Predefined format : CSVFormat.Predefined.values()) { + try { + StringWriter buf = new StringWriter(); + try (CSVPrinter printer = new CSVPrinter(buf, format.getFormat())) { + for (String[] line : lines) { + printer.printRecord((Object[]) line); + } + } + try (CSVParser csvRecords = new CSVParser(new StringReader(buf.toString()), format.getFormat())) { + for (String[] line : lines) { + assertArrayEquals(line, csvRecords.nextRecord().values()); + } + assertNull(csvRecords.nextRecord()); + } + } catch (Exception | Error e) { + Exception detailedException = new RuntimeException("format: " + format, e); + if (firstException == null) { + firstException = detailedException; + } else { + firstException.addSuppressed(detailedException); + } + } + } + + if (firstException != null) + throw firstException; + } + @Test public void testProvidedHeader() throws Exception { final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z"); @@ -1562,41 +1597,6 @@ public class CSVParserTest { assertEquals(3, record.size()); }} - @Test - public void testParsingPrintedEmptyFirstColumn() throws Exception { - String[][] lines = new String[][] { - {"a", "b"}, - {"", "x"} - }; - Exception firstException = null; - for (CSVFormat.Predefined format : CSVFormat.Predefined.values()) { - try { - StringWriter buf = new StringWriter(); - try (CSVPrinter printer = new CSVPrinter(buf, format.getFormat())) { - for (String[] line : lines) { - printer.printRecord((Object[]) line); - } - } - try (CSVParser csvRecords = new CSVParser(new StringReader(buf.toString()), format.getFormat())) { - for (String[] line : lines) { - assertArrayEquals(line, csvRecords.nextRecord().values()); - } - assertNull(csvRecords.nextRecord()); - } - } catch (Exception | Error e) { - Exception detailedException = new RuntimeException("format: " + format, e); - if (firstException == null) { - firstException = detailedException; - } else { - firstException.addSuppressed(detailedException); - } - } - } - - if (firstException != null) - throw firstException; - } - private void validateLineNumbers(final String lineSeparator) throws IOException { try (final CSVParser parser = CSVParser.parse("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withRecordSeparator(lineSeparator))) { assertEquals(0, parser.getCurrentLineNumber());