1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.csv.issues;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20
21 import org.apache.commons.csv.CSVFormat;
22 import org.apache.commons.csv.QuoteMode;
23 import org.junit.jupiter.api.Test;
24
25 public class JiraCsv148Test {
26
27 @Test
28 public void testWithIgnoreSurroundingSpacesEmpty() {
29
30 final CSVFormat format = CSVFormat.DEFAULT.builder()
31 .setQuoteMode(QuoteMode.ALL)
32 .setIgnoreSurroundingSpaces(true)
33 .build();
34
35 assertEquals(
36 "\"\",\" \",\" Single space on the left\",\"Single space on the right \","
37 + "\" Single spaces on both sides \",\" Multiple spaces on the left\","
38 + "\"Multiple spaces on the right \",\" Multiple spaces on both sides \"",
39 format.format("", " ", " Single space on the left", "Single space on the right ",
40 " Single spaces on both sides ", " Multiple spaces on the left", "Multiple spaces on the right ",
41 " Multiple spaces on both sides "));
42 }
43
44
45
46
47
48
49 @Test
50 public void testWithTrimEmpty() {
51
52 final CSVFormat format = CSVFormat.DEFAULT.builder()
53 .setQuoteMode(QuoteMode.ALL)
54 .setTrim(true)
55 .build();
56
57 assertEquals(
58 "\"\",\"\",\"Single space on the left\",\"Single space on the right\","
59 + "\"Single spaces on both sides\",\"Multiple spaces on the left\","
60 + "\"Multiple spaces on the right\",\"Multiple spaces on both sides\"",
61 format.format("", " ", " Single space on the left", "Single space on the right ",
62 " Single spaces on both sides ", " Multiple spaces on the left", "Multiple spaces on the right ",
63 " Multiple spaces on both sides "));
64 }
65 }