CSV235 - WRONG Implementation for RFC4180

Show that implementation is actually correct
This commit is contained in:
Sebb 2019-06-16 13:44:04 +01:00
parent bc64fb569c
commit c025d73d31
1 changed files with 12 additions and 0 deletions

View File

@ -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<CSVRecord> 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))) {