Skip to content

Commit c26c858

Browse files
committed
Update copyright for 2016 in NOTICE.txt
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1725424 13f79535-47bb-0310-9956-ffa450edef68
1 parent 82b6d2e commit c26c858

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

src/test/java/org/apache/commons/csv/CSVPrinterTest.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.Arrays;
3434
import java.util.Date;
3535
import java.util.Iterator;
36+
import java.util.LinkedList;
3637
import java.util.List;
3738
import java.util.Random;
3839

@@ -231,6 +232,68 @@ private Connection geH2Connection() throws SQLException, ClassNotFoundException
231232
return DriverManager.getConnection("jdbc:h2:mem:my_test;", "sa", "");
232233
}
233234

235+
@Test
236+
public void testJira135All() throws IOException {
237+
CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
238+
StringWriter sw = new StringWriter();
239+
CSVPrinter printer = new CSVPrinter(sw, format);
240+
List<String> list = new LinkedList<String>();
241+
list.add("\"");
242+
list.add("\n");
243+
list.add("\\");
244+
printer.printRecord(list);
245+
printer.close();
246+
final String expected = "\"\\\"\",\"\\n\",\"\\\"" + format.getRecordSeparator();
247+
assertEquals(expected, sw.toString());
248+
String[] record0 = toFirstRecordValues(expected, format);
249+
assertArrayEquals(expectNulls(list.toArray(), format), record0);
250+
}
251+
252+
@Test
253+
public void testJira135_part3() throws IOException {
254+
CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
255+
StringWriter sw = new StringWriter();
256+
CSVPrinter printer = new CSVPrinter(sw, format);
257+
List<String> list = new LinkedList<String>();
258+
list.add("\\");
259+
printer.printRecord(list);
260+
printer.close();
261+
final String expected = "\"\\\\\"" + format.getRecordSeparator();
262+
assertEquals(expected, sw.toString());
263+
String[] record0 = toFirstRecordValues(expected, format);
264+
assertArrayEquals(expectNulls(list.toArray(), format), record0);
265+
}
266+
267+
@Test
268+
public void testJira135_part2() throws IOException {
269+
CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
270+
StringWriter sw = new StringWriter();
271+
CSVPrinter printer = new CSVPrinter(sw, format);
272+
List<String> list = new LinkedList<String>();
273+
list.add("\n");
274+
printer.printRecord(list);
275+
printer.close();
276+
final String expected = "\"\\n\"" + format.getRecordSeparator();
277+
assertEquals(expected, sw.toString());
278+
String[] record0 = toFirstRecordValues(expected, format);
279+
assertArrayEquals(expectNulls(list.toArray(), format), record0);
280+
}
281+
282+
@Test
283+
public void testJira135_part1() throws IOException {
284+
CSVFormat format = CSVFormat.DEFAULT.withRecordSeparator('\n').withQuote('"').withEscape('\\');
285+
StringWriter sw = new StringWriter();
286+
CSVPrinter printer = new CSVPrinter(sw, format);
287+
List<String> list = new LinkedList<String>();
288+
list.add("\"");
289+
printer.printRecord(list);
290+
printer.close();
291+
final String expected = "\"\\\"\"" + format.getRecordSeparator();
292+
assertEquals(expected, sw.toString());
293+
String[] record0 = toFirstRecordValues(expected, format);
294+
assertArrayEquals(expectNulls(list.toArray(), format), record0);
295+
}
296+
234297
@Test
235298
public void testJdbcPrinter() throws IOException, ClassNotFoundException, SQLException {
236299
final StringWriter sw = new StringWriter();

0 commit comments

Comments
 (0)