|
From: <zep...@us...> - 2006-10-24 11:36:57
|
Revision: 115
http://svn.sourceforge.net/pzfilereader/?rev=115&view=rev
Author: zepernick
Date: 2006-10-24 04:36:50 -0700 (Tue, 24 Oct 2006)
Log Message:
-----------
started splitline test. Publishing so I can work on it futher from work
Added Paths:
-----------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Added: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java (rev 0)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-24 11:36:50 UTC (rev 115)
@@ -0,0 +1,53 @@
+package net.sf.pzfilereader.parserutils;
+
+import java.util.List;
+
+import net.sf.pzfilereader.util.ParserUtils;
+import junit.framework.TestCase;
+
+/**
+ * Test the functionality of the splitLine method. This method returns
+ * a List of Strings. Each element of the list represents a column created
+ * by the parser from the delimited String.
+ *
+ * @author zepernick
+ */
+public class ParserUtilsSplitLineTest extends TestCase{
+ final String[] delimitedDataNoBreaks = {"Column 1","Column 2", "Column 3", "Column 4", "Column 5"};
+ final String[] delimitedDataWithBreaks = {"Column 1","Column 2", "Column 3", "Column 4", "Column 5"};
+
+ /**
+ * Test CSV without any line breaks
+ *
+ */
+ public void testCSVNoLineBreaks(){
+
+ final String delimiter = ",";
+ final String qualifier = "\"";
+ final StringBuffer txtToParse = new StringBuffer();
+ for (int i = 0; i < delimitedDataNoBreaks.length; i++){
+ if (i > 0){
+ txtToParse.append(delimiter);
+ }
+ txtToParse.append(qualifier + delimitedDataNoBreaks[i] + qualifier);
+ }
+
+ List splitLineResults = ParserUtils.splitLine(txtToParse.toString(), delimiter, qualifier);
+
+
+ //check to make sure we have the same amount of elements which were expected
+ assertEquals(delimitedDataNoBreaks.length, splitLineResults.size());
+
+ //loop through each value and compare what came back
+ for (int i = 0 ; i < delimitedDataNoBreaks.length; i ++){
+ assertEquals(delimitedDataNoBreaks[i], (String)splitLineResults.get(i));
+ }
+
+
+ }
+
+ public static void main(final String[] args) {
+ junit.textui.TestRunner.run(ParserUtilsSplitLineTest.class);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <be...@us...> - 2006-10-26 15:50:23
|
Revision: 126
http://svn.sourceforge.net/pzfilereader/?rev=126&view=rev
Author: benoitx
Date: 2006-10-26 08:50:17 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Added a couple of whacky tests, some fail (on purpose); Paul could you check what results you expect and create a few more?
Thanks
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-26 14:04:40 UTC (rev 125)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-26 15:50:17 UTC (rev 126)
@@ -59,7 +59,7 @@
}
/**
- * Test without any line breaks
+ * Test with any line breaks
*
*/
public void testLineBreaks() {
@@ -70,7 +70,7 @@
final String txtToParse = UnitTestUtils.buildDelimString(DELIMITED_DATA_WITH_BREAKS, d, q);
- final List splitLineResults = ParserUtils.splitLine(txtToParse.toString(), d, q);
+ final List splitLineResults = ParserUtils.splitLine(txtToParse, d, q);
// check to make sure we have the same amount of elements which were
// expected
@@ -82,25 +82,51 @@
assertEquals("Data Element Value Does Not Match (d = " + d + " q = " + q + ")", DELIMITED_DATA_WITH_BREAKS[j],
(String) splitLineResults.get(j));
}
-
}
}
/**
* Test to make sure we get the correct amount of elements for malformed
* data
- *
- * @param args
*/
public void testMalformedData() {
final List splitLineResults = ParserUtils.splitLine(DELIMITED_BAD_DATA, ',', '\"');
assertEquals("Expecting 2 Data Elements From The Malformed Data", 2, splitLineResults.size());
+ }
+ /**
+ * Test some extreme cases
+ */
+ public void testSomeExtremeCases() {
+ check("\"a,b,c\"", ',', '\"', new String[] { "a,b,c" });
+ check("\"a,b\",\"c\"", ',', '\"', new String[] { "a,b", "c" });
+ check("a,b,c", ',', '\"', new String[] { "a", "b", "c" });
+ check(" a,b,c", ',', '\"', new String[] { "a", "b", "c" });
+ check(" a,b,c", ',', '\"', new String[] { "a","b","c" });
+
+ // what would you expect of these ones?
+ check("a\",b,c", ',', '\"', new String[] { "a", "b", "c" });
+ check("\" a,b,c\"", ',', '\"', new String[] { "a,b,c" });
+ check(" a, b ,c ", ',', '\"', new String[] { "a","b","c" });
+
+ // Paul... please put some more whacky stuff here...
+
}
+ private void check(final String txtToParse, final char delim, final char qualifier, final String[] expected) {
+ final List splitLineResults = ParserUtils.splitLine(txtToParse, delim, qualifier);
+
+ assertEquals(
+ "Did Not Get Amount Of Elements Expected (d = " + delim + " q = " + qualifier + ") txt [" + txtToParse + "]",
+ expected.length, splitLineResults.size());
+
+ for (int i = 0; i < expected.length; i++) {
+ assertEquals("expecting...", expected[i], splitLineResults.get(i));
+ }
+ }
+
public static void main(final String[] args) {
junit.textui.TestRunner.run(ParserUtilsSplitLineTest.class);
}
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2006-10-27 01:05:55
|
Revision: 139
http://svn.sourceforge.net/pzfilereader/?rev=139&view=rev
Author: zepernick
Date: 2006-10-26 18:05:51 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
starting to go through extreme tests
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-27 01:05:18 UTC (rev 138)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-27 01:05:51 UTC (rev 139)
@@ -106,9 +106,20 @@
check(" a,b,c", ',', '\"', new String[] { "a","b","c" });
// what would you expect of these ones?
- check("a\",b,c", ',', '\"', new String[] { "a", "b", "c" });
+
+ //+++++The parser allows qualified and unqualified elements to be contained
+ //on the same line. so it should break the elements down like so
+ //1 = a" -->" is part of the data since the element did not start with a qualifier
+ //2 = b
+ //3 = c" --> same as #1
+ check("a\",b,c\"", ',', '\"', new String[] { "a\"", "b", "c\"" });
+
+
+
check("\" a,b,c\"", ',', '\"', new String[] { "a,b,c" });
- check(" a, b ,c ", ',', '\"', new String[] { "a","b","c" });
+ //check(" a, b ,c ", ',', '\"', new String[] { "a","b","c" });
+ //++++++I think this should probably generate this
+ check(" a, b ,c ", ',', '\"', new String[] { "a, b ,c" });
// Paul... please put some more whacky stuff here...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2006-10-30 12:20:42
|
Revision: 149
http://svn.sourceforge.net/pzfilereader/?rev=149&view=rev
Author: zepernick
Date: 2006-10-30 04:20:35 -0800 (Mon, 30 Oct 2006)
Log Message:
-----------
added 2 more extreme tests. Possible bug on the last test.
Needs more discussion.
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-30 12:05:55 UTC (rev 148)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-30 12:20:35 UTC (rev 149)
@@ -113,15 +113,17 @@
//2 = b
//3 = c" --> same as #1
check("a\",b,c\"", ',', '\"', new String[] { "a\"", "b", "c\"" });
-
-
-
- check("\" a,b,c\"", ',', '\"', new String[] { "a,b,c" });
- //check(" a, b ,c ", ',', '\"', new String[] { "a","b","c" });
- //++++++I think this should probably generate this
- check(" a, b ,c ", ',', '\"', new String[] { "a, b ,c" });
+ //should not trim leading space inside of a qualified element
+ check("\" a,b,c\"", ',', '\"', new String[] { " a,b,c" });
+ check(" a, b ,c ", ',', '\"', new String[] { "a","b","c" });
// Paul... please put some more whacky stuff here...
+ check("\"a\", b , \"c\"", ',', '\"', new String[] {"a","b","c"});
+ //check malformed data
+ //TODO - I believe this should be producing 2 elements. As soon as their is a
+ //delimter followed by a qualifier a new element shoudl be created
+ //+++Any thoughts Benoit?
+ check("\"a, b,\"c\"", ',', '\"', new String[] {"a, b", "c"});
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2006-10-30 15:57:07
|
Revision: 150
http://svn.sourceforge.net/pzfilereader/?rev=150&view=rev
Author: zepernick
Date: 2006-10-30 07:57:00 -0800 (Mon, 30 Oct 2006)
Log Message:
-----------
added a couple more tests
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-30 12:20:35 UTC (rev 149)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-30 15:57:00 UTC (rev 150)
@@ -123,7 +123,9 @@
//TODO - I believe this should be producing 2 elements. As soon as their is a
//delimter followed by a qualifier a new element shoudl be created
//+++Any thoughts Benoit?
- check("\"a, b,\"c\"", ',', '\"', new String[] {"a, b", "c"});
+ check("\"a, b,\"c\"", ',', '\"', new String[] {"a, b,\"c"});
+ check("\"\",,,,\"last one\"", ',', '\"', new String[] {"","","","","last one"});
+ check("\"first\",\"second\",", ',', '\"', new String[] {"first","second",""});
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <be...@us...> - 2006-10-31 16:05:20
|
Revision: 158
http://svn.sourceforge.net/pzfilereader/?rev=158&view=rev
Author: benoitx
Date: 2006-10-31 08:05:16 -0800 (Tue, 31 Oct 2006)
Log Message:
-----------
I have added a few very basic tests and they all seem to fail... Paul, could you investigate? thanks.
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-31 15:04:16 UTC (rev 157)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-31 16:05:16 UTC (rev 158)
@@ -99,6 +99,15 @@
* Test some extreme cases
*/
public void testSomeExtremeCases() {
+ // back to Basic...
+ check(null, ',', '\"', new String[] {});
+ check("a", ',', '\"', new String[] { "a" });
+ check(",", ',', '\"', new String[] { null, null });
+ check(",,", ',', '\"', new String[] { null, null, null });
+ check(",a,", ',', '\"', new String[] { null, "a", null });
+
+ //
+
check("\"a,b,c\"", ',', '\"', new String[] { "a,b,c" });
check("\"a,b\",\"c\"", ',', '\"', new String[] { "a,b", "c" });
check("a,b,c", ',', '\"', new String[] { "a", "b", "c" });
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <be...@us...> - 2006-10-31 16:07:29
|
Revision: 159
http://svn.sourceforge.net/pzfilereader/?rev=159&view=rev
Author: benoitx
Date: 2006-10-31 08:07:23 -0800 (Tue, 31 Oct 2006)
Log Message:
-----------
One more funny test....
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-31 16:05:16 UTC (rev 158)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-31 16:07:23 UTC (rev 159)
@@ -102,6 +102,7 @@
// back to Basic...
check(null, ',', '\"', new String[] {});
check("a", ',', '\"', new String[] { "a" });
+ check("", ',', '\"', new String[] { null });
check(",", ',', '\"', new String[] { null, null });
check(",,", ',', '\"', new String[] { null, null, null });
check(",a,", ',', '\"', new String[] { null, "a", null });
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2006-10-31 20:02:53
|
Revision: 163
http://svn.sourceforge.net/pzfilereader/?rev=163&view=rev
Author: zepernick
Date: 2006-10-31 12:02:48 -0800 (Tue, 31 Oct 2006)
Log Message:
-----------
modified the last check in testSomeExtremeCases()
it appears that it should have 2 " in the result of the parse
Benoit, please lmk if this is incorrect.
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-31 20:00:17 UTC (rev 162)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-10-31 20:02:48 UTC (rev 163)
@@ -128,7 +128,9 @@
check("\"first\",\"second\",", ',', '\"', new String[] { "first", "second", null });
check("\" a,b,c\"", ',', '\"', new String[] { " a,b,c" });
check("\" a,b,c\",d", ',', '\"', new String[] { " a,b,c", "d" });
- check("\"a, b,\"\"c\"", ',', '\"', new String[] { "a, b,\"c" });
+ //++++looks like both quotes should be returned in the result here.
+ //let me know if I am wrong. pz
+ check("\"a, b,\"\"c\"", ',', '\"', new String[] { "a, b,\"\"c" });
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2006-11-25 17:23:20
|
Revision: 199
http://svn.sourceforge.net/pzfilereader/?rev=199&view=rev
Author: zepernick
Date: 2006-11-25 09:23:17 -0800 (Sat, 25 Nov 2006)
Log Message:
-----------
copied over from bx test cases
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-11-25 17:22:30 UTC (rev 198)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-11-25 17:23:17 UTC (rev 199)
@@ -42,7 +42,7 @@
final String txtToParse = UnitTestUtils.buildDelimString(DELIMITED_DATA_NO_BREAKS, d, q);
- final List splitLineResults = ParserUtils.splitLine(txtToParse, d, q);
+ final List splitLineResults = ParserUtils.splitLine(txtToParse, d, q, 10);
// check to make sure we have the same amount of elements which were
// expected
@@ -70,7 +70,7 @@
final String txtToParse = UnitTestUtils.buildDelimString(DELIMITED_DATA_WITH_BREAKS, d, q);
- final List splitLineResults = ParserUtils.splitLine(txtToParse, d, q);
+ final List splitLineResults = ParserUtils.splitLine(txtToParse, d, q, 10);
// check to make sure we have the same amount of elements which were
// expected
@@ -90,7 +90,7 @@
* data
*/
public void testMalformedData() {
- final List splitLineResults = ParserUtils.splitLine(DELIMITED_BAD_DATA, ',', '\"');
+ final List splitLineResults = ParserUtils.splitLine(DELIMITED_BAD_DATA, ',', '\"', 10);
assertEquals("Expecting 2 Data Elements From The Malformed Data", 2, splitLineResults.size());
}
@@ -101,12 +101,12 @@
public void testSomeExtremeCases() {
check(null, ',', '\"', new String[] {});
check("a", ',', '\"', new String[] { "a" });
- check("", ',', '\"', new String[] { null });
- check(" ", ',', '\"', new String[] { null });
- check(" ", ',', '\"', new String[] { null });
- check(",", ',', '\"', new String[] { null, null });
- check(",,", ',', '\"', new String[] { null, null, null });
- check(",a,", ',', '\"', new String[] { null, "a", null });
+ check("", ',', '\"', new String[] { "" });
+ check(" ", ',', '\"', new String[] { "" });
+ check(" ", ',', '\"', new String[] { "" });
+ check(",", ',', '\"', new String[] { "", "" });
+ check(",,", ',', '\"', new String[] { "", "", "" });
+ check(",a,", ',', '\"', new String[] { "", "a", "" });
check("\"a,b,c\"", ',', '\"', new String[] { "a,b,c" });
check("\"a,b\",\"c\"", ',', '\"', new String[] { "a,b", "c" });
@@ -119,53 +119,27 @@
// example typically from Excel.
check("\"test1\",test2,\"0.00\",\"another, element here\",lastone", ',', '\"', new String[] { "test1", "test2", "0.00",
"another, element here", "lastone" });
+
+ check("\"FRED\",\"ZNAME\",\"Text Qualifier \" and seperator, in string\",\"ELYRIA\",\"OH\",\"\"", ',', '\"',
+ new String[] {"FRED", "ZNAME", "Text Qualifier \" and seperator, in string", "ELYRIA", "OH", ""});
check("a\",b,c\"", ',', '\"', new String[] { "a\"", "b", "c\"" });
check(" a, b ,c ", ',', '\"', new String[] { "a", "b", "c" });
check("\"a\", b , \"c\"", ',', '\"', new String[] { "a", "b", "c" });
- check("\"\",,,,\"last one\"", ',', '\"', new String[] { "", null, null, null, "last one" });
- check("\"first\",\"second\",", ',', '\"', new String[] { "first", "second", null });
+ check("\"\",,,,\"last one\"", ',', '\"', new String[] { "", "", "", "", "last one" });
+ check("\"first\",\"second\",", ',', '\"', new String[] { "first", "second", "" });
check("\" a,b,c\"", ',', '\"', new String[] { " a,b,c" });
check("\" a,b,c\",d", ',', '\"', new String[] { " a,b,c", "d" });
- //++++looks like both quotes should be returned in the result here.
- //let me know if I am wrong. pz
- check("\"a, b,\"\"c\"", ',', '\"', new String[] { "a, b,\"\"c" });
+ check("\"a, b,\"\"c\"", ',', '\"', new String[] { "a, b,\"c" });
+
+ check("one two three", ' ', '\u0000', new String[] {"one", "two", "three"});
+ check("\"one\" \"two\" three", ' ', '\"', new String[] {"one", "two", "three"});
+ check("\"one\" \"two\" three", ' ', '\"', new String[] {"one", "", "two", "", "three"});
}
- /**
- * Test some extreme cases
- */
- public void testSomeExtremeCases2() {
- check("\"a,b,c\"", ',', '\'', new String[] { "\"a", "b", "c\"" });
- check("\"a,b\",\"c\"", ',', '\'', new String[] { "\"a", "b\"", "\"c\"" });
- check("a,b,c", ',', '\'', new String[] { "a", "b", "c" });
- check(" a,b,c", ',', '\'', new String[] { "a", "b", "c" });
- check(" a,b,c", ',', '\'', new String[] { "a", "b", "c" });
-
- // example typically from Excel.
- check("\"test1\",test2,\"0.00\",\"another, element here\",lastone", ',', '\'', new String[] { "\"test1\"", "test2",
- "\"0.00\"", "\"another", "element here\"", "lastone" });
-
- // what would you expect of these ones?
-
- // +++++The parser allows qualified and unqualified elements to be
- // contained
- // on the same line. so it should break the elements down like so
- // 1 = a" -->" is part of the data since the element did not start with
- // a qualifier
- // 2 = b
- // 3 = c" --> same as #1
- // a",b,c"
- check("a\",b,c\"", ',', '\'', new String[] { "a\"", "b", "c\"" });
-
- check("\" a,b,c\"", ',', '\'', new String[] { "\" a", "b", "c\"" });
- check(" a, b ,c ", ',', '\'', new String[] { "a", "b", "c" });
-
- }
-
private void check(final String txtToParse, final char delim, final char qualifier, final String[] expected) {
- final List splitLineResults = ParserUtils.splitLine(txtToParse, delim, qualifier);
+ final List splitLineResults = ParserUtils.splitLine(txtToParse, delim, qualifier, 10);
assertEquals(
"Did Not Get Amount Of Elements Expected (d = " + delim + " q = " + qualifier + ") txt [" + txtToParse + "]",
@@ -175,7 +149,6 @@
assertEquals("expecting...", expected[i], splitLineResults.get(i));
}
}
-
public static void main(final String[] args) {
junit.textui.TestRunner.run(ParserUtilsSplitLineTest.class);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2006-11-26 13:55:21
|
Revision: 204
http://svn.sourceforge.net/pzfilereader/?rev=204&view=rev
Author: zepernick
Date: 2006-11-26 05:55:21 -0800 (Sun, 26 Nov 2006)
Log Message:
-----------
added a couple new checks
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-11-26 13:54:16 UTC (rev 203)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-11-26 13:55:21 UTC (rev 204)
@@ -132,6 +132,8 @@
check("\" a,b,c\"", ',', '\"', new String[] { " a,b,c" });
check("\" a,b,c\",d", ',', '\"', new String[] { " a,b,c", "d" });
check("\"a, b,\"\"c\"", ',', '\"', new String[] { "a, b,\"c" });
+ check("\"a, b,\"\"c\", \" test\"", ',', '\"', new String[] { "a, b,\"c", " test" });
+ check("\"a, b,\"\"c\", test", ',', '\"', new String[] { "a, b,\"c", "test" });
check("one two three", ' ', '\u0000', new String[] {"one", "two", "three"});
check("\"one\" \"two\" three", ' ', '\"', new String[] {"one", "two", "three"});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2006-11-26 14:01:14
|
Revision: 205
http://svn.sourceforge.net/pzfilereader/?rev=205&view=rev
Author: zepernick
Date: 2006-11-26 06:01:12 -0800 (Sun, 26 Nov 2006)
Log Message:
-----------
added test method in that was accidentally removed while combining with bx tests
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-11-26 13:55:21 UTC (rev 204)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2006-11-26 14:01:12 UTC (rev 205)
@@ -140,6 +140,37 @@
check("\"one\" \"two\" three", ' ', '\"', new String[] {"one", "", "two", "", "three"});
}
+ /**
+ * Test some extreme cases
+ */
+ public void testSomeExtremeCases2() {
+ check("\"a,b,c\"", ',', '\'', new String[] { "\"a", "b", "c\"" });
+ check("\"a,b\",\"c\"", ',', '\'', new String[] { "\"a", "b\"", "\"c\"" });
+ check("a,b,c", ',', '\'', new String[] { "a", "b", "c" });
+ check(" a,b,c", ',', '\'', new String[] { "a", "b", "c" });
+ check(" a,b,c", ',', '\'', new String[] { "a", "b", "c" });
+
+ // example typically from Excel.
+ check("\"test1\",test2,\"0.00\",\"another, element here\",lastone", ',', '\'', new String[] { "\"test1\"", "test2",
+ "\"0.00\"", "\"another", "element here\"", "lastone" });
+
+ // what would you expect of these ones?
+
+ // +++++The parser allows qualified and unqualified elements to be
+ // contained
+ // on the same line. so it should break the elements down like so
+ // 1 = a" -->" is part of the data since the element did not start with
+ // a qualifier
+ // 2 = b
+ // 3 = c" --> same as #1
+ // a",b,c"
+ check("a\",b,c\"", ',', '\'', new String[] { "a\"", "b", "c\"" });
+
+ check("\" a,b,c\"", ',', '\'', new String[] { "\" a", "b", "c\"" });
+ check(" a, b ,c ", ',', '\'', new String[] { "a", "b", "c" });
+
+ }
+
private void check(final String txtToParse, final char delim, final char qualifier, final String[] expected) {
final List splitLineResults = ParserUtils.splitLine(txtToParse, delim, qualifier, 10);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2007-02-04 15:02:39
|
Revision: 273
http://svn.sourceforge.net/pzfilereader/?rev=273&view=rev
Author: zepernick
Date: 2007-02-04 07:02:39 -0800 (Sun, 04 Feb 2007)
Log Message:
-----------
added test for empty tabs which is currently failing
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2007-01-23 09:38:19 UTC (rev 272)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2007-02-04 15:02:39 UTC (rev 273)
@@ -138,6 +138,9 @@
check("one two three", ' ', '\u0000', new String[] {"one", "two", "three"});
check("\"one\" \"two\" three", ' ', '\"', new String[] {"one", "two", "three"});
check("\"one\" \"two\" three", ' ', '\"', new String[] {"one", "", "two", "", "three"});
+
+ check (" , , ", ',', '"', new String[] {"","",""});
+ check (" \t \t ", '\t', '"', new String[] {"","",""});
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <zep...@us...> - 2007-02-06 14:43:10
|
Revision: 275
http://svn.sourceforge.net/pzfilereader/?rev=275&view=rev
Author: zepernick
Date: 2007-02-06 06:43:08 -0800 (Tue, 06 Feb 2007)
Log Message:
-----------
adding more tests
Modified Paths:
--------------
trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
Modified: trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java
===================================================================
--- trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2007-02-06 14:41:50 UTC (rev 274)
+++ trunk/PZFileReader/src/test/java/net/sf/pzfilereader/parserutils/ParserUtilsSplitLineTest.java 2007-02-06 14:43:08 UTC (rev 275)
@@ -3,6 +3,7 @@
import java.util.List;
import junit.framework.TestCase;
+import net.sf.pzfilereader.util.PZConstants;
import net.sf.pzfilereader.util.ParserUtils;
import net.sf.pzfilereader.utilities.UnitTestUtils;
@@ -140,7 +141,12 @@
check("\"one\" \"two\" three", ' ', '\"', new String[] {"one", "", "two", "", "three"});
check (" , , ", ',', '"', new String[] {"","",""});
+ check (" , , ", ',', PZConstants.NO_QUALIFIER, new String[] {"","",""});
check (" \t \t ", '\t', '"', new String[] {"","",""});
+ check (" \t \t ", '\t', PZConstants.NO_QUALIFIER, new String[] {"","",""});
+ check (" ", ' ', '"', new String[] {"","",""});
+ check (" ", ' ', PZConstants.NO_QUALIFIER, new String[] {"","",""});
+
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|