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. |