Copilot commented on code in PR #609:
URL: https://github.com/apache/commons-csv/pull/609#discussion_r3407951689
##########
src/test/java/org/apache/commons/csv/CSVPrinterTest.java:
##########
@@ -423,6 +423,23 @@ void testDelimeterStringQuoteNone() throws IOException {
}
}
+ @Test
+ void testQuoteCharEscapedWithQuoteModeNone() throws IOException {
+ final CSVFormat format =
CSVFormat.DEFAULT.builder().setQuote('"').setEscape('?').setQuoteMode(QuoteMode.NONE).get();
+ final StringWriter sw = new StringWriter();
+ try (CSVPrinter printer = new CSVPrinter(sw, format)) {
+ printer.printRecord("\"abc", "x\"y");
+ }
+ assertEquals("?\"abc,x?\"y\r\n", sw.toString());
+ // The emitted record must read back as the original values.
+ try (CSVParser parser = CSVParser.parse(sw.toString(), format)) {
+ final List<CSVRecord> records = parser.getRecords();
+ assertEquals(1, records.size());
+ assertEquals("\"abc", records.get(0).get(0));
+ assertEquals("x\"y", records.get(0).get(1));
+ }
+ }
Review Comment:
The new test validates the CharSequence-based printing path, but the PR also
changes the Reader-based `printWithEscapes(Reader, ...)` overload. Consider
extending this test to also print the same values via `Reader` inputs so the
Reader path is covered. Also, this file already centralizes the record
separator in `RECORD_SEPARATOR`; using it here avoids hard-coding "\r\n" and
keeps the test resilient if the default record separator ever changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]