@@ -289,6 +289,18 @@ public void testCloseWithFlushOn() throws IOException {
289289 }
290290 }
291291
292+ @ Test
293+ public void testCRComment () throws IOException {
294+ final StringWriter sw = new StringWriter ();
295+ final Object value = "abc" ;
296+ try (final CSVPrinter printer = new CSVPrinter (sw , CSVFormat .DEFAULT .withCommentMarker ('#' ))) {
297+ printer .print (value );
298+ printer .printComment ("This is a comment\r \n on multiple lines\r this is next comment\r " );
299+ assertEquals ("abc" + recordSeparator + "# This is a comment" + recordSeparator + "# on multiple lines"
300+ + recordSeparator + "# this is next comment" + recordSeparator + "# " + recordSeparator , sw .toString ());
301+ }
302+ }
303+
292304 @ Test
293305 public void testCSV135 () throws IOException {
294306 final List <String > list = new LinkedList <>();
@@ -909,6 +921,16 @@ public void testNewCsvPrinterNullAppendableFormat() {
909921 assertThrows (NullPointerException .class , () -> new CSVPrinter (null , CSVFormat .DEFAULT ));
910922 }
911923
924+ @ Test
925+ public void testNotFlushable () throws IOException {
926+ final Appendable out = new StringBuilder ();
927+ try (final CSVPrinter printer = new CSVPrinter (out , CSVFormat .DEFAULT )) {
928+ printer .printRecord ("a" , "b" , "c" );
929+ assertEquals ("a,b,c" + recordSeparator , out .toString ());
930+ printer .flush ();
931+ }
932+ }
933+
912934 @ Test
913935 public void testParseCustomNullValues () throws IOException {
914936 final StringWriter sw = new StringWriter ();
@@ -1447,6 +1469,7 @@ public void testRandomPostgreSqlText() throws Exception {
14471469 doRandom (CSVFormat .POSTGRESQL_TEXT , ITERATIONS_FOR_RANDOM_TEST );
14481470 }
14491471
1472+
14501473 @ Test
14511474 public void testRandomRfc4180 () throws Exception {
14521475 doRandom (CSVFormat .RFC4180 , ITERATIONS_FOR_RANDOM_TEST );
@@ -1457,7 +1480,6 @@ public void testRandomTdf() throws Exception {
14571480 doRandom (CSVFormat .TDF , ITERATIONS_FOR_RANDOM_TEST );
14581481 }
14591482
1460-
14611483 @ Test
14621484 public void testSingleLineComment () throws IOException {
14631485 final StringWriter sw = new StringWriter ();
@@ -1538,28 +1560,6 @@ public void testTrimOnTwoColumns() throws IOException {
15381560 }
15391561 }
15401562
1541- @ Test
1542- public void testNotFlushable () throws IOException {
1543- final Appendable out = new StringBuilder ();
1544- try (final CSVPrinter printer = new CSVPrinter (out , CSVFormat .DEFAULT )) {
1545- printer .printRecord ("a" , "b" , "c" );
1546- assertEquals ("a,b,c" + recordSeparator , out .toString ());
1547- printer .flush ();
1548- }
1549- }
1550-
1551- @ Test
1552- public void testCRComment () throws IOException {
1553- final StringWriter sw = new StringWriter ();
1554- final Object value = "abc" ;
1555- try (final CSVPrinter printer = new CSVPrinter (sw , CSVFormat .DEFAULT .withCommentMarker ('#' ))) {
1556- printer .print (value );
1557- printer .printComment ("This is a comment\r \n on multiple lines\r this is next comment\r " );
1558- assertEquals ("abc" + recordSeparator + "# This is a comment" + recordSeparator + "# on multiple lines"
1559- + recordSeparator + "# this is next comment" + recordSeparator + "# " + recordSeparator , sw .toString ());
1560- }
1561- }
1562-
15631563 private String [] toFirstRecordValues (final String expected , final CSVFormat format ) throws IOException {
15641564 return CSVParser .parse (expected , format ).getRecords ().get (0 ).values ();
15651565 }
0 commit comments