Skip to content

Commit d729b44

Browse files
committed
Sort members
1 parent 660be95 commit d729b44

3 files changed

Lines changed: 46 additions & 46 deletions

File tree

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,20 +1668,6 @@ void testParsingPrintedEmptyFirstColumn(final CSVFormat.Predefined format) throw
16681668
}
16691669
}
16701670

1671-
/**
1672-
* Tests <a href="https://issues.apache.org/jira/browse/CSV-324">CSV-324</a>.
1673-
*/
1674-
@Test
1675-
void testPartialMultiCharacterDelimiterAtEOF() throws IOException {
1676-
final CSVFormat format = CSVFormat.DEFAULT.builder().setDelimiter("[|]").get();
1677-
try (CSVParser parser = format.parse(new StringReader("a[|]b[|"))) {
1678-
final CSVRecord record = parser.nextRecord();
1679-
assertEquals("a", record.get(0));
1680-
assertEquals("b[|", record.get(1));
1681-
assertEquals(2, record.size());
1682-
}
1683-
}
1684-
16851671
/**
16861672
* A truncated escaped multi-character delimiter at EOF must stay literal data and not be completed from a stale
16871673
* escape delimiter look-ahead.
@@ -1696,6 +1682,20 @@ void testPartialEscapedMultiCharacterDelimiterAtEOF() throws IOException {
16961682
}
16971683
}
16981684

1685+
/**
1686+
* Tests <a href="https://issues.apache.org/jira/browse/CSV-324">CSV-324</a>.
1687+
*/
1688+
@Test
1689+
void testPartialMultiCharacterDelimiterAtEOF() throws IOException {
1690+
final CSVFormat format = CSVFormat.DEFAULT.builder().setDelimiter("[|]").get();
1691+
try (CSVParser parser = format.parse(new StringReader("a[|]b[|"))) {
1692+
final CSVRecord record = parser.nextRecord();
1693+
assertEquals("a", record.get(0));
1694+
assertEquals("b[|", record.get(1));
1695+
assertEquals(2, record.size());
1696+
}
1697+
}
1698+
16991699
@Test
17001700
void testProvidedHeader() throws Exception {
17011701
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -423,26 +423,6 @@ void testDelimeterStringQuoteNone() throws IOException {
423423
}
424424
}
425425

426-
@Test
427-
void testQuoteCharEscapedWithQuoteModeNone() throws IOException {
428-
final CSVFormat format = CSVFormat.DEFAULT.builder().setQuote('"').setEscape('?').setQuoteMode(QuoteMode.NONE).get();
429-
final StringWriter sw = new StringWriter();
430-
try (CSVPrinter printer = new CSVPrinter(sw, format)) {
431-
printer.printRecord("\"abc", "x\"y");
432-
printer.printRecord(new StringReader("\"abc"), new StringReader("x\"y"));
433-
}
434-
assertEquals("?\"abc,x?\"y" + RECORD_SEPARATOR + "?\"abc,x?\"y" + RECORD_SEPARATOR, sw.toString());
435-
// The emitted records must read back as the original values.
436-
try (CSVParser parser = CSVParser.parse(sw.toString(), format)) {
437-
final List<CSVRecord> records = parser.getRecords();
438-
assertEquals(2, records.size());
439-
for (final CSVRecord record : records) {
440-
assertEquals("\"abc", record.get(0));
441-
assertEquals("x\"y", record.get(1));
442-
}
443-
}
444-
}
445-
446426
@Test
447427
void testDelimiterEscaped() throws IOException {
448428
final StringWriter sw = new StringWriter();
@@ -1818,6 +1798,26 @@ void testQuoteAll() throws IOException {
18181798
}
18191799
}
18201800

1801+
@Test
1802+
void testQuoteCharEscapedWithQuoteModeNone() throws IOException {
1803+
final CSVFormat format = CSVFormat.DEFAULT.builder().setQuote('"').setEscape('?').setQuoteMode(QuoteMode.NONE).get();
1804+
final StringWriter sw = new StringWriter();
1805+
try (CSVPrinter printer = new CSVPrinter(sw, format)) {
1806+
printer.printRecord("\"abc", "x\"y");
1807+
printer.printRecord(new StringReader("\"abc"), new StringReader("x\"y"));
1808+
}
1809+
assertEquals("?\"abc,x?\"y" + RECORD_SEPARATOR + "?\"abc,x?\"y" + RECORD_SEPARATOR, sw.toString());
1810+
// The emitted records must read back as the original values.
1811+
try (CSVParser parser = CSVParser.parse(sw.toString(), format)) {
1812+
final List<CSVRecord> records = parser.getRecords();
1813+
assertEquals(2, records.size());
1814+
for (final CSVRecord record : records) {
1815+
assertEquals("\"abc", record.get(0));
1816+
assertEquals("x\"y", record.get(1));
1817+
}
1818+
}
1819+
}
1820+
18211821
@Test
18221822
void testQuoteCommaFirstChar() throws IOException {
18231823
final StringWriter sw = new StringWriter();

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -409,18 +409,6 @@ void testNextToken6() throws IOException {
409409
}
410410
}
411411

412-
/**
413-
* Tests <a href="https://issues.apache.org/jira/browse/CSV-324">CSV-324</a>.
414-
*/
415-
@Test
416-
void testPartialMultiCharacterDelimiterAtEOF() throws IOException {
417-
final CSVFormat format = CSVFormat.DEFAULT.builder().setDelimiter("[|]").get();
418-
try (Lexer lexer = createLexer("a[|]b[|", format)) {
419-
assertNextToken(TOKEN, "a", lexer);
420-
assertNextToken(EOF, "b[|", lexer);
421-
}
422-
}
423-
424412
/**
425413
* A truncated escaped multi-character delimiter at EOF must not be accepted by reusing the previous escape delimiter
426414
* look-ahead in {@link Lexer#isEscapeDelimiter()}.
@@ -433,6 +421,18 @@ void testPartialEscapedMultiCharacterDelimiterAtEOF() throws IOException {
433421
}
434422
}
435423

424+
/**
425+
* Tests <a href="https://issues.apache.org/jira/browse/CSV-324">CSV-324</a>.
426+
*/
427+
@Test
428+
void testPartialMultiCharacterDelimiterAtEOF() throws IOException {
429+
final CSVFormat format = CSVFormat.DEFAULT.builder().setDelimiter("[|]").get();
430+
try (Lexer lexer = createLexer("a[|]b[|", format)) {
431+
assertNextToken(TOKEN, "a", lexer);
432+
assertNextToken(EOF, "b[|", lexer);
433+
}
434+
}
435+
436436
@Test
437437
void testReadEscapeBackspace() throws IOException {
438438
try (Lexer lexer = createLexer("b", CSVFormat.DEFAULT.withEscape('\b'))) {

0 commit comments

Comments
 (0)