Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit 010c81e

Browse files
committed
Add roundtrip test.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398020 13f79535-47bb-0310-9956-ffa450edef68
1 parent 79eb6e0 commit 010c81e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.IOException;
3232
import java.io.Reader;
3333
import java.io.StringReader;
34+
import java.io.StringWriter;
3435
import java.util.ArrayList;
3536
import java.util.Iterator;
3637
import java.util.List;
@@ -435,6 +436,17 @@ public void testForEach() throws Exception {
435436
assertArrayEquals(new String[]{"x", "y", "z"}, records.get(2).values());
436437
}
437438

439+
@Test
440+
public void testRoundtrip() throws Exception {
441+
StringWriter out = new StringWriter();
442+
CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT);
443+
final String input = "a,b,c\r\n1,2,3\r\nx,y,z\r\n";
444+
for (final CSVRecord record : CSVFormat.DEFAULT.parse(new StringReader(input))) {
445+
printer.printRecord(record);
446+
}
447+
assertEquals(input, out.toString());
448+
}
449+
438450
@Test
439451
public void testIterator() throws Exception {
440452
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");

0 commit comments

Comments
 (0)