mirror of
https://github.com/apache/commons-csv.git
synced 2025-02-17 15:35:46 +00:00
Add roundtrip test.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398020 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
79eb6e0392
commit
010c81e8b4
@ -31,6 +31,7 @@ import static org.junit.Assert.fail;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -435,6 +436,17 @@ public class CSVParserTest {
|
||||
assertArrayEquals(new String[]{"x", "y", "z"}, records.get(2).values());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoundtrip() throws Exception {
|
||||
StringWriter out = new StringWriter();
|
||||
CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT);
|
||||
final String input = "a,b,c\r\n1,2,3\r\nx,y,z\r\n";
|
||||
for (final CSVRecord record : CSVFormat.DEFAULT.parse(new StringReader(input))) {
|
||||
printer.printRecord(record);
|
||||
}
|
||||
assertEquals(input, out.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIterator() throws Exception {
|
||||
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
|
||||
|
Loading…
x
Reference in New Issue
Block a user