|
22 | 22 | public class CSVFormatTest extends TestCase { |
23 | 23 |
|
24 | 24 | public void testImmutalibity() { |
25 | | - CSVFormat format1 = new CSVFormat('!', '!', '!', '!', true, true, true, true); |
26 | | - CSVFormat format2 = format1.withDelimiter('?') |
27 | | - .withEncapsulator('?') |
28 | | - .withCommentStart('?') |
29 | | - .withLineSeparator("?") |
30 | | - .withEscape('?') |
31 | | - .withLeadingSpacesIgnored(false) |
32 | | - .withTrailingSpacesIgnored(false) |
33 | | - .withEmptyLinesIgnored(false) |
34 | | - .withUnicodeEscapesInterpreted(false); |
35 | | - |
36 | | - assertNotSame(format1.getDelimiter(), format2.getDelimiter()); |
37 | | - assertNotSame(format1.getEncapsulator(), format2.getEncapsulator()); |
38 | | - assertNotSame(format1.getCommentStart(), format2.getCommentStart()); |
39 | | - assertNotSame(format1.getEscape(), format2.getEscape()); |
40 | | - assertNotSame(format1.getLineSeparator(), format2.getLineSeparator()); |
| 25 | + CSVFormat format = new CSVFormat('!', '!', '!', '!', true, true, true, true); |
| 26 | + |
| 27 | + format.withDelimiter('?'); |
| 28 | + format.withEncapsulator('?'); |
| 29 | + format.withCommentStart('?'); |
| 30 | + format.withLineSeparator("?"); |
| 31 | + format.withEscape('?'); |
| 32 | + format.withLeadingSpacesIgnored(false); |
| 33 | + format.withTrailingSpacesIgnored(false); |
| 34 | + format.withEmptyLinesIgnored(false); |
| 35 | + format.withUnicodeEscapesInterpreted(false); |
| 36 | + |
| 37 | + assertEquals('!', format.getDelimiter()); |
| 38 | + assertEquals('!', format.getEncapsulator()); |
| 39 | + assertEquals('!', format.getCommentStart()); |
| 40 | + assertEquals("\n", format.getLineSeparator()); |
| 41 | + assertEquals('!', format.getEscape()); |
41 | 42 |
|
42 | | - assertNotSame(format1.isTrailingSpacesIgnored(), format2.isTrailingSpacesIgnored()); |
43 | | - assertNotSame(format1.isLeadingSpacesIgnored(), format2.isLeadingSpacesIgnored()); |
44 | | - assertNotSame(format1.isEmptyLinesIgnored(), format2.isEmptyLinesIgnored()); |
45 | | - assertNotSame(format1.isUnicodeEscapesInterpreted(), format2.isUnicodeEscapesInterpreted()); |
| 43 | + assertEquals(true, format.isLeadingSpacesIgnored()); |
| 44 | + assertEquals(true, format.isTrailingSpacesIgnored()); |
| 45 | + assertEquals(true, format.isEmptyLinesIgnored()); |
| 46 | + assertEquals(true, format.isUnicodeEscapesInterpreted()); |
46 | 47 | } |
47 | 48 |
|
| 49 | + public void testMutators() { |
| 50 | + CSVFormat format = new CSVFormat('!', '!', '!', '!', true, true, true, true); |
| 51 | + |
| 52 | + assertEquals('?', format.withDelimiter('?').getDelimiter()); |
| 53 | + assertEquals('?', format.withEncapsulator('?').getEncapsulator()); |
| 54 | + assertEquals('?', format.withCommentStart('?').getCommentStart()); |
| 55 | + assertEquals("?", format.withLineSeparator("?").getLineSeparator()); |
| 56 | + assertEquals('?', format.withEscape('?').getEscape()); |
| 57 | + |
| 58 | + assertEquals(false, format.withLeadingSpacesIgnored(false).isLeadingSpacesIgnored()); |
| 59 | + assertEquals(false, format.withTrailingSpacesIgnored(false).isTrailingSpacesIgnored()); |
| 60 | + assertEquals(false, format.withEmptyLinesIgnored(false).isEmptyLinesIgnored()); |
| 61 | + assertEquals(false, format.withUnicodeEscapesInterpreted(false).isUnicodeEscapesInterpreted()); |
| 62 | + } |
48 | 63 | } |
0 commit comments