File tree Expand file tree Collapse file tree
main/java/org/apache/commons/csv
test/java/org/apache/commons/csv Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,12 +205,12 @@ void validate() throws IllegalStateException {
205205 "')" );
206206 }
207207
208- if (quoteChar != null && quoteChar == commentStart ) {
208+ if (quoteChar != null && quoteChar . equals ( commentStart ) ) {
209209 throw new IllegalStateException ("The comment start character and the quoteChar cannot be the same ('" + commentStart +
210210 "')" );
211211 }
212212
213- if (escape != null && escape == commentStart ) {
213+ if (escape != null && escape . equals ( commentStart ) ) {
214214 throw new IllegalStateException ("The comment start and the escape character cannot be the same ('" + commentStart + "')" );
215215 }
216216
Original file line number Diff line number Diff line change @@ -140,6 +140,14 @@ public void testValidation() {
140140 // expected
141141 }
142142
143+ // Cannot assume that callers won't use different Character objects
144+ try {
145+ format .withQuoteChar (new Character ('!' )).withCommentStart ('!' ).validate ();
146+ fail ();
147+ } catch (final IllegalStateException e ) {
148+ // expected
149+ }
150+
143151 format .withQuoteChar (null ).withCommentStart (null ).validate ();
144152
145153 try {
@@ -149,6 +157,14 @@ public void testValidation() {
149157 // expected
150158 }
151159
160+ // Cannot assume that callers won't use different Character objects
161+ try {
162+ format .withEscape (new Character ('!' )).withCommentStart (new Character ('!' )).validate ();
163+ fail ();
164+ } catch (final IllegalStateException e ) {
165+ // expected
166+ }
167+
152168 format .withEscape (null ).withCommentStart (null ).validate ();
153169
154170
@@ -165,7 +181,7 @@ public void testValidation() {
165181 } catch (final IllegalStateException e ) {
166182 // expected
167183 }
168- }
184+ }
169185
170186 @ SuppressWarnings ("boxing" ) // no need to worry about boxing here
171187 @ Test
You can’t perform that action at this time.
0 commit comments