commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1301971 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java
Date Sat, 17 Mar 2012 18:17:15 GMT
Author: sebb
Date: Sat Mar 17 18:17:15 2012
New Revision: 1301971

URL: http://svn.apache.org/viewvc?rev=1301971&view=rev
Log:
Add test for CSV-75

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

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java?rev=1301971&r1=1301970&r2=1301971&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java
(original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java
Sat Mar 17 18:17:15 2012
@@ -71,12 +71,12 @@ public class ExtendedBufferedReaderTest 
         assertEquals('3', br.readAgain());
 
         assertEquals('\n', br.lookAhead());
-        assertEquals(1, br.getLineNumber());
+        assertEquals(1, br.getLineNumber()); // will need fixing for CSV-75
         assertEquals('3', br.readAgain());
         assertEquals('\n', br.read());
-        assertEquals(2, br.getLineNumber());
+        assertEquals(2, br.getLineNumber()); // will need fixing for CSV-75
         assertEquals('\n', br.readAgain());
-        assertEquals(2, br.getLineNumber());
+        assertEquals(2, br.getLineNumber()); // will need fixing for CSV-75
 
         assertEquals(ExtendedBufferedReader.END_OF_STREAM, br.lookAhead());
         assertEquals('\n', br.readAgain());
@@ -150,6 +150,39 @@ public class ExtendedBufferedReaderTest 
         assertTrue(br.readLine() == null);
     }
 
+    /*
+     * 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;
+        
+        br = getBufferedReader(test);
+        assertEquals(0, br.getLineNumber());
+        while(br.readLine()!=null) {}
+        assertEquals(EOLeolct, br.getLineNumber());
+
+        br = getBufferedReader(test);
+        assertEquals(0, br.getLineNumber());
+        while(br.read()!=-1) {}
+        assertEquals(EOLct, br.getLineNumber()); // will need fixing for CSV-75
+
+        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
+    }
+
     private ExtendedBufferedReader getBufferedReader(String s) {
         return new ExtendedBufferedReader(new StringReader(s));
     }



Mime
View raw message