From c025d73d31ca9c9c467f3bad142ca62d7ebee76b Mon Sep 17 00:00:00 2001 From: Sebb Date: Sun, 16 Jun 2019 13:44:04 +0100 Subject: [PATCH] CSV235 - WRONG Implementation for RFC4180 Show that implementation is actually correct --- .../java/org/apache/commons/csv/CSVParserTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index fc46b164..8953e388 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -1179,6 +1179,18 @@ public class CSVParserTest { assertEquals(Arrays.asList("header1", "header2", "header1"), record.getParser().getHeaderNames()); } + @Test + public void testCSV235() throws IOException { + final String dqString = "\"aaa\",\"b\"\"bb\",\"ccc\""; // "aaa","b""bb","ccc" + final Iterator records = CSVFormat.RFC4180.parse(new StringReader(dqString)).iterator(); + final CSVRecord record = records.next(); + assertFalse(records.hasNext()); + Assert.assertEquals(3, record.size()); + assertEquals("aaa", record.get(0)); + assertEquals("b\"bb", record.get(1)); + assertEquals("ccc", record.get(2)); + } + private void validateLineNumbers(final String lineSeparator) throws IOException { try (final CSVParser parser = CSVParser.parse("a" + lineSeparator + "b" + lineSeparator + "c", CSVFormat.DEFAULT.withRecordSeparator(lineSeparator))) {