Skip to content

Commit 7b72c50

Browse files
committed
Merge some string literals
1 parent 9658373 commit 7b72c50

File tree

5 files changed

+51
-13
lines changed

5 files changed

+51
-13
lines changed

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ void testToStringAndWithCommentMarkerTakingCharacter() {
12181218
Assertions.assertNotEquals(csvFormat, csvFormatTwo);
12191219

12201220
Assertions.assertNotEquals(csvFormatTwo, csvFormat);
1221-
assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> " + "RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false",
1221+
assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false",
12221222
csvFormatTwo.toString());
12231223

12241224
}

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ class CSVParserTest {
7979

8080
private static final String UTF_8_NAME = UTF_8.name();
8181

82-
private static final String CSV_INPUT = "a,b,c,d\n" + " a , b , 1 2 \n" + "\"foo baar\", b,\n" +
82+
// @formatter:off
83+
private static final String CSV_INPUT = "a,b,c,d\n" +
84+
" a , b , 1 2 \n" +
85+
"\"foo baar\", b,\n" +
8386
// + " \"foo\n,,\n\"\",,\n\\\"\",d,e\n";
8487
" \"foo\n,,\n\"\",,\n\"\"\",d,e\n"; // changed to use standard CSV escaping
88+
// @formatter:on
8589

8690
private static final String CSV_INPUT_1 = "a,b,c,d";
8791

@@ -181,7 +185,7 @@ void testBackslashEscaping2() throws IOException {
181185
// We will test with a forward slash as the escape char, and a single
182186
// quote as the encapsulator.
183187
// @formatter:off
184-
final String code = "" + " , , \n" + // 1)
188+
final String code = " , , \n" + // 1)
185189
" \t , , \n" + // 2)
186190
" // , /, , /,\n" + // 3)
187191
"";
@@ -201,8 +205,17 @@ void testBackslashEscaping2() throws IOException {
201205
@Test
202206
@Disabled
203207
void testBackslashEscapingOld() throws IOException {
204-
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" +
205-
"\"a\\\\\"\n" + "a\\,b\n" + "\"a\\\\,b\"";
208+
// @formatter:off
209+
final String code = "one,two,three\n" +
210+
"on\\\"e,two\n" +
211+
"on\"e,two\n" +
212+
"one,\"tw\\\"o\"\n" +
213+
"one,\"t\\,wo\"\n" +
214+
"one,two,\"th,ree\"\n" +
215+
"\"a\\\\\"\n" +
216+
"a\\,b\n" +
217+
"\"a\\\\,b\"";
218+
// @formatter:on
206219
final String[][] res = { { "one", "two", "three" }, { "on\\\"e", "two" }, { "on\"e", "two" }, { "one", "tw\"o" }, { "one", "t\\,wo" }, // backslash in
207220
// quotes only
208221
// escapes a
@@ -417,7 +430,7 @@ void testCSV57() throws Exception {
417430
@Test
418431
void testDefaultFormat() throws IOException {
419432
// @formatter:off
420-
final String code = "" + "a,b#\n" + // 1)
433+
final String code = "a,b#\n" + // 1)
421434
"\"\n\",\" \",#\n" + // 2)
422435
"#,\"\"\n" + // 3)
423436
"# Final comment\n" // 4)
@@ -548,7 +561,7 @@ void testEndOfFileBehaviorExcel() throws Exception {
548561

549562
@Test
550563
void testExcelFormat1() throws IOException {
551-
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";
564+
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";
552565
final String[][] res = { { "value1", "value2", "value3", "value4" }, { "a", "b", "c", "d" }, { " x", "", "", "" }, { "" },
553566
{ "\"hello\"", " \"world\"", "abc\ndef", "" } };
554567
try (CSVParser parser = CSVParser.parse(code, CSVFormat.EXCEL)) {

src/test/java/org/apache/commons/csv/LexerTest.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ void testBackspace() throws Exception {
121121

122122
@Test
123123
void testComments() throws IOException {
124-
final String code = "first,line,\n" + "second,line,tokenWith#no-comment\n" + "# comment line \n" +
125-
"third,line,#no-comment\n" + "# penultimate comment\n" + "# Final comment\n";
124+
// @formatter:off
125+
final String code = "first,line,\n" +
126+
"second,line,tokenWith#no-comment\n" +
127+
"# comment line \n" +
128+
"third,line,#no-comment\n" +
129+
"# penultimate comment\n" +
130+
"# Final comment\n";
131+
// @formatter:on
126132
final CSVFormat format = CSVFormat.DEFAULT.withCommentMarker('#');
127133
try (Lexer lexer = createLexer(code, format)) {
128134
assertNextToken(TOKEN, "first", lexer);
@@ -306,8 +312,21 @@ void testFF() throws Exception {
306312

307313
@Test
308314
void testIgnoreEmptyLines() throws IOException {
309-
final String code = "first,line,\n" + "\n" + "\n" + "second,line\n" + "\n" + "\n" + "third line \n" + "\n" +
310-
"\n" + "last, line \n" + "\n" + "\n" + "\n";
315+
// @formatter:off
316+
final String code = "first,line,\n" +
317+
"\n" +
318+
"\n" +
319+
"second,line\n" +
320+
"\n" +
321+
"\n" +
322+
"third line \n" +
323+
"\n" +
324+
"\n" +
325+
"last, line \n" +
326+
"\n" +
327+
"\n" +
328+
"\n";
329+
// @formatter:on
311330
final CSVFormat format = CSVFormat.DEFAULT.withIgnoreEmptyLines();
312331
try (Lexer lexer = createLexer(code, format)) {
313332
assertNextToken(TOKEN, "first", lexer);

src/test/java/org/apache/commons/csv/issues/JiraCsv148Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void testWithTrimEmpty() {
5555
.get();
5656
// @formatter:on
5757
assertEquals(
58-
"\"\",\"\",\"Single space on the left\",\"Single space on the right\"," + "\"Single spaces on both sides\",\"Multiple spaces on the left\"," +
58+
"\"\",\"\",\"Single space on the left\",\"Single space on the right\",\"Single spaces on both sides\",\"Multiple spaces on the left\"," +
5959
"\"Multiple spaces on the right\",\"Multiple spaces on both sides\"",
6060
format.format("", " ", " Single space on the left", "Single space on the right ", " Single spaces on both sides ",
6161
" Multiple spaces on the left", "Multiple spaces on the right ", " Multiple spaces on both sides "));

src/test/java/org/apache/commons/csv/issues/JiraCsv253Test.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ class JiraCsv253Test {
3737

3838
@Test
3939
void testHandleAbsentValues() throws IOException {
40-
final String source = "\"John\",,\"Doe\"\n" + ",\"AA\",123\n" + "\"John\",90,\n" + "\"\",,90";
40+
// @formatter:off
41+
final String source =
42+
"\"John\",,\"Doe\"\n" +
43+
",\"AA\",123\n" +
44+
"\"John\",90,\n" +
45+
"\"\",,90";
46+
// @formatter:on
4147
final CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setQuoteMode(QuoteMode.NON_NUMERIC).get();
4248
try (CSVParser parser = csvFormat.parse(new StringReader(source))) {
4349
final Iterator<CSVRecord> csvRecords = parser.iterator();

0 commit comments

Comments
 (0)