Add code and test for Quote.NONE
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1480499 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bb3bb0d65b
commit
512e446d28
|
@ -242,7 +242,9 @@ public class CSVPrinter implements Flushable, Closeable {
|
|||
quote = !(object instanceof Number);
|
||||
break;
|
||||
case NONE:
|
||||
throw new IllegalArgumentException("Not implemented yet");
|
||||
// Use the existing escaping code
|
||||
printAndEscape(value, offset, len);
|
||||
return;
|
||||
case MINIMAL:
|
||||
if (len <= 0) {
|
||||
// always quote an empty token that is the first
|
||||
|
|
|
@ -381,6 +381,17 @@ public class CSVPrinterTest {
|
|||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelimeterQuoteNONE() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVFormat format = CSVFormat.newBuilder().withEscape('!').withQuotePolicy(Quote.NONE).build();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, format);
|
||||
printer.print("a,b,c");
|
||||
printer.print("xyz");
|
||||
assertEquals("a!,b!,c,xyz", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEOLQuoted() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
|
|
Loading…
Reference in New Issue