You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2017/07/10 20:27:34 UTC

commons-csv git commit: Add some tests from PR https://patch-diff.githubusercontent.com/raw/apache/commons-csv/pull/19. Closes #19.

Repository: commons-csv
Updated Branches:
  refs/heads/master 0bdca58fc -> e41d4841f


Add some tests from PR
https://patch-diff.githubusercontent.com/raw/apache/commons-csv/pull/19.
Closes #19.

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

Branch: refs/heads/master
Commit: e41d4841ff196ec74e1e09f1eb85b7160099f22e
Parents: 0bdca58
Author: TheRealHaui <no...@github.com>
Authored: Mon Jul 10 13:27:32 2017 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Mon Jul 10 13:27:32 2017 -0700

----------------------------------------------------------------------
 .../org/apache/commons/csv/CSVFormatTest.java   | 627 +++++++++++++++++++
 .../org/apache/commons/csv/CSVPrinterTest.java  |  44 ++
 2 files changed, 671 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-csv/blob/e41d4841/src/test/java/org/apache/commons/csv/CSVFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/csv/CSVFormatTest.java b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
index da73478..59a7629 100644
--- a/src/test/java/org/apache/commons/csv/CSVFormatTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.commons.csv;
 
+import static junit.framework.TestCase.assertNull;
 import static org.apache.commons.csv.CSVFormat.RFC4180;
 import static org.apache.commons.csv.Constants.CR;
 import static org.apache.commons.csv.Constants.CRLF;
@@ -27,6 +28,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -459,10 +461,635 @@ public class CSVFormatTest {
         assertTrue(formatWithFirstRecordAsHeader.getHeader().length == 0);
     }
 
+    @Test
+    public void testToStringAndWithCommentMarkerTakingCharacter() {
+
+        CSVFormat.Predefined cSVFormat_Predefined = CSVFormat.Predefined.Default;
+        CSVFormat cSVFormat = cSVFormat_Predefined.getFormat();
+
+        assertNull(cSVFormat.getEscapeCharacter());
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+
+        assertFalse(cSVFormat.getTrim());
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+
+        assertFalse(cSVFormat.getTrailingDelimiter());
+        assertEquals(',', cSVFormat.getDelimiter());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertEquals("\r\n", cSVFormat.getRecordSeparator());
+
+        assertFalse(cSVFormat.isCommentMarkerSet());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+
+        assertNull(cSVFormat.getNullString());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertTrue(cSVFormat.getIgnoreEmptyLines());
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+
+        Character character = Character.valueOf('n');
+
+        CSVFormat cSVFormatTwo = cSVFormat.withCommentMarker(character);
+
+        assertNull(cSVFormat.getEscapeCharacter());
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+
+        assertFalse(cSVFormat.getTrim());
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+
+        assertFalse(cSVFormat.getTrailingDelimiter());
+        assertEquals(',', cSVFormat.getDelimiter());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertEquals("\r\n", cSVFormat.getRecordSeparator());
+
+        assertFalse(cSVFormat.isCommentMarkerSet());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+
+        assertNull(cSVFormat.getNullString());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertTrue(cSVFormat.getIgnoreEmptyLines());
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+
+        assertFalse(cSVFormatTwo.isNullStringSet());
+        assertFalse(cSVFormatTwo.getAllowMissingColumnNames());
+
+        assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter());
+        assertNull(cSVFormatTwo.getNullString());
+
+        assertEquals(',', cSVFormatTwo.getDelimiter());
+        assertFalse(cSVFormatTwo.getTrailingDelimiter());
+
+        assertTrue(cSVFormatTwo.isCommentMarkerSet());
+        assertFalse(cSVFormatTwo.getIgnoreHeaderCase());
+
+        assertFalse(cSVFormatTwo.getTrim());
+        assertNull(cSVFormatTwo.getEscapeCharacter());
+
+        assertTrue(cSVFormatTwo.isQuoteCharacterSet());
+        assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces());
+
+        assertEquals("\r\n", cSVFormatTwo.getRecordSeparator());
+        assertNull(cSVFormatTwo.getQuoteMode());
+
+        assertEquals('n', (char)cSVFormatTwo.getCommentMarker());
+        assertFalse(cSVFormatTwo.getSkipHeaderRecord());
+
+        assertFalse(cSVFormatTwo.isEscapeCharacterSet());
+        assertTrue(cSVFormatTwo.getIgnoreEmptyLines());
+
+        assertNotSame(cSVFormat, cSVFormatTwo);
+        assertNotSame(cSVFormatTwo, cSVFormat);
+
+        assertFalse(cSVFormatTwo.equals(cSVFormat));
+
+        assertNull(cSVFormat.getEscapeCharacter());
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+
+        assertFalse(cSVFormat.getTrim());
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+
+        assertFalse(cSVFormat.getTrailingDelimiter());
+        assertEquals(',', cSVFormat.getDelimiter());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertEquals("\r\n", cSVFormat.getRecordSeparator());
+
+        assertFalse(cSVFormat.isCommentMarkerSet());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+
+        assertNull(cSVFormat.getNullString());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertTrue(cSVFormat.getIgnoreEmptyLines());
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+
+        assertFalse(cSVFormatTwo.isNullStringSet());
+        assertFalse(cSVFormatTwo.getAllowMissingColumnNames());
+
+        assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter());
+        assertNull(cSVFormatTwo.getNullString());
+
+        assertEquals(',', cSVFormatTwo.getDelimiter());
+        assertFalse(cSVFormatTwo.getTrailingDelimiter());
+
+        assertTrue(cSVFormatTwo.isCommentMarkerSet());
+        assertFalse(cSVFormatTwo.getIgnoreHeaderCase());
+
+        assertFalse(cSVFormatTwo.getTrim());
+        assertNull(cSVFormatTwo.getEscapeCharacter());
+
+        assertTrue(cSVFormatTwo.isQuoteCharacterSet());
+        assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces());
+
+        assertEquals("\r\n", cSVFormatTwo.getRecordSeparator());
+        assertNull(cSVFormatTwo.getQuoteMode());
+
+        assertEquals('n', (char)cSVFormatTwo.getCommentMarker());
+        assertFalse(cSVFormatTwo.getSkipHeaderRecord());
+
+        assertFalse(cSVFormatTwo.isEscapeCharacterSet());
+        assertTrue(cSVFormatTwo.getIgnoreEmptyLines());
+
+        assertNotSame(cSVFormat, cSVFormatTwo);
+        assertNotSame(cSVFormatTwo, cSVFormat);
+
+        assertFalse(cSVFormat.equals(cSVFormatTwo));
+
+        assertFalse(cSVFormatTwo.equals(cSVFormat));
+        assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> " +
+                        "RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false"
+                , cSVFormatTwo.toString());
+
+    }
+
+
+    @Test
+    public void testNewFormat() {
+
+        CSVFormat cSVFormat = CSVFormat.newFormat('X');
+
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+
+        assertNull(cSVFormat.getRecordSeparator());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertNull(cSVFormat.getCommentMarker());
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+        assertFalse(cSVFormat.getTrim());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertNull(cSVFormat.getEscapeCharacter());
+
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+        assertFalse(cSVFormat.getTrailingDelimiter());
+
+        assertEquals('X', cSVFormat.getDelimiter());
+        assertNull(cSVFormat.getNullString());
+
+        assertFalse(cSVFormat.isQuoteCharacterSet());
+        assertFalse(cSVFormat.isCommentMarkerSet());
+
+        assertNull(cSVFormat.getQuoteCharacter());
+        assertFalse(cSVFormat.getIgnoreEmptyLines());
+
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+
+        assertNull(cSVFormat.getRecordSeparator());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertNull(cSVFormat.getCommentMarker());
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+        assertFalse(cSVFormat.getTrim());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertNull(cSVFormat.getEscapeCharacter());
+
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+        assertFalse(cSVFormat.getTrailingDelimiter());
+
+        assertEquals('X', cSVFormat.getDelimiter());
+        assertNull(cSVFormat.getNullString());
+
+        assertFalse(cSVFormat.isQuoteCharacterSet());
+        assertFalse(cSVFormat.isCommentMarkerSet());
+
+        assertNull(cSVFormat.getQuoteCharacter());
+        assertFalse(cSVFormat.getIgnoreEmptyLines());
+
+    }
+
+
+    @Test
+    public void testWithHeaderComments() {
+
+        CSVFormat cSVFormat = CSVFormat.DEFAULT;
+
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+        assertFalse(cSVFormat.isCommentMarkerSet());
+
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertEquals(',', cSVFormat.getDelimiter());
+        assertTrue(cSVFormat.getIgnoreEmptyLines());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertEquals("\r\n", cSVFormat.getRecordSeparator());
+        assertFalse(cSVFormat.getTrailingDelimiter());
+
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+        assertFalse(cSVFormat.getTrim());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertNull(cSVFormat.getNullString());
+
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+        assertNull(cSVFormat.getEscapeCharacter());
+
+        Object[] objectArray = new Object[8];
+        CSVFormat cSVFormatTwo = cSVFormat.withHeaderComments(objectArray);
+
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+        assertFalse(cSVFormat.isCommentMarkerSet());
+
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertEquals(',', cSVFormat.getDelimiter());
+        assertTrue(cSVFormat.getIgnoreEmptyLines());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertEquals("\r\n", cSVFormat.getRecordSeparator());
+        assertFalse(cSVFormat.getTrailingDelimiter());
+
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+        assertFalse(cSVFormat.getTrim());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertNull(cSVFormat.getNullString());
+
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+        assertNull(cSVFormat.getEscapeCharacter());
+
+        assertFalse(cSVFormatTwo.getIgnoreHeaderCase());
+        assertNull(cSVFormatTwo.getQuoteMode());
+
+        assertTrue(cSVFormatTwo.getIgnoreEmptyLines());
+        assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces());
+
+        assertNull(cSVFormatTwo.getEscapeCharacter());
+        assertFalse(cSVFormatTwo.getTrim());
+
+        assertFalse(cSVFormatTwo.isEscapeCharacterSet());
+        assertTrue(cSVFormatTwo.isQuoteCharacterSet());
+
+        assertFalse(cSVFormatTwo.getSkipHeaderRecord());
+        assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter());
+
+        assertFalse(cSVFormatTwo.getAllowMissingColumnNames());
+        assertNull(cSVFormatTwo.getNullString());
+
+        assertFalse(cSVFormatTwo.isNullStringSet());
+        assertFalse(cSVFormatTwo.getTrailingDelimiter());
+
+        assertEquals("\r\n", cSVFormatTwo.getRecordSeparator());
+        assertEquals(',', cSVFormatTwo.getDelimiter());
+
+        assertNull(cSVFormatTwo.getCommentMarker());
+        assertFalse(cSVFormatTwo.isCommentMarkerSet());
+
+        assertNotSame(cSVFormat, cSVFormatTwo);
+        assertNotSame(cSVFormatTwo, cSVFormat);
+
+        assertTrue(cSVFormatTwo.equals(cSVFormat));
+
+        String string = cSVFormatTwo.format(objectArray);
+
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+        assertFalse(cSVFormat.isCommentMarkerSet());
+
+        assertFalse(cSVFormat.isEscapeCharacterSet());
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+        assertNull(cSVFormat.getQuoteMode());
+
+        assertEquals(',', cSVFormat.getDelimiter());
+        assertTrue(cSVFormat.getIgnoreEmptyLines());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertEquals("\r\n", cSVFormat.getRecordSeparator());
+        assertFalse(cSVFormat.getTrailingDelimiter());
+
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+        assertFalse(cSVFormat.getTrim());
+
+        assertFalse(cSVFormat.isNullStringSet());
+        assertNull(cSVFormat.getNullString());
+
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+        assertNull(cSVFormat.getEscapeCharacter());
+
+        assertFalse(cSVFormatTwo.getIgnoreHeaderCase());
+        assertNull(cSVFormatTwo.getQuoteMode());
+
+        assertTrue(cSVFormatTwo.getIgnoreEmptyLines());
+        assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces());
+
+        assertNull(cSVFormatTwo.getEscapeCharacter());
+        assertFalse(cSVFormatTwo.getTrim());
+
+        assertFalse(cSVFormatTwo.isEscapeCharacterSet());
+        assertTrue(cSVFormatTwo.isQuoteCharacterSet());
+
+        assertFalse(cSVFormatTwo.getSkipHeaderRecord());
+        assertEquals('\"', (char)cSVFormatTwo.getQuoteCharacter());
+
+        assertFalse(cSVFormatTwo.getAllowMissingColumnNames());
+        assertNull(cSVFormatTwo.getNullString());
+
+        assertFalse(cSVFormatTwo.isNullStringSet());
+        assertFalse(cSVFormatTwo.getTrailingDelimiter());
+
+        assertEquals("\r\n", cSVFormatTwo.getRecordSeparator());
+        assertEquals(',', cSVFormatTwo.getDelimiter());
+
+        assertNull(cSVFormatTwo.getCommentMarker());
+        assertFalse(cSVFormatTwo.isCommentMarkerSet());
+
+        assertNotSame(cSVFormat, cSVFormatTwo);
+        assertNotSame(cSVFormatTwo, cSVFormat);
+
+        assertNotNull(string);
+        assertTrue(cSVFormat.equals(cSVFormatTwo));
+
+        assertTrue(cSVFormatTwo.equals(cSVFormat));
+        assertEquals(",,,,,,,", string);
+
+    }
+
+
+    @Test  //I assume this to be a defect.
+    public void testFormatThrowsNullPointerException() {
+
+        CSVFormat cSVFormat = CSVFormat.MYSQL;
+
+        try {
+            cSVFormat.format(null);
+            fail("Expecting exception: NullPointerException");
+        } catch(NullPointerException e) {
+            assertEquals(CSVFormat.class.getName(), e.getStackTrace()[0].getClassName());
+        }
+
+    }
+
+
+    @Test
+    public void testEqualsOne() {
+
+        CSVFormat cSVFormatOne = CSVFormat.INFORMIX_UNLOAD;
+        CSVFormat cSVFormatTwo = CSVFormat.MYSQL;
+
+
+        assertEquals('\\', (char)cSVFormatOne.getEscapeCharacter());
+        assertNull(cSVFormatOne.getQuoteMode());
+
+        assertTrue(cSVFormatOne.getIgnoreEmptyLines());
+        assertFalse(cSVFormatOne.getSkipHeaderRecord());
+
+        assertFalse(cSVFormatOne.getIgnoreHeaderCase());
+        assertNull(cSVFormatOne.getCommentMarker());
+
+        assertFalse(cSVFormatOne.isCommentMarkerSet());
+        assertTrue(cSVFormatOne.isQuoteCharacterSet());
+
+        assertEquals('|', cSVFormatOne.getDelimiter());
+        assertFalse(cSVFormatOne.getAllowMissingColumnNames());
+
+        assertTrue(cSVFormatOne.isEscapeCharacterSet());
+        assertEquals("\n", cSVFormatOne.getRecordSeparator());
+
+        assertEquals('\"', (char)cSVFormatOne.getQuoteCharacter());
+        assertFalse(cSVFormatOne.getTrailingDelimiter());
+
+        assertFalse(cSVFormatOne.getTrim());
+        assertFalse(cSVFormatOne.isNullStringSet());
+
+        assertNull(cSVFormatOne.getNullString());
+        assertFalse(cSVFormatOne.getIgnoreSurroundingSpaces());
+
+
+        assertTrue(cSVFormatTwo.isEscapeCharacterSet());
+        assertNull(cSVFormatTwo.getQuoteCharacter());
+
+        assertFalse(cSVFormatTwo.getAllowMissingColumnNames());
+        assertEquals(QuoteMode.ALL_NON_NULL, cSVFormatTwo.getQuoteMode());
+
+        assertEquals('\t', cSVFormatTwo.getDelimiter());
+        assertEquals("\n", cSVFormatTwo.getRecordSeparator());
+
+        assertFalse(cSVFormatTwo.isQuoteCharacterSet());
+        assertTrue(cSVFormatTwo.isNullStringSet());
+
+        assertEquals('\\', (char)cSVFormatTwo.getEscapeCharacter());
+        assertFalse(cSVFormatTwo.getIgnoreHeaderCase());
+
+        assertFalse(cSVFormatTwo.getTrim());
+        assertFalse(cSVFormatTwo.getIgnoreEmptyLines());
+
+        assertEquals("\\N", cSVFormatTwo.getNullString());
+        assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces());
+
+        assertFalse(cSVFormatTwo.getTrailingDelimiter());
+        assertFalse(cSVFormatTwo.getSkipHeaderRecord());
+
+        assertNull(cSVFormatTwo.getCommentMarker());
+        assertFalse(cSVFormatTwo.isCommentMarkerSet());
+
+        assertNotSame(cSVFormatTwo, cSVFormatOne);
+        assertFalse(cSVFormatTwo.equals(cSVFormatOne));
+
+        assertEquals('\\', (char)cSVFormatOne.getEscapeCharacter());
+        assertNull(cSVFormatOne.getQuoteMode());
+
+        assertTrue(cSVFormatOne.getIgnoreEmptyLines());
+        assertFalse(cSVFormatOne.getSkipHeaderRecord());
+
+        assertFalse(cSVFormatOne.getIgnoreHeaderCase());
+        assertNull(cSVFormatOne.getCommentMarker());
+
+        assertFalse(cSVFormatOne.isCommentMarkerSet());
+        assertTrue(cSVFormatOne.isQuoteCharacterSet());
+
+        assertEquals('|', cSVFormatOne.getDelimiter());
+        assertFalse(cSVFormatOne.getAllowMissingColumnNames());
+
+        assertTrue(cSVFormatOne.isEscapeCharacterSet());
+        assertEquals("\n", cSVFormatOne.getRecordSeparator());
+
+        assertEquals('\"', (char)cSVFormatOne.getQuoteCharacter());
+        assertFalse(cSVFormatOne.getTrailingDelimiter());
+
+        assertFalse(cSVFormatOne.getTrim());
+        assertFalse(cSVFormatOne.isNullStringSet());
+
+        assertNull(cSVFormatOne.getNullString());
+        assertFalse(cSVFormatOne.getIgnoreSurroundingSpaces());
+
+        assertTrue(cSVFormatTwo.isEscapeCharacterSet());
+        assertNull(cSVFormatTwo.getQuoteCharacter());
+
+        assertFalse(cSVFormatTwo.getAllowMissingColumnNames());
+        assertEquals(QuoteMode.ALL_NON_NULL, cSVFormatTwo.getQuoteMode());
+
+        assertEquals('\t', cSVFormatTwo.getDelimiter());
+        assertEquals("\n", cSVFormatTwo.getRecordSeparator());
+
+        assertFalse(cSVFormatTwo.isQuoteCharacterSet());
+        assertTrue(cSVFormatTwo.isNullStringSet());
+
+        assertEquals('\\', (char)cSVFormatTwo.getEscapeCharacter());
+        assertFalse(cSVFormatTwo.getIgnoreHeaderCase());
+
+        assertFalse(cSVFormatTwo.getTrim());
+        assertFalse(cSVFormatTwo.getIgnoreEmptyLines());
+
+        assertEquals("\\N", cSVFormatTwo.getNullString());
+        assertFalse(cSVFormatTwo.getIgnoreSurroundingSpaces());
+
+        assertFalse(cSVFormatTwo.getTrailingDelimiter());
+        assertFalse(cSVFormatTwo.getSkipHeaderRecord());
+
+        assertNull(cSVFormatTwo.getCommentMarker());
+        assertFalse(cSVFormatTwo.isCommentMarkerSet());
+
+        assertNotSame(cSVFormatOne, cSVFormatTwo);
+        assertNotSame(cSVFormatTwo, cSVFormatOne);
+
+        assertFalse(cSVFormatOne.equals(cSVFormatTwo));
+        assertFalse(cSVFormatTwo.equals(cSVFormatOne));
+
+        assertFalse(cSVFormatTwo.equals(cSVFormatOne));
+
+    }
+
+
+    @Test
+    public void testEqualsWithNull() {
+
+        CSVFormat cSVFormat = CSVFormat.POSTGRESQL_TEXT;
+
+        assertEquals('\"', (char)cSVFormat.getEscapeCharacter());
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+
+        assertFalse(cSVFormat.getTrailingDelimiter());
+        assertFalse(cSVFormat.getTrim());
+
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+        assertEquals("\\N", cSVFormat.getNullString());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertTrue(cSVFormat.isEscapeCharacterSet());
+
+        assertFalse(cSVFormat.isCommentMarkerSet());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+        assertEquals(QuoteMode.ALL_NON_NULL, cSVFormat.getQuoteMode());
+
+        assertEquals('\t', cSVFormat.getDelimiter());
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+
+        assertEquals("\n", cSVFormat.getRecordSeparator());
+        assertFalse(cSVFormat.getIgnoreEmptyLines());
+
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+        assertTrue(cSVFormat.isNullStringSet());
+
+        assertEquals('\"', (char)cSVFormat.getEscapeCharacter());
+        assertFalse(cSVFormat.getIgnoreSurroundingSpaces());
+
+        assertFalse(cSVFormat.getTrailingDelimiter());
+        assertFalse(cSVFormat.getTrim());
+
+        assertTrue(cSVFormat.isQuoteCharacterSet());
+        assertEquals("\\N", cSVFormat.getNullString());
+
+        assertFalse(cSVFormat.getIgnoreHeaderCase());
+        assertTrue(cSVFormat.isEscapeCharacterSet());
+
+        assertFalse(cSVFormat.isCommentMarkerSet());
+        assertNull(cSVFormat.getCommentMarker());
+
+        assertFalse(cSVFormat.getAllowMissingColumnNames());
+        assertEquals(QuoteMode.ALL_NON_NULL, cSVFormat.getQuoteMode());
+
+        assertEquals('\t', cSVFormat.getDelimiter());
+        assertFalse(cSVFormat.getSkipHeaderRecord());
+
+        assertEquals("\n", cSVFormat.getRecordSeparator());
+        assertFalse(cSVFormat.getIgnoreEmptyLines());
+
+        assertEquals('\"', (char)cSVFormat.getQuoteCharacter());
+        assertTrue(cSVFormat.isNullStringSet());
+
+        assertFalse(cSVFormat.equals( null));
+
+    }
+
+
+    @Test
+    public void testToString() {
+
+        CSVFormat cSVFormat = CSVFormat.POSTGRESQL_TEXT;
+        String string = cSVFormat.INFORMIX_UNLOAD.toString();
+
+        assertEquals("Delimiter=<|> Escape=<\\> QuoteChar=<\"> RecordSeparator=<\n> EmptyLines:ignored SkipHeaderRecord:false", string);
+
+    }
+
+
+    @Test
+    public void testHashCodeAndWithIgnoreHeaderCase() {
+
+        CSVFormat cSVFormat = CSVFormat.INFORMIX_UNLOAD_CSV;
+        CSVFormat cSVFormatTwo = cSVFormat.withIgnoreHeaderCase();
+        cSVFormatTwo.hashCode();
+
+        assertTrue(cSVFormatTwo.getIgnoreHeaderCase());
+        assertFalse(cSVFormatTwo.getTrailingDelimiter());
+
+        assertTrue(cSVFormatTwo.equals(cSVFormat));
+        assertFalse(cSVFormatTwo.getAllowMissingColumnNames());
+
+        assertFalse(cSVFormatTwo.getTrim());
+
+    }
+
     public enum Header {
         Name, Email, Phone
     }
 
     public enum EmptyEnum {
     }
+
 }

http://git-wip-us.apache.org/repos/asf/commons-csv/blob/e41d4841/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 a74ed25..0c831ee 100644
--- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
@@ -22,12 +22,14 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 
+import java.io.CharArrayWriter;
 import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
+import java.sql.BatchUpdateException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -35,13 +37,17 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
 import java.util.Random;
+import java.util.Vector;
 
 import org.apache.commons.io.FileUtils;
+import org.h2.value.Value;
+import org.h2.value.ValueArray;
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -1269,4 +1275,42 @@ public class CSVPrinterTest {
     private String[] toFirstRecordValues(final String expected, final CSVFormat format) throws IOException {
         return CSVParser.parse(expected, format).getRecords().get(0).values();
     }
+
+    @Test
+    public void testPrintRecordsWithResultSetOneRow() throws IOException, SQLException {
+        try (CSVPrinter csvPrinter = CSVFormat.MYSQL.printer()) {
+            Value[] valueArray = new Value[0];
+            ValueArray valueArrayTwo = ValueArray.get(valueArray);
+            try (ResultSet resultSet = valueArrayTwo.getResultSet()) {
+                csvPrinter.printRecords(resultSet);
+                assertEquals(0, resultSet.getRow());
+            }
+        }
+    }
+
+    @Test
+    public void testPrintRecordsWithObjectArray() throws IOException {
+        CharArrayWriter charArrayWriter = new CharArrayWriter(0);
+        try (CSVPrinter csvPrinter = CSVFormat.INFORMIX_UNLOAD.print(charArrayWriter)) {
+            HashSet<BatchUpdateException> hashSet = new HashSet<>();
+            Object[] objectArray = new Object[6];
+            objectArray[3] = hashSet;
+            csvPrinter.printRecords(objectArray);
+        }
+        assertEquals(6, charArrayWriter.size());
+        assertEquals("\n\n\n\n\n\n", charArrayWriter.toString());
+    }
+
+
+    @Test
+    public void testPrintRecordsWithEmptyVector() throws IOException {
+        try (CSVPrinter csvPrinter = CSVFormat.POSTGRESQL_TEXT.printer()) {
+            Vector<CSVFormatTest.EmptyEnum> vector = new Vector<>();
+            int expectedCapacity = 23;
+            vector.setSize(expectedCapacity);
+            csvPrinter.printRecords(vector);
+            assertEquals(expectedCapacity, vector.capacity());
+        }
+    }
+
 }