commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r427470 - in /jakarta/commons/sandbox/csv/trunk/src: java/org/apache/commons/csv/CSVParser.java test/org/apache/commons/csv/CSVParserTest.java
Date Tue, 01 Aug 2006 06:50:08 GMT
Author: bayard
Date: Mon Jul 31 23:50:08 2006
New Revision: 427470

URL: http://svn.apache.org/viewvc?rev=427470&view=rev
Log:
Fixing bug reported byu Markus Rogg in #SANDBOX-153. Whitespace was being treated specially
when it was not the delimiter. Unit test and patch applied. 

Modified:
    jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java
    jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java

Modified: jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java?rev=427470&r1=427469&r2=427470&view=diff
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java (original)
+++ jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVParser.java Mon Jul
31 23:50:08 2006
@@ -557,7 +557,7 @@
    * @return true if the given char is a whitespace character
    */
   private boolean isWhitespace(int c) {
-    return Character.isWhitespace((char) c);
+    return Character.isWhitespace((char) c) && (c != strategy.getDelimiter());
   }
   
   /**

Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java?rev=427470&r1=427469&r2=427470&view=diff
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java (original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java Mon
Jul 31 23:50:08 2006
@@ -526,4 +526,18 @@
         }
       }
     }
+
+    // From SANDBOX-153
+     public void testDelimiterIsWhitespace() throws IOException {
+         String code = "one\ttwo\t\tfour \t five\t six";
+         TestCSVParser parser = new TestCSVParser(new StringReader(code));
+         parser.setStrategy(CSVStrategy.TDF_STRATEGY);
+         System.out.println("---------\n" + code + "\n-------------");
+         assertEquals(CSVParser.TT_TOKEN + ";one;", parser.testNextToken());
+         assertEquals(CSVParser.TT_TOKEN + ";two;", parser.testNextToken());
+         assertEquals(CSVParser.TT_TOKEN + ";;", parser.testNextToken());
+         assertEquals(CSVParser.TT_TOKEN + ";four;", parser.testNextToken());
+         assertEquals(CSVParser.TT_TOKEN + ";five;", parser.testNextToken());
+         assertEquals(CSVParser.TT_EOF + ";six;", parser.testNextToken());
+     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message