@@ -53,7 +53,7 @@ public void testQuoteModeMinimal() throws Exception {
5353 }
5454
5555 @ Test
56- public void testQuoteModeNoneNumeric () throws Exception {
56+ public void testQuoteModeNonNumeric () throws Exception {
5757 CSVFormat format = CSVFormat .EXCEL
5858 .withNullString ("N/A" )
5959 .withIgnoreSurroundingSpaces (true )
@@ -65,4 +65,33 @@ public void testQuoteModeNoneNumeric() throws Exception {
6565
6666 Assert .assertEquals ("N/A,\" Hello\" ,N/A,\" World\" \r \n " , buffer .toString ());
6767 }
68+
69+ @ Test
70+ public void testWithoutNullString () throws Exception {
71+ CSVFormat format = CSVFormat .EXCEL
72+ //.withNullString("N/A")
73+ .withIgnoreSurroundingSpaces (true )
74+ .withQuoteMode (QuoteMode .ALL );
75+
76+ StringBuffer buffer = new StringBuffer ();
77+ CSVPrinter printer = new CSVPrinter (buffer , format );
78+ printer .printRecord (new Object [] { null , "Hello" , null , "World" });
79+
80+ Assert .assertEquals (",\" Hello\" ,,\" World\" \r \n " , buffer .toString ());
81+ }
82+
83+ @ Test
84+ public void testWithEmptyValues () throws Exception {
85+ CSVFormat format = CSVFormat .EXCEL
86+ .withNullString ("N/A" )
87+ .withIgnoreSurroundingSpaces (true )
88+ .withQuoteMode (QuoteMode .ALL );
89+
90+ StringBuffer buffer = new StringBuffer ();
91+ CSVPrinter printer = new CSVPrinter (buffer , format );
92+ printer .printRecord (new Object [] { "" , "Hello" , "" , "World" });
93+ //printer.printRecord(new Object[] { null, "Hello", null, "World" });
94+
95+ Assert .assertEquals ("\" \" ,\" Hello\" ,\" \" ,\" World\" \r \n " , buffer .toString ());
96+ }
6897}
0 commit comments