From 978e5796e24f44cbe4e48527811d4f461b1e9e59 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Tue, 7 May 2013 02:21:38 +0000 Subject: [PATCH] MOre tests git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1479753 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/csv/CSVPrinterTest.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index 87066256..362b488b 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java @@ -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(); + } + }