Validation fails if no quotes mode set but no escape character is set.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398148 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2012-10-14 23:22:17 +00:00
parent f51f43d184
commit bdb5842eef
2 changed files with 12 additions and 1 deletions

View File

@ -199,6 +199,10 @@ public class CSVFormat implements Serializable {
if (escape != null && escape == commentStart) { if (escape != null && escape == commentStart) {
throw new IllegalStateException("The comment start and the escape character cannot be the same ('" + commentStart + "')"); throw new IllegalStateException("The comment start and the escape character cannot be the same ('" + commentStart + "')");
} }
if (escape == null && quotePolicy == Quote.NONE) {
throw new IllegalStateException("No quotes mode set but no escape character is set");
}
} }
/** /**

View File

@ -153,6 +153,13 @@ public class CSVFormatTest {
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
// expected // expected
} }
try {
format.withQuoteChar('!').withQuotePolicy(Quote.NONE).validate();
fail();
} catch (final IllegalStateException e) {
// expected
}
} }
@SuppressWarnings("boxing") // no need to worry about boxing here @SuppressWarnings("boxing") // no need to worry about boxing here