commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r1463210 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java
Date Mon, 01 Apr 2013 17:15:31 GMT
Author: britter
Date: Mon Apr  1 17:15:31 2013
New Revision: 1463210

URL: http://svn.apache.org/r1463210
Log:
Use hasContent matcher token type is not relevant (correct token type recognition is tested
by other tests methods)

Modified:
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java?rev=1463210&r1=1463209&r2=1463210&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVLexerTest.java Mon Apr
 1 17:15:31 2013
@@ -29,6 +29,8 @@ import static org.apache.commons.csv.Tok
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThat;
+import static org.apache.commons.csv.TokenMatchers.hasContent;
 
 import java.io.IOException;
 import java.io.StringReader;
@@ -282,38 +284,38 @@ public class CSVLexerTest {
     @Test
     public void testEscapedCR() throws Exception {
         final Lexer lexer = getLexer("character\\" + CR + "Escaped", formatWithEscaping);
-        assertTokenEquals(EOF, "character" + CR + "Escaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character" + CR + "Escaped"));
     }
 
     @Test
     public void testEscapedLF() throws Exception {
         final Lexer lexer = getLexer("character\\" + LF + "Escaped", formatWithEscaping);
-        assertTokenEquals(EOF, "character" + LF + "Escaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character" + LF + "Escaped"));
     }
 
     @Test
     public void testEscapedTab() throws Exception {
         final Lexer lexer = getLexer("character\\" + TAB + "Escaped", formatWithEscaping);
-        assertTokenEquals(EOF, "character" + TAB + "Escaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character" + TAB + "Escaped"));
     }
 
     @Test
     public void testEscapeBackspace() throws Exception {
         final Lexer lexer = getLexer("character\\" + BACKSPACE + "Escaped", formatWithEscaping);
-        assertTokenEquals(EOF, "character" + BACKSPACE + "Escaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character" + BACKSPACE + "Escaped"));
     }
 
     @Test
     public void testEscapeFF() throws Exception {
         final Lexer lexer = getLexer("character\\" + FF + "Escaped", formatWithEscaping);
-        assertTokenEquals(EOF, "character" + FF + "Escaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character" + FF + "Escaped"));
     }
 
     @Test
     public void testEscapedMySqlNullValue() throws Exception {
         // MySQL uses \N to symbolize null values. We have to restore this
         final Lexer lexer = getLexer("character\\\\NEscaped", formatWithEscaping);
-        assertTokenEquals(EOF, "character\\NEscaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character\\NEscaped"));
     }
 
     // FIXME this should work after CSV-58 is resolved. Currently the result will be "characteraEscaped"
@@ -321,7 +323,7 @@ public class CSVLexerTest {
     @Ignore
     public void testEscapedCharacter() throws Exception {
         final Lexer lexer = getLexer("character\\aEscaped", formatWithEscaping);
-        assertTokenEquals(EOF, "character\\aEscaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character\\aEscaped"));
     }
 
     // FIXME this should work after CSV-58 is resolved. Currently the result will be "characterCREscaped"
@@ -330,7 +332,13 @@ public class CSVLexerTest {
     public void testEscapedControlCharacter() throws Exception {
         // we are explicitly using an escape different from \ here, because \r is the character
sequence for CR
         final Lexer lexer = getLexer("character!rEscaped", CSVFormat.newBuilder().withEscape('!').build());
-        assertTokenEquals(EOF, "character!rEscaped", lexer.nextToken(new Token()));
+        assertThat(lexer.nextToken(new Token()), hasContent("character!rEscaped"));
+    }
+
+    @Test
+    public void testEscapedControlCharacter2() throws Exception {
+        final Lexer lexer = getLexer("character\\rEscaped", CSVFormat.newBuilder().withEscape('\\').build());
+        assertThat(lexer.nextToken(new Token()), hasContent("character"+CR+"Escaped"));
     }
 
     @Test(expected = IOException.class)



Mime
View raw message