### Question:
RowFormat { public String format(Collection<?> values) { return format(values.toArray(new Object[0])); } RowFormat(String separator); String format(Collection<?> values); String format(Object[] values); static final String LINE_SEPARATOR; }### Answer:
@Test public void use_separator() { RowFormat rowFormat = new RowFormat("|"); assertEquals("1|2", rowFormat.format(new Object[]{ 1, 2 })); }
@Test public void format_date_as_iso() { RowFormat rowFormat = new RowFormat("|"); assertEquals("2010-02-03T21:22:23", rowFormat.format(new Object[]{ timestamp("2010-02-03 21:22:23") })); }
@Test public void quote_quotes() { RowFormat rowFormat = new RowFormat("|"); assertEquals("\"\"\"\"", rowFormat.format(new String[]{ "\"" })); }
@Test public void quote_line_separators() { RowFormat rowFormat = new RowFormat("|"); assertEquals("\"a\r\nb\"", rowFormat.format(new String[]{ "a\r\nb" })); }
@Test public void quote_field_separators() { RowFormat rowFormat = new RowFormat("|"); assertEquals("',' is not the separator and it isn't quoted", "a,b", rowFormat.format(new String[]{ "a,b" })); assertEquals("'|' is the separator and it is quoted", "\"a|b\"", rowFormat.format(new String[]{ "a|b" })); }