Skip to content

Commit 9791346

Browse files
committed
Add org.apache.commons.csv.CSVPrinterTest.testPrintRecordsWithCSVRecord().
1 parent 7aa3b46 commit 9791346

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,21 @@ public void testPrintReaderWithoutQuoteToWriter() throws IOException {
13361336
assertEquals(content, sw.toString());
13371337
}
13381338

1339+
@Test
1340+
public void testPrintRecordsWithCSVRecord() throws IOException {
1341+
final String[] values = new String[] {"A", "B", "C"};
1342+
final String rowData = StringUtils.join(values, ',');
1343+
final CharArrayWriter charArrayWriter = new CharArrayWriter(0);
1344+
try (final CSVParser parser = CSVFormat.DEFAULT.parse(new StringReader(rowData));
1345+
CSVPrinter csvPrinter = CSVFormat.INFORMIX_UNLOAD.print(charArrayWriter)) {
1346+
for (CSVRecord record : parser) {
1347+
csvPrinter.printRecord(record);
1348+
}
1349+
}
1350+
assertEquals(6, charArrayWriter.size());
1351+
assertEquals("A|B|C" + CSVFormat.INFORMIX_UNLOAD.getRecordSeparator(), charArrayWriter.toString());
1352+
}
1353+
13391354
@Test
13401355
public void testPrintRecordsWithEmptyVector() throws IOException {
13411356
final PrintStream out = System.out;

0 commit comments

Comments
 (0)