From 8a683f009d10150c3bcff6c92455cadd7f7f0a88 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Tue, 27 Mar 2012 00:54:36 +0000 Subject: [PATCH] CSV-75 ExtendedBufferReader does not handle EOL consistently Fix tests git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1305695 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/csv/ExtendedBufferedReaderTest.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java b/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java index 9736a600..82faace6 100644 --- a/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java +++ b/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java @@ -70,12 +70,12 @@ public class ExtendedBufferedReaderTest { assertEquals('3', br.readAgain()); assertEquals('\n', br.lookAhead()); - assertEquals(1, br.getLineNumber()); // will need fixing for CSV-75 + assertEquals(2, br.getLineNumber()); assertEquals('3', br.readAgain()); assertEquals('\n', br.read()); - assertEquals(2, br.getLineNumber()); // will need fixing for CSV-75 + assertEquals(3, br.getLineNumber()); assertEquals('\n', br.readAgain()); - assertEquals(2, br.getLineNumber()); // will need fixing for CSV-75 + assertEquals(3, br.getLineNumber()); assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.lookAhead()); assertEquals('\n', br.readAgain()); @@ -152,16 +152,12 @@ public class ExtendedBufferedReaderTest { /* * Test to illustrate https://issues.apache.org/jira/browse/CSV-75 * - * TODO fix checks when code is fixed */ @Test public void testReadChar() throws Exception { String LF="\n"; String CR="\r"; String CRLF=CR+LF; String LFCR=LF+CR;// easier to read the string below String test="a" + LF + "b" + CR + "c" + LF + LF + "d" + CR + CR + "e" + LFCR + "f "+ CRLF; // EOL eol EOL EOL eol eol EOL+CR EOL - // EOL = current EOL behaviour with read() methods - // eol = additional behaviour with readLine() - final int EOLct=5; final int EOLeolct=9; ExtendedBufferedReader br; @@ -173,13 +169,13 @@ public class ExtendedBufferedReaderTest { br = getBufferedReader(test); assertEquals(0, br.getLineNumber()); while(br.read()!=-1) {} - assertEquals(EOLct, br.getLineNumber()); // will need fixing for CSV-75 + assertEquals(EOLeolct, br.getLineNumber()); br = getBufferedReader(test); assertEquals(0, br.getLineNumber()); char[] buff = new char[10]; while(br.read(buff ,0, 3)!=-1) {} - assertEquals(EOLct, br.getLineNumber()); // will need fixing for CSV-75 + assertEquals(EOLeolct, br.getLineNumber()); } private ExtendedBufferedReader getBufferedReader(String s) {