Add org.apache.commons.csv.CSVPrinterTest.testPrintRecordsWithCSVRecord().

This commit is contained in:
Gary Gregory 2020-11-11 14:08:30 -05:00
parent 7aa3b46719
commit 979134603b
1 changed files with 15 additions and 0 deletions

View File

@ -1336,6 +1336,21 @@ public class CSVPrinterTest {
assertEquals(content, sw.toString());
}
@Test
public void testPrintRecordsWithCSVRecord() throws IOException {
final String[] values = new String[] {"A", "B", "C"};
final String rowData = StringUtils.join(values, ',');
final CharArrayWriter charArrayWriter = new CharArrayWriter(0);
try (final CSVParser parser = CSVFormat.DEFAULT.parse(new StringReader(rowData));
CSVPrinter csvPrinter = CSVFormat.INFORMIX_UNLOAD.print(charArrayWriter)) {
for (CSVRecord record : parser) {
csvPrinter.printRecord(record);
}
}
assertEquals(6, charArrayWriter.size());
assertEquals("A|B|C" + CSVFormat.INFORMIX_UNLOAD.getRecordSeparator(), charArrayWriter.toString());
}
@Test
public void testPrintRecordsWithEmptyVector() throws IOException {
final PrintStream out = System.out;