1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.csv.issues;
19
20 import static org.junit.jupiter.api.Assertions.assertEquals;
21
22 import java.io.IOException;
23 import java.io.StringWriter;
24 import java.util.Arrays;
25
26 import org.apache.commons.csv.CSVFormat;
27 import org.apache.commons.csv.CSVPrinter;
28 import org.junit.jupiter.api.Test;
29
30 public class JiraCsv271Test {
31
32 @Test
33 public void testJiraCsv271_withArray() throws IOException {
34 final CSVFormat csvFormat = CSVFormat.DEFAULT;
35 final StringWriter stringWriter = new StringWriter();
36 try (CSVPrinter printer = new CSVPrinter(stringWriter, csvFormat)) {
37 printer.print("a");
38 printer.printRecord("b","c");
39 }
40 assertEquals("a,b,c\r\n", stringWriter.toString());
41 }
42
43 @Test
44 public void testJiraCsv271_withList() throws IOException {
45 final CSVFormat csvFormat = CSVFormat.DEFAULT;
46 final StringWriter stringWriter = new StringWriter();
47 try (CSVPrinter printer = new CSVPrinter(stringWriter, csvFormat)) {
48 printer.print("a");
49 printer.printRecord(Arrays.asList("b","c"));
50 }
51 assertEquals("a,b,c\r\n", stringWriter.toString());
52 }
53
54 }