Sort members.

This commit is contained in:
Gary Gregory 2020-11-11 14:01:17 -05:00
parent 0aa7954bfa
commit 7aa3b46719
1 changed files with 23 additions and 23 deletions

View File

@ -289,6 +289,18 @@ public class CSVPrinterTest {
}
}
@Test
public void testCRComment() throws IOException {
final StringWriter sw = new StringWriter();
final Object value = "abc";
try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentMarker('#'))) {
printer.print(value);
printer.printComment("This is a comment\r\non multiple lines\rthis is next comment\r");
assertEquals("abc" + recordSeparator + "# This is a comment" + recordSeparator + "# on multiple lines"
+ recordSeparator + "# this is next comment" + recordSeparator + "# " + recordSeparator, sw.toString());
}
}
@Test
public void testCSV135() throws IOException {
final List<String> list = new LinkedList<>();
@ -909,6 +921,16 @@ public class CSVPrinterTest {
assertThrows(NullPointerException.class, () -> new CSVPrinter(null, CSVFormat.DEFAULT));
}
@Test
public void testNotFlushable() throws IOException {
final Appendable out = new StringBuilder();
try (final CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT)) {
printer.printRecord("a", "b", "c");
assertEquals("a,b,c" + recordSeparator, out.toString());
printer.flush();
}
}
@Test
public void testParseCustomNullValues() throws IOException {
final StringWriter sw = new StringWriter();
@ -1447,6 +1469,7 @@ public class CSVPrinterTest {
doRandom(CSVFormat.POSTGRESQL_TEXT, ITERATIONS_FOR_RANDOM_TEST);
}
@Test
public void testRandomRfc4180() throws Exception {
doRandom(CSVFormat.RFC4180, ITERATIONS_FOR_RANDOM_TEST);
@ -1457,7 +1480,6 @@ public class CSVPrinterTest {
doRandom(CSVFormat.TDF, ITERATIONS_FOR_RANDOM_TEST);
}
@Test
public void testSingleLineComment() throws IOException {
final StringWriter sw = new StringWriter();
@ -1538,28 +1560,6 @@ public class CSVPrinterTest {
}
}
@Test
public void testNotFlushable() throws IOException {
final Appendable out = new StringBuilder();
try (final CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT)) {
printer.printRecord("a", "b", "c");
assertEquals("a,b,c" + recordSeparator, out.toString());
printer.flush();
}
}
@Test
public void testCRComment() throws IOException {
final StringWriter sw = new StringWriter();
final Object value = "abc";
try (final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withCommentMarker('#'))) {
printer.print(value);
printer.printComment("This is a comment\r\non multiple lines\rthis is next comment\r");
assertEquals("abc" + recordSeparator + "# This is a comment" + recordSeparator + "# on multiple lines"
+ recordSeparator + "# this is next comment" + recordSeparator + "# " + recordSeparator, sw.toString());
}
}
private String[] toFirstRecordValues(final String expected, final CSVFormat format) throws IOException {
return CSVParser.parse(expected, format).getRecords().get(0).values();
}