Add some more tests that document escaping behavior

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1509957 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2013-08-03 11:12:48 +00:00
parent 3178725e98
commit 575c88d8a2
1 changed files with 32 additions and 0 deletions

View File

@ -304,30 +304,62 @@ public class CSVLexerTest {
assertThat(lexer.nextToken(new Token()), hasContent("character" + CR + "Escaped"));
}
@Test
public void testCR() throws Exception {
final Lexer lexer = getLexer("character" + CR + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character"));
assertThat(lexer.nextToken(new Token()), hasContent("Escaped"));
}
@Test
public void testEscapedLF() throws Exception {
final Lexer lexer = getLexer("character\\" + LF + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character" + LF + "Escaped"));
}
@Test
public void testLF() throws Exception {
final Lexer lexer = getLexer("character" + LF + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character"));
assertThat(lexer.nextToken(new Token()), hasContent("Escaped"));
}
@Test // TODO is this correct? Do we expect TAB to be un/escaped?
public void testEscapedTab() throws Exception {
final Lexer lexer = getLexer("character\\" + TAB + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character" + TAB + "Escaped"));
}
@Test // TODO is this correct? Do we expect TAB to be un/escaped?
public void testTab() throws Exception {
final Lexer lexer = getLexer("character" + TAB + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character" + TAB + "Escaped"));
}
@Test // TODO is this correct? Do we expect BACKSPACE to be un/escaped?
public void testEscapedBackspace() throws Exception {
final Lexer lexer = getLexer("character\\" + BACKSPACE + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character" + BACKSPACE + "Escaped"));
}
@Test // TODO is this correct? Do we expect BACKSPACE to be un/escaped?
public void testBackspace() throws Exception {
final Lexer lexer = getLexer("character" + BACKSPACE + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character" + BACKSPACE + "Escaped"));
}
@Test // TODO is this correct? Do we expect FF to be un/escaped?
public void testEscapedFF() throws Exception {
final Lexer lexer = getLexer("character\\" + FF + "Escaped", formatWithEscaping);
assertThat(lexer.nextToken(new Token()), hasContent("character" + FF + "Escaped"));
}
@Test // TODO is this correct? Do we expect FF to be un/escaped?
public void testFF() throws Exception {
final Lexer lexer = getLexer("character" + FF + "Escaped", formatWithEscaping);
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