Skip to content

Commit cee5cc3

Browse files
committed
CSV-69 Eliminate CSVPrinterTest.equals(String[][], String[][]) by using Assert.assertArrayEquals
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1306833 13f79535-47bb-0310-9956-ffa450edef68
1 parent 9d00beb commit cee5cc3

2 files changed

Lines changed: 4 additions & 34 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void testBackslashEscaping2() throws IOException {
324324
List<CSVRecord> records = parser.getRecords();
325325
assertTrue(records.size() > 0);
326326

327-
assertTrue(CSVPrinterTest.equals(res, records));
327+
Utils.compare("", res, records);
328328
}
329329

330330
@Test
@@ -349,7 +349,7 @@ public void testDefaultFormat() throws IOException {
349349
List<CSVRecord> records = parser.getRecords();
350350
assertTrue(records.size() > 0);
351351

352-
assertTrue("Failed to parse without comments", CSVPrinterTest.equals(res, records));
352+
Utils.compare("Failed to parse without comments", res, records);
353353

354354
String[][] res_comments = {
355355
{"a", "b#"},
@@ -360,7 +360,7 @@ public void testDefaultFormat() throws IOException {
360360
parser = new CSVParser(code, format);
361361
records = parser.getRecords();
362362

363-
assertTrue("Failed to parse with comments",CSVPrinterTest.equals(res_comments, records));
363+
Utils.compare("Failed to parse with comments", res_comments, records);
364364
}
365365

366366
@Test

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

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -181,37 +181,7 @@ public void doOneRandom(CSVFormat format) throws Exception {
181181
CSVParser parser = new CSVParser(result, format);
182182
List<CSVRecord> parseResult = parser.getRecords();
183183

184-
if (!equals(lines, parseResult)) {
185-
System.out.println("Printer output :" + printable(result));
186-
assertTrue(false);
187-
}
188-
}
189-
190-
public static boolean equals(String[][] a, List<CSVRecord> b) {
191-
if (a.length != b.size()) {
192-
System.out.println("expected length :" + a.length);
193-
System.out.println("got :" + b.size());
194-
return false;
195-
}
196-
for (int i = 0; i < a.length; i++) {
197-
String[] linea = a[i];
198-
String[] lineb = b.get(i).values();
199-
if (linea.length != lineb.length) {
200-
System.out.println("[" + i + "] expected length :" + linea.length);
201-
System.out.println("[" + i + "] got :" + lineb.length);
202-
return false;
203-
}
204-
for (int j = 0; j < linea.length; j++) {
205-
String aval = linea[j];
206-
String bval = lineb[j];
207-
if (!aval.equals(bval)) {
208-
System.out.println("[" + i + "," + j + "] expected :" + printable(aval));
209-
System.out.println("[" + i + "," + j + "] got :" + printable(bval));
210-
return false;
211-
}
212-
}
213-
}
214-
return true;
184+
Utils.compare("Printer output :" + printable(result), lines, parseResult);
215185
}
216186

217187
public static String printable(String s) {

0 commit comments

Comments
 (0)