commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1725424 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
Date Tue, 19 Jan 2016 06:20:08 GMT
Author: ggregory
Date: Tue Jan 19 06:20:08 2016
New Revision: 1725424

URL: http://svn.apache.org/viewvc?rev=1725424&view=rev
Log:
Update copyright for 2016 in NOTICE.txt

Modified:
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java?rev=1725424&r1=1725423&r2=1725424&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java Tue
Jan 19 06:20:08 2016
@@ -33,6 +33,7 @@ import java.sql.Statement;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Random;
 
@@ -232,6 +233,68 @@ public class CSVPrinterTest {
     }
 
     @Test
+    public void testJira135All() throws IOException {
+        CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+        StringWriter sw = new StringWriter();
+        CSVPrinter printer = new CSVPrinter(sw, format);
+        List<String> list = new LinkedList<String>();
+        list.add("\"");
+        list.add("\n");
+        list.add("\\");
+        printer.printRecord(list);
+        printer.close();
+        final String expected = "\"\\\"\",\"\\n\",\"\\\"" + format.getRecordSeparator();
+        assertEquals(expected, sw.toString());
+        String[] record0 = toFirstRecordValues(expected, format);
+        assertArrayEquals(expectNulls(list.toArray(), format), record0);
+    }
+    
+    @Test
+    public void testJira135_part3() throws IOException {
+        CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+        StringWriter sw = new StringWriter();
+        CSVPrinter printer = new CSVPrinter(sw, format);
+        List<String> list = new LinkedList<String>();
+        list.add("\\");
+        printer.printRecord(list);
+        printer.close();
+        final String expected = "\"\\\\\"" + format.getRecordSeparator();
+        assertEquals(expected, sw.toString());
+        String[] record0 = toFirstRecordValues(expected, format);
+        assertArrayEquals(expectNulls(list.toArray(), format), record0);
+    }
+    
+    @Test
+    public void testJira135_part2() throws IOException {
+        CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+        StringWriter sw = new StringWriter();
+        CSVPrinter printer = new CSVPrinter(sw, format);
+        List<String> list = new LinkedList<String>();
+        list.add("\n");
+        printer.printRecord(list);
+        printer.close();
+        final String expected = "\"\\n\"" + format.getRecordSeparator();
+        assertEquals(expected, sw.toString());
+        String[] record0 = toFirstRecordValues(expected, format);
+        assertArrayEquals(expectNulls(list.toArray(), format), record0);
+    }
+    
+    @Test
+    public void testJira135_part1() throws IOException {
+        CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
+        StringWriter sw = new StringWriter();
+        CSVPrinter printer = new CSVPrinter(sw, format);
+        List<String> list = new LinkedList<String>();
+        list.add("\"");
+        printer.printRecord(list);
+        printer.close();
+        final String expected = "\"\\\"\"" + format.getRecordSeparator();
+        assertEquals(expected, sw.toString());
+        String[] record0 = toFirstRecordValues(expected, format);
+        assertArrayEquals(expectNulls(list.toArray(), format), record0);
+    }
+    
+    @Test
     public void testJdbcPrinter() throws IOException, ClassNotFoundException, SQLException
{
         final StringWriter sw = new StringWriter();
         final Connection connection = geH2Connection();



Mime
View raw message