Skip to content

Commit 12a39f8

Browse files
committed
Use a parameterized test for the escaped null string case
1 parent e6495c7 commit 12a39f8

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -584,19 +584,19 @@ void testEndOfFileBehaviorExcel() throws Exception {
584584
}
585585
}
586586

587-
@Test
588-
void testEscapedNullStringIsAValue() throws Exception {
587+
@ParameterizedTest
588+
@EnumSource(value = CSVFormat.Predefined.class, names = { "MySQL", "PostgreSQLCsv", "PostgreSQLText", "Oracle" })
589+
void testEscapedNullStringIsAValue(final CSVFormat.Predefined predefined) throws Exception {
589590
// "\N" is the MySQL and PostgreSQL null marker, "\\N" is the value "\N", which is what the printer writes for it.
590-
for (final CSVFormat format : new CSVFormat[] { CSVFormat.MYSQL, CSVFormat.POSTGRESQL_TEXT, CSVFormat.ORACLE }) {
591-
final StringWriter writer = new StringWriter();
592-
try (CSVPrinter printer = new CSVPrinter(writer, format)) {
593-
printer.printRecord("\\N", null);
594-
}
595-
try (CSVParser parser = CSVParser.parse(writer.toString(), format)) {
596-
final CSVRecord record = parser.nextRecord();
597-
assertEquals("\\N", record.get(0), format.toString());
598-
assertNull(record.get(1), format.toString());
599-
}
591+
final CSVFormat format = predefined.getFormat();
592+
final StringWriter writer = new StringWriter();
593+
try (CSVPrinter printer = new CSVPrinter(writer, format)) {
594+
printer.printRecord("\\N", null);
595+
}
596+
try (CSVParser parser = CSVParser.parse(writer.toString(), format)) {
597+
final CSVRecord record = parser.nextRecord();
598+
assertEquals("\\N", record.get(0));
599+
assertNull(record.get(1));
600600
}
601601
}
602602

0 commit comments

Comments
 (0)