Use varargs.

This commit is contained in:
Gary Gregory 2021-02-28 16:23:41 -05:00
parent d400a04b15
commit a34cedaca7
2 changed files with 9 additions and 9 deletions

View File

@ -166,28 +166,28 @@ public class CSVFormatTest {
for (final Class<?> cls : method.getParameterTypes()) {
final String type = cls.getCanonicalName();
if ("boolean".equals(type)) {
final Object defTrue = method.invoke(CSVFormat.DEFAULT, new Object[] {Boolean.TRUE});
final Object defFalse = method.invoke(CSVFormat.DEFAULT, new Object[] {Boolean.FALSE});
final Object defTrue = method.invoke(CSVFormat.DEFAULT, Boolean.TRUE);
final Object defFalse = method.invoke(CSVFormat.DEFAULT, Boolean.FALSE);
assertNotEquals(name, type ,defTrue, defFalse);
} else if ("char".equals(type)){
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {'a'});
final Object b = method.invoke(CSVFormat.DEFAULT, new Object[] {'b'});
final Object a = method.invoke(CSVFormat.DEFAULT, 'a');
final Object b = method.invoke(CSVFormat.DEFAULT, 'b');
assertNotEquals(name, type, a, b);
} else if ("java.lang.Character".equals(type)){
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {null});
final Object b = method.invoke(CSVFormat.DEFAULT, new Object[] {new Character('d')});
final Object b = method.invoke(CSVFormat.DEFAULT, new Character('d'));
assertNotEquals(name, type, a, b);
} else if ("java.lang.String".equals(type)){
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {null});
final Object b = method.invoke(CSVFormat.DEFAULT, new Object[] {"e"});
final Object b = method.invoke(CSVFormat.DEFAULT, "e");
assertNotEquals(name, type, a, b);
} else if ("java.lang.String[]".equals(type)){
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {new String[] {null, null}});
final Object b = method.invoke(CSVFormat.DEFAULT, new Object[] {new String[] {"f", "g"}});
assertNotEquals(name, type, a, b);
} else if ("org.apache.commons.csv.QuoteMode".equals(type)){
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {QuoteMode.MINIMAL});
final Object b = method.invoke(CSVFormat.DEFAULT, new Object[] {QuoteMode.ALL});
final Object a = method.invoke(CSVFormat.DEFAULT, QuoteMode.MINIMAL);
final Object b = method.invoke(CSVFormat.DEFAULT, QuoteMode.ALL);
assertNotEquals(name, type, a, b);
} else if ("java.lang.Object[]".equals(type)){
final Object a = method.invoke(CSVFormat.DEFAULT, new Object[] {new Object[] {null, null}});

View File

@ -547,7 +547,7 @@ public class CSVPrinterTest {
final StringWriter sw = new StringWriter();
try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.EXCEL)) {
printer.printRecords(
Arrays.asList(new List[] { Arrays.asList("r1c1", "r1c2"), Arrays.asList("r2c1", "r2c2") }));
Arrays.asList(Arrays.asList("r1c1", "r1c2"), Arrays.asList("r2c1", "r2c2")));
assertEquals("r1c1,r1c2" + recordSeparator + "r2c1,r2c2" + recordSeparator, sw.toString());
}
}