Skip to content

Commit d4d4154

Browse files
committed
Refactor some magic strings in
CSVPrinterTest.testQuoteCharEscapedWithQuoteModeNone()
1 parent d729b44 commit d4d4154

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,18 +1802,20 @@ void testQuoteAll() throws IOException {
18021802
void testQuoteCharEscapedWithQuoteModeNone() throws IOException {
18031803
final CSVFormat format = CSVFormat.DEFAULT.builder().setQuote('"').setEscape('?').setQuoteMode(QuoteMode.NONE).get();
18041804
final StringWriter sw = new StringWriter();
1805+
final String col1 = "\"abc";
1806+
final String col2 = "x\"y";
18051807
try (CSVPrinter printer = new CSVPrinter(sw, format)) {
1806-
printer.printRecord("\"abc", "x\"y");
1807-
printer.printRecord(new StringReader("\"abc"), new StringReader("x\"y"));
1808+
printer.printRecord(col1, col2);
1809+
printer.printRecord(new StringReader(col1), new StringReader(col2));
18081810
}
18091811
assertEquals("?\"abc,x?\"y" + RECORD_SEPARATOR + "?\"abc,x?\"y" + RECORD_SEPARATOR, sw.toString());
18101812
// The emitted records must read back as the original values.
18111813
try (CSVParser parser = CSVParser.parse(sw.toString(), format)) {
18121814
final List<CSVRecord> records = parser.getRecords();
18131815
assertEquals(2, records.size());
18141816
for (final CSVRecord record : records) {
1815-
assertEquals("\"abc", record.get(0));
1816-
assertEquals("x\"y", record.get(1));
1817+
assertEquals(col1, record.get(0));
1818+
assertEquals(col2, record.get(1));
18171819
}
18181820
}
18191821
}

0 commit comments

Comments
 (0)