MOre tests

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1479753 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2013-05-07 02:21:38 +00:00
parent 0fabee5f24
commit 978e5796e2
1 changed files with 30 additions and 0 deletions

View File

@ -381,6 +381,16 @@ public class CSVPrinterTest {
printer.close();
}
@Test
public void testEOLQuoted() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar('\'').build());
printer.print("a\rb\nc");
printer.print("x\by\fz");
assertEquals("'a\rb\nc',x\by\fz", sw.toString());
printer.close();
}
@Test
public void testPlainEscaped() throws IOException {
final StringWriter sw = new StringWriter();
@ -401,6 +411,16 @@ public class CSVPrinterTest {
printer.close();
}
@Test
public void testEOLEscaped() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).withEscape('!').build());
printer.print("a\rb\nc");
printer.print("x\fy\bz");
assertEquals("a!rb!nc,x\fy\bz", sw.toString());
printer.close();
}
@Test
public void testPlainPlain() throws IOException {
final StringWriter sw = new StringWriter();
@ -421,4 +441,14 @@ public class CSVPrinterTest {
printer.close();
}
@Test
public void testEOLPlain() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).build());
printer.print("a\rb\nc");
printer.print("x\fy\bz");
assertEquals("a\rb\nc,x\fy\bz", sw.toString());
printer.close();
}
}