|
32 | 32 | import static org.junit.jupiter.api.Assertions.assertFalse; |
33 | 33 | import static org.junit.jupiter.api.Assertions.assertThrows; |
34 | 34 | import static org.junit.jupiter.api.Assertions.assertTrue; |
35 | | - |
| 35 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
36 | 36 | import java.io.IOException; |
37 | 37 | import java.io.StringReader; |
38 | 38 |
|
@@ -389,4 +389,45 @@ public void testEscapingAtEOF() throws Exception { |
389 | 389 | assertThrows(IOException.class, () -> lexer.nextToken(new Token())); |
390 | 390 | } |
391 | 391 | } |
| 392 | + |
| 393 | + @Test |
| 394 | + public void testTrimTrailingSpacesZeroLength() throws Exception { |
| 395 | + final StringBuilder buffer = new StringBuilder(""); |
| 396 | + final Lexer lexer = createLexer(buffer.toString(), CSVFormat.DEFAULT); |
| 397 | + lexer.trimTrailingSpaces(buffer); |
| 398 | + assertThat(lexer.nextToken(new Token()), matches(EOF, "")); |
| 399 | + } |
| 400 | + |
| 401 | + @Test |
| 402 | + public void testReadEscapeTab() throws IOException { |
| 403 | + try (final Lexer lexer = createLexer("t", CSVFormat.DEFAULT.withEscape('\t'))) { |
| 404 | + final int ch = lexer.readEscape(); |
| 405 | + assertThat(lexer.nextToken(new Token()), matches(EOF, "")); |
| 406 | + assertEquals(TAB, ch); |
| 407 | + } |
| 408 | + } |
| 409 | + |
| 410 | + @Test |
| 411 | + public void testReadEscapeBackspace() throws IOException { |
| 412 | + try (final Lexer lexer = createLexer("b", CSVFormat.DEFAULT.withEscape('\b'))) { |
| 413 | + final int ch = lexer.readEscape(); |
| 414 | + assertEquals(BACKSPACE, ch); |
| 415 | + } |
| 416 | + } |
| 417 | + |
| 418 | + @Test |
| 419 | + public void testReadEscapeFF() throws IOException { |
| 420 | + try (final Lexer lexer = createLexer("f", CSVFormat.DEFAULT.withEscape('\f'))) { |
| 421 | + final int ch = lexer.readEscape(); |
| 422 | + assertEquals(FF, ch); |
| 423 | + } |
| 424 | + } |
| 425 | + |
| 426 | + @Test |
| 427 | + public void testIsMetaCharCommentStart() throws IOException { |
| 428 | + try (final Lexer lexer = createLexer("#", CSVFormat.DEFAULT.withCommentMarker('#'))) { |
| 429 | + final int ch = lexer.readEscape(); |
| 430 | + assertEquals('#', ch); |
| 431 | + } |
| 432 | + } |
392 | 433 | } |
0 commit comments