commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject commons-csv git commit: Break up testEscapeBackslash() method into individual tests.
Date Sun, 31 Jul 2016 06:42:55 GMT
Repository: commons-csv
Updated Branches:
  refs/heads/master d067c3ffe -> 1023690dc


Break up testEscapeBackslash() method into individual tests.

Project: http://git-wip-us.apache.org/repos/asf/commons-csv/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-csv/commit/1023690d
Tree: http://git-wip-us.apache.org/repos/asf/commons-csv/tree/1023690d
Diff: http://git-wip-us.apache.org/repos/asf/commons-csv/diff/1023690d

Branch: refs/heads/master
Commit: 1023690dc284afaf380b0cf3eb74c411e0663465
Parents: d067c3f
Author: Gary Gregory <ggregory@apache.org>
Authored: Sat Jul 30 23:42:51 2016 -0700
Committer: Gary Gregory <ggregory@apache.org>
Committed: Sat Jul 30 23:42:51 2016 -0700

----------------------------------------------------------------------
 .../org/apache/commons/csv/CSVPrinterTest.java  | 40 +++++++++++++-------
 1 file changed, 26 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-csv/blob/1023690d/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
index 664175c..86b852f 100644
--- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
@@ -53,6 +53,7 @@ import org.junit.Test;
  */
 public class CSVPrinterTest {
 
+    private static final char QUOTE_CH = '\'';
     private static final int ITERATIONS_FOR_RANDOM_TEST = 50000;
 
     private static String printable(final String s) {
@@ -290,35 +291,46 @@ public class CSVPrinterTest {
     }
 
     @Test
-    public void testEscapeBackslash() throws IOException {
+    public void testEscapeBackslash1() throws IOException {
         StringWriter sw = new StringWriter();
-        final char quoteChar = '\'';
-        final String eol = "\r\n";
-        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar)))
{
+        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(QUOTE_CH)))
{
             printer.print("\\");
         }
         assertEquals("'\\'", sw.toString());
+    }
 
-        sw = new StringWriter();
-        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar)))
{
+    @Test
+    public void testEscapeBackslash2() throws IOException {
+        StringWriter sw = new StringWriter();
+        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(QUOTE_CH)))
{
             printer.print("\\\r");
         }
         assertEquals("'\\\r'", sw.toString());
 
-        sw = new StringWriter();
-        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar)))
{
+    }
+
+    @Test
+    public void testEscapeBackslash3() throws IOException {
+        StringWriter sw = new StringWriter();
+        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(QUOTE_CH)))
{
             printer.print("X\\\r");
         }
         assertEquals("'X\\\r'", sw.toString());
+    }
 
-        sw = new StringWriter();
-        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar)))
{
-            printer.printRecord(new Object[] { "\\\r" });
+    @Test
+    public void testEscapeBackslash4() throws IOException {
+        StringWriter sw = new StringWriter();
+        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(QUOTE_CH)))
{
+            printer.print("\\\\");
         }
-        assertEquals("'\\\r'" + eol, sw.toString());
+        assertEquals("'\\\\'", sw.toString());
+    }
 
-        sw = new StringWriter();
-        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(quoteChar)))
{
+    @Test
+    public void testEscapeBackslash5() throws IOException {
+        StringWriter sw = new StringWriter();
+        try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(QUOTE_CH)))
{
             printer.print("\\\\");
         }
         assertEquals("'\\\\'", sw.toString());


Mime
View raw message