Skip to content

Commit 978e579

Browse files
committed
MOre tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1479753 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0fabee5 commit 978e579

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,16 @@ public void testDelimeterQuoted() throws IOException {
381381
printer.close();
382382
}
383383

384+
@Test
385+
public void testEOLQuoted() throws IOException {
386+
final StringWriter sw = new StringWriter();
387+
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar('\'').build());
388+
printer.print("a\rb\nc");
389+
printer.print("x\by\fz");
390+
assertEquals("'a\rb\nc',x\by\fz", sw.toString());
391+
printer.close();
392+
}
393+
384394
@Test
385395
public void testPlainEscaped() throws IOException {
386396
final StringWriter sw = new StringWriter();
@@ -401,6 +411,16 @@ public void testDelimiterEscaped() throws IOException {
401411
printer.close();
402412
}
403413

414+
@Test
415+
public void testEOLEscaped() throws IOException {
416+
final StringWriter sw = new StringWriter();
417+
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).withEscape('!').build());
418+
printer.print("a\rb\nc");
419+
printer.print("x\fy\bz");
420+
assertEquals("a!rb!nc,x\fy\bz", sw.toString());
421+
printer.close();
422+
}
423+
404424
@Test
405425
public void testPlainPlain() throws IOException {
406426
final StringWriter sw = new StringWriter();
@@ -421,4 +441,14 @@ public void testDelimiterPlain() throws IOException {
421441
printer.close();
422442
}
423443

444+
@Test
445+
public void testEOLPlain() throws IOException {
446+
final StringWriter sw = new StringWriter();
447+
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).build());
448+
printer.print("a\rb\nc");
449+
printer.print("x\fy\bz");
450+
assertEquals("a\rb\nc,x\fy\bz", sw.toString());
451+
printer.close();
452+
}
453+
424454
}

0 commit comments

Comments
 (0)