diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index effa9630..8891195c 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -324,7 +324,7 @@ public class CSVParserTest { List records = parser.getRecords(); assertTrue(records.size() > 0); - assertTrue(CSVPrinterTest.equals(res, records)); + Utils.compare("", res, records); } @Test @@ -349,7 +349,7 @@ public class CSVParserTest { List records = parser.getRecords(); assertTrue(records.size() > 0); - assertTrue("Failed to parse without comments", CSVPrinterTest.equals(res, records)); + Utils.compare("Failed to parse without comments", res, records); String[][] res_comments = { {"a", "b#"}, @@ -360,7 +360,7 @@ public class CSVParserTest { parser = new CSVParser(code, format); records = parser.getRecords(); - assertTrue("Failed to parse with comments",CSVPrinterTest.equals(res_comments, records)); + Utils.compare("Failed to parse with comments", res_comments, records); } @Test diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index 52b7c56e..0be25f95 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java @@ -181,37 +181,7 @@ public class CSVPrinterTest { CSVParser parser = new CSVParser(result, format); List parseResult = parser.getRecords(); - if (!equals(lines, parseResult)) { - System.out.println("Printer output :" + printable(result)); - assertTrue(false); - } - } - - public static boolean equals(String[][] a, List b) { - if (a.length != b.size()) { - System.out.println("expected length :" + a.length); - System.out.println("got :" + b.size()); - return false; - } - for (int i = 0; i < a.length; i++) { - String[] linea = a[i]; - String[] lineb = b.get(i).values(); - if (linea.length != lineb.length) { - System.out.println("[" + i + "] expected length :" + linea.length); - System.out.println("[" + i + "] got :" + lineb.length); - return false; - } - for (int j = 0; j < linea.length; j++) { - String aval = linea[j]; - String bval = lineb[j]; - if (!aval.equals(bval)) { - System.out.println("[" + i + "," + j + "] expected :" + printable(aval)); - System.out.println("[" + i + "," + j + "] got :" + printable(bval)); - return false; - } - } - } - return true; + Utils.compare("Printer output :" + printable(result), lines, parseResult); } public static String printable(String s) {