Skip to content

Commit 72ba42e

Browse files
committed
Add missing code coverage
1 parent 9134e95 commit 72ba42e

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ private void assertNotEquals(final String name, final String type, final Object
7979
}
8080
}
8181

82+
@Test
83+
public void testDelimiterEmptyStringThrowsException1() {
84+
assertThrows(IllegalArgumentException.class, () -> CSVFormat.DEFAULT.builder().setDelimiter("").build());
85+
}
86+
8287
@SuppressWarnings("deprecation")
8388
@Test
8489
public void testDelimiterSameAsCommentStartThrowsException_Deprecated() {
@@ -797,6 +802,22 @@ public void testNullRecordSeparatorCsv106__Deprecated() {
797802
assertFalse(formatStr.endsWith("null"));
798803
}
799804

805+
@Test
806+
public void testPrintRecord() throws IOException {
807+
final Appendable out = new StringBuilder();
808+
final CSVFormat format = CSVFormat.RFC4180;
809+
format.printRecord(out, "a", "b", "c");
810+
assertEquals("a,b,c" + format.getRecordSeparator(), out.toString());
811+
}
812+
813+
@Test
814+
public void testPrintRecordEmpty() throws IOException {
815+
final Appendable out = new StringBuilder();
816+
final CSVFormat format = CSVFormat.RFC4180;
817+
format.printRecord(out);
818+
assertEquals(format.getRecordSeparator(), out.toString());
819+
}
820+
800821
@Test
801822
public void testPrintWithEscapesEndWithCRLF() throws IOException {
802823
final Reader in = new StringReader("x,y,x\r\na,?b,c\r\n");
@@ -1419,9 +1440,4 @@ public void testWithSystemRecordSeparator() {
14191440
final CSVFormat formatWithRecordSeparator = CSVFormat.DEFAULT.withSystemRecordSeparator();
14201441
assertEquals(System.lineSeparator(), formatWithRecordSeparator.getRecordSeparator());
14211442
}
1422-
1423-
@Test
1424-
public void testDelimiterEmptyStringThrowsException1() {
1425-
assertThrows(IllegalArgumentException.class, () -> CSVFormat.DEFAULT.builder().setDelimiter("").build());
1426-
}
14271443
}

0 commit comments

Comments
 (0)