This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b72c509 Merge some string literals
7b72c509 is described below

commit 7b72c509f73e05ca2bf2f0945a6a1cb03f87bd39
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sun Jul 20 17:36:44 2025 -0400

    Merge some string literals
---
 .../java/org/apache/commons/csv/CSVFormatTest.java |  2 +-
 .../java/org/apache/commons/csv/CSVParserTest.java | 25 +++++++++++++++-----
 .../java/org/apache/commons/csv/LexerTest.java     | 27 ++++++++++++++++++----
 .../apache/commons/csv/issues/JiraCsv148Test.java  |  2 +-
 .../apache/commons/csv/issues/JiraCsv253Test.java  |  8 ++++++-
 5 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/src/test/java/org/apache/commons/csv/CSVFormatTest.java 
b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
index 99c7dc52..d1d19f75 100644
--- a/src/test/java/org/apache/commons/csv/CSVFormatTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVFormatTest.java
@@ -1218,7 +1218,7 @@ class CSVFormatTest {
         Assertions.assertNotEquals(csvFormat, csvFormatTwo);
 
         Assertions.assertNotEquals(csvFormatTwo, csvFormat);
-        assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> " + 
"RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false",
+        assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> 
RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false",
                 csvFormatTwo.toString());
 
     }
diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java 
b/src/test/java/org/apache/commons/csv/CSVParserTest.java
index 22b1417c..d9dd4e54 100644
--- a/src/test/java/org/apache/commons/csv/CSVParserTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java
@@ -79,9 +79,13 @@ class CSVParserTest {
 
     private static final String UTF_8_NAME = UTF_8.name();
 
-    private static final String CSV_INPUT = "a,b,c,d\n" + " a , b , 1 2 \n" + 
"\"foo baar\", b,\n" +
+    // @formatter:off
+    private static final String CSV_INPUT = "a,b,c,d\n" +
+            " a , b , 1 2 \n" +
+            "\"foo baar\", b,\n" +
             // + " \"foo\n,,\n\"\",,\n\\\"\",d,e\n";
             "   \"foo\n,,\n\"\",,\n\"\"\",d,e\n"; // changed to use standard 
CSV escaping
+    // @formatter:on
 
     private static final String CSV_INPUT_1 = "a,b,c,d";
 
@@ -181,7 +185,7 @@ class CSVParserTest {
         // We will test with a forward slash as the escape char, and a single
         // quote as the encapsulator.
         // @formatter:off
-        final String code = "" + " , , \n" + // 1)
+        final String code = " , , \n" + // 1)
             " \t ,  , \n" + // 2)
             " // , /, , /,\n" + // 3)
             "";
@@ -201,8 +205,17 @@ class CSVParserTest {
     @Test
     @Disabled
     void testBackslashEscapingOld() throws IOException {
-        final String code = "one,two,three\n" + "on\\\"e,two\n" + 
"on\"e,two\n" + "one,\"tw\\\"o\"\n" + "one,\"t\\,wo\"\n" + 
"one,two,\"th,ree\"\n" +
-                "\"a\\\\\"\n" + "a\\,b\n" + "\"a\\\\,b\"";
+        // @formatter:off
+        final String code = "one,two,three\n" +
+                "on\\\"e,two\n" +
+                "on\"e,two\n" +
+                "one,\"tw\\\"o\"\n" +
+                "one,\"t\\,wo\"\n" +
+                "one,two,\"th,ree\"\n" +
+                "\"a\\\\\"\n" +
+                "a\\,b\n" +
+                "\"a\\\\,b\"";
+        // @formatter:on
         final String[][] res = { { "one", "two", "three" }, { "on\\\"e", "two" 
}, { "on\"e", "two" }, { "one", "tw\"o" }, { "one", "t\\,wo" }, // backslash in
                                                                                
                                                                // quotes only
                                                                                
                                                                // escapes a
@@ -417,7 +430,7 @@ class CSVParserTest {
     @Test
     void testDefaultFormat() throws IOException {
         // @formatter:off
-        final String code = "" + "a,b#\n" + // 1)
+        final String code = "a,b#\n" +      // 1)
             "\"\n\",\" \",#\n" +            // 2)
             "#,\"\"\n" +                    // 3)
             "# Final comment\n"             // 4)
@@ -548,7 +561,7 @@ class CSVParserTest {
 
     @Test
     void testExcelFormat1() throws IOException {
-        final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n  x,,," 
+ "\r\n\r\n\"\"\"hello\"\"\",\"  \"\"world\"\"\",\"abc\ndef\",\r\n";
+        final String code = "value1,value2,value3,value4\r\na,b,c,d\r\n  
x,,,\r\n\r\n\"\"\"hello\"\"\",\"  \"\"world\"\"\",\"abc\ndef\",\r\n";
         final String[][] res = { { "value1", "value2", "value3", "value4" }, { 
"a", "b", "c", "d" }, { "  x", "", "", "" }, { "" },
                 { "\"hello\"", "  \"world\"", "abc\ndef", "" } };
         try (CSVParser parser = CSVParser.parse(code, CSVFormat.EXCEL)) {
diff --git a/src/test/java/org/apache/commons/csv/LexerTest.java 
b/src/test/java/org/apache/commons/csv/LexerTest.java
index af0c69a7..e54e9336 100644
--- a/src/test/java/org/apache/commons/csv/LexerTest.java
+++ b/src/test/java/org/apache/commons/csv/LexerTest.java
@@ -121,8 +121,14 @@ class LexerTest {
 
     @Test
     void testComments() throws IOException {
-        final String code = "first,line,\n" + 
"second,line,tokenWith#no-comment\n" + "# comment line \n" +
-                "third,line,#no-comment\n" + "# penultimate comment\n" + "# 
Final comment\n";
+        // @formatter:off
+        final String code = "first,line,\n" +
+                "second,line,tokenWith#no-comment\n" +
+                "# comment line \n" +
+                "third,line,#no-comment\n" +
+                "# penultimate comment\n" +
+                "# Final comment\n";
+        // @formatter:on
         final CSVFormat format = CSVFormat.DEFAULT.withCommentMarker('#');
         try (Lexer lexer = createLexer(code, format)) {
             assertNextToken(TOKEN, "first", lexer);
@@ -306,8 +312,21 @@ class LexerTest {
 
     @Test
     void testIgnoreEmptyLines() throws IOException {
-        final String code = "first,line,\n" + "\n" + "\n" + "second,line\n" + 
"\n" + "\n" + "third line \n" + "\n" +
-                "\n" + "last, line \n" + "\n" + "\n" + "\n";
+        // @formatter:off
+        final String code = "first,line,\n" +
+                "\n" +
+                "\n" +
+                "second,line\n" +
+                "\n" +
+                "\n" +
+                "third line \n" +
+                "\n" +
+                "\n" +
+                "last, line \n" +
+                "\n" +
+                "\n" +
+                "\n";
+        // @formatter:on
         final CSVFormat format = CSVFormat.DEFAULT.withIgnoreEmptyLines();
         try (Lexer lexer = createLexer(code, format)) {
             assertNextToken(TOKEN, "first", lexer);
diff --git a/src/test/java/org/apache/commons/csv/issues/JiraCsv148Test.java 
b/src/test/java/org/apache/commons/csv/issues/JiraCsv148Test.java
index befe3b5c..67f1b785 100644
--- a/src/test/java/org/apache/commons/csv/issues/JiraCsv148Test.java
+++ b/src/test/java/org/apache/commons/csv/issues/JiraCsv148Test.java
@@ -55,7 +55,7 @@ class JiraCsv148Test {
             .get();
         // @formatter:on
         assertEquals(
-                "\"\",\"\",\"Single space on the left\",\"Single space on the 
right\"," + "\"Single spaces on both sides\",\"Multiple spaces on the left\"," +
+                "\"\",\"\",\"Single space on the left\",\"Single space on the 
right\",\"Single spaces on both sides\",\"Multiple spaces on the left\"," +
                         "\"Multiple spaces on the right\",\"Multiple spaces on 
both sides\"",
                 format.format("", " ", " Single space on the left", "Single 
space on the right ", " Single spaces on both sides ",
                         "   Multiple spaces on the left", "Multiple spaces on 
the right   ", "  Multiple spaces on both sides     "));
diff --git a/src/test/java/org/apache/commons/csv/issues/JiraCsv253Test.java 
b/src/test/java/org/apache/commons/csv/issues/JiraCsv253Test.java
index 13694085..13bb6a82 100644
--- a/src/test/java/org/apache/commons/csv/issues/JiraCsv253Test.java
+++ b/src/test/java/org/apache/commons/csv/issues/JiraCsv253Test.java
@@ -37,7 +37,13 @@ class JiraCsv253Test {
 
     @Test
     void testHandleAbsentValues() throws IOException {
-        final String source = "\"John\",,\"Doe\"\n" + ",\"AA\",123\n" + 
"\"John\",90,\n" + "\"\",,90";
+        // @formatter:off
+        final String source =
+                "\"John\",,\"Doe\"\n" +
+                ",\"AA\",123\n" +
+                "\"John\",90,\n" +
+                "\"\",,90";
+        // @formatter:on
         final CSVFormat csvFormat = 
CSVFormat.DEFAULT.builder().setQuoteMode(QuoteMode.NON_NUMERIC).get();
         try (CSVParser parser = csvFormat.parse(new StringReader(source))) {
             final Iterator<CSVRecord> csvRecords = parser.iterator();

Reply via email to