File tree 2 files changed +20
-3
lines changed
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -2602,9 +2602,6 @@ boolean useRow(final long rowNum) {
2602
2602
* @throws IllegalArgumentException Throw when any attribute is invalid or inconsistent with other attributes.
2603
2603
*/
2604
2604
private void validate () throws IllegalArgumentException {
2605
- if (containsLineBreak (delimiter )) {
2606
- throw new IllegalArgumentException ("The delimiter cannot be a line break" );
2607
- }
2608
2605
if (quoteCharacter != null && contains (delimiter , quoteCharacter .charValue ())) { // Explicit (un)boxing is intentional
2609
2606
throw new IllegalArgumentException ("The quoteChar character and the delimiter cannot be the same ('" + quoteCharacter + "')" );
2610
2607
}
Original file line number Diff line number Diff line change @@ -88,6 +88,16 @@ public void testBuildVsGet() {
88
88
assertNotSame (builder .get (), builder .build ());
89
89
}
90
90
91
+ @ Test
92
+ public void testDelimiterCharLineBreakCrThrowsException1 () {
93
+ assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .builder ().setDelimiter (Constants .CR ).get ());
94
+ }
95
+
96
+ @ Test
97
+ public void testDelimiterCharLineBreakLfThrowsException1 () {
98
+ assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .builder ().setDelimiter (Constants .LF ).get ());
99
+ }
100
+
91
101
@ Test
92
102
public void testDelimiterEmptyStringThrowsException1 () {
93
103
assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .builder ().setDelimiter ("" ).get ());
@@ -120,6 +130,16 @@ public void testDelimiterSameAsRecordSeparatorThrowsException() {
120
130
assertThrows (IllegalArgumentException .class , () -> CSVFormat .newFormat (CR ));
121
131
}
122
132
133
+ @ Test
134
+ public void testDelimiterStringLineBreakCrThrowsException1 () {
135
+ assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .builder ().setDelimiter (String .valueOf (Constants .CR )).get ());
136
+ }
137
+
138
+ @ Test
139
+ public void testDelimiterStringLineBreakLfThrowsException1 () {
140
+ assertThrows (IllegalArgumentException .class , () -> CSVFormat .DEFAULT .builder ().setDelimiter (String .valueOf (Constants .LF )).get ());
141
+ }
142
+
123
143
@ Test
124
144
public void testDuplicateHeaderElements () {
125
145
final String [] header = { "A" , "A" };
You can’t perform that action at this time.
0 commit comments