Add some more tests
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1479730 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
02c1b35939
commit
0fabee5f24
|
@ -342,6 +342,15 @@ public class CSVPrinterTest {
|
|||
doRandom(CSVFormat.MYSQL, iter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainQuoted() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar('\'').build());
|
||||
printer.print("abc");
|
||||
assertEquals("abc", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleLineComment() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
|
@ -352,4 +361,64 @@ public class CSVPrinterTest {
|
|||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleQuoteQuoted() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar('\'').build());
|
||||
printer.print("a'b'c");
|
||||
printer.print("xyz");
|
||||
assertEquals("'a''b''c',xyz", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelimeterQuoted() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar('\'').build());
|
||||
printer.print("a,b,c");
|
||||
printer.print("xyz");
|
||||
assertEquals("'a,b,c',xyz", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainEscaped() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).withEscape('!').build());
|
||||
printer.print("abc");
|
||||
printer.print("xyz");
|
||||
assertEquals("abc,xyz", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelimiterEscaped() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).withEscape('!').build());
|
||||
printer.print("a,b,c");
|
||||
printer.print("xyz");
|
||||
assertEquals("a!,b!,c,xyz", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainPlain() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).build());
|
||||
printer.print("abc");
|
||||
printer.print("xyz");
|
||||
assertEquals("abc,xyz", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelimiterPlain() throws IOException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.newBuilder().withQuoteChar(null).build());
|
||||
printer.print("a,b,c");
|
||||
printer.print("xyz");
|
||||
assertEquals("a,b,c,xyz", sw.toString());
|
||||
printer.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue