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
This commit is contained in:
parent
9d00beb352
commit
cee5cc3d74
|
@ -324,7 +324,7 @@ public class CSVParserTest {
|
|||
List<CSVRecord> 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<CSVRecord> 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
|
||||
|
|
|
@ -181,37 +181,7 @@ public class CSVPrinterTest {
|
|||
CSVParser parser = new CSVParser(result, format);
|
||||
List<CSVRecord> parseResult = parser.getRecords();
|
||||
|
||||
if (!equals(lines, parseResult)) {
|
||||
System.out.println("Printer output :" + printable(result));
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean equals(String[][] a, List<CSVRecord> 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) {
|
||||
|
|
Loading…
Reference in New Issue