Skip to content

Commit 09a6e88

Browse files
committed
Use hasContent matcher token type is not relevant (correct token type recognition is tested by other tests methods)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1463210 13f79535-47bb-0310-9956-ffa450edef68
1 parent aef7130 commit 09a6e88

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import static org.junit.Assert.assertEquals;
3030
import static org.junit.Assert.assertFalse;
3131
import static org.junit.Assert.assertTrue;
32+
import static org.junit.Assert.assertThat;
33+
import static org.apache.commons.csv.TokenMatchers.hasContent;
3234

3335
import java.io.IOException;
3436
import java.io.StringReader;
@@ -282,46 +284,46 @@ public void testDelimiterIsWhitespace() throws IOException {
282284
@Test
283285
public void testEscapedCR() throws Exception {
284286
final Lexer lexer = getLexer("character\\" + CR + "Escaped", formatWithEscaping);
285-
assertTokenEquals(EOF, "character" + CR + "Escaped", lexer.nextToken(new Token()));
287+
assertThat(lexer.nextToken(new Token()), hasContent("character" + CR + "Escaped"));
286288
}
287289

288290
@Test
289291
public void testEscapedLF() throws Exception {
290292
final Lexer lexer = getLexer("character\\" + LF + "Escaped", formatWithEscaping);
291-
assertTokenEquals(EOF, "character" + LF + "Escaped", lexer.nextToken(new Token()));
293+
assertThat(lexer.nextToken(new Token()), hasContent("character" + LF + "Escaped"));
292294
}
293295

294296
@Test
295297
public void testEscapedTab() throws Exception {
296298
final Lexer lexer = getLexer("character\\" + TAB + "Escaped", formatWithEscaping);
297-
assertTokenEquals(EOF, "character" + TAB + "Escaped", lexer.nextToken(new Token()));
299+
assertThat(lexer.nextToken(new Token()), hasContent("character" + TAB + "Escaped"));
298300
}
299301

300302
@Test
301303
public void testEscapeBackspace() throws Exception {
302304
final Lexer lexer = getLexer("character\\" + BACKSPACE + "Escaped", formatWithEscaping);
303-
assertTokenEquals(EOF, "character" + BACKSPACE + "Escaped", lexer.nextToken(new Token()));
305+
assertThat(lexer.nextToken(new Token()), hasContent("character" + BACKSPACE + "Escaped"));
304306
}
305307

306308
@Test
307309
public void testEscapeFF() throws Exception {
308310
final Lexer lexer = getLexer("character\\" + FF + "Escaped", formatWithEscaping);
309-
assertTokenEquals(EOF, "character" + FF + "Escaped", lexer.nextToken(new Token()));
311+
assertThat(lexer.nextToken(new Token()), hasContent("character" + FF + "Escaped"));
310312
}
311313

312314
@Test
313315
public void testEscapedMySqlNullValue() throws Exception {
314316
// MySQL uses \N to symbolize null values. We have to restore this
315317
final Lexer lexer = getLexer("character\\\\NEscaped", formatWithEscaping);
316-
assertTokenEquals(EOF, "character\\NEscaped", lexer.nextToken(new Token()));
318+
assertThat(lexer.nextToken(new Token()), hasContent("character\\NEscaped"));
317319
}
318320

319321
// FIXME this should work after CSV-58 is resolved. Currently the result will be "characteraEscaped"
320322
@Test
321323
@Ignore
322324
public void testEscapedCharacter() throws Exception {
323325
final Lexer lexer = getLexer("character\\aEscaped", formatWithEscaping);
324-
assertTokenEquals(EOF, "character\\aEscaped", lexer.nextToken(new Token()));
326+
assertThat(lexer.nextToken(new Token()), hasContent("character\\aEscaped"));
325327
}
326328

327329
// FIXME this should work after CSV-58 is resolved. Currently the result will be "characterCREscaped"
@@ -330,7 +332,13 @@ public void testEscapedCharacter() throws Exception {
330332
public void testEscapedControlCharacter() throws Exception {
331333
// we are explicitly using an escape different from \ here, because \r is the character sequence for CR
332334
final Lexer lexer = getLexer("character!rEscaped", CSVFormat.newBuilder().withEscape('!').build());
333-
assertTokenEquals(EOF, "character!rEscaped", lexer.nextToken(new Token()));
335+
assertThat(lexer.nextToken(new Token()), hasContent("character!rEscaped"));
336+
}
337+
338+
@Test
339+
public void testEscapedControlCharacter2() throws Exception {
340+
final Lexer lexer = getLexer("character\\rEscaped", CSVFormat.newBuilder().withEscape('\\').build());
341+
assertThat(lexer.nextToken(new Token()), hasContent("character"+CR+"Escaped"));
334342
}
335343

336344
@Test(expected = IOException.class)

0 commit comments

Comments
 (0)