Thread: [Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/utilTests HTMLParserUtilsTest.java,1.18,1.19
Brought to you by:
derrickoswald
From: Alberto N. <an...@us...> - 2004-08-27 09:57:18
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/utilTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27405 Modified Files: HTMLParserUtilsTest.java Log Message: New tests added for: bug fixing and trimAllTags method test. Index: HTMLParserUtilsTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/utilTests/HTMLParserUtilsTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** HTMLParserUtilsTest.java 17 Jul 2004 13:45:03 -0000 1.18 --- HTMLParserUtilsTest.java 27 Aug 2004 09:56:56 -0000 1.19 *************** *** 167,170 **** --- 167,195 ---- ParserUtils.trimSpacesBeginEnd("<DIV> Trim all spaces but not the ones inside the string </DIV>", "<>DIV/") ); + assertStringEquals( + "modified text", + "0", + ParserUtils.trimSpacesBeginEnd("0", "") + ); + assertStringEquals( + "modified text", + "verifying the last char x", + ParserUtils.trimSpacesBeginEnd("verifying the last char x", "") + ); + assertStringEquals( + "modified text", + "verifying the last char x", + ParserUtils.trimSpacesBeginEnd("verifying the last char x ", "") + ); + assertStringEquals( + "modified text", + "x verifying the first char", + ParserUtils.trimSpacesBeginEnd("x verifying the first char", "") + ); + assertStringEquals( + "modified text", + "x verifying the first char", + ParserUtils.trimSpacesBeginEnd(" x verifying the first char", "") + ); } *************** *** 216,219 **** --- 241,280 ---- ParserUtils.trimTags("<DIV><DIV> +12.5 </DIV></DIV> ALL OK", new String[] {"DIV"}, false, true) ); + // Test trimAllTags method + assertStringEquals( + "modified text", + " +12.5 ALL OK", + ParserUtils.trimAllTags("<DIV><DIV> +12.5 </DIV></DIV> ALL OK", false) + ); + assertStringEquals( + "modified text", + " ALL OK", + ParserUtils.trimAllTags("<DIV><DIV> +12.5 </DIV></DIV> ALL OK", true) + ); + assertStringEquals( + "modified text", + " +12.5 ", + ParserUtils.trimAllTags("<DIV><DIV> +12.5 </DIV></DIV>", false) + ); + assertStringEquals( + "modified text", + "", + ParserUtils.trimAllTags("<DIV><DIV> +12.5 </DIV></DIV>", true) + ); + assertStringEquals( + "modified text", + " YYY ", + ParserUtils.trimAllTags("<XXX> YYY <ZZZ>", false) + ); + assertStringEquals( + "modified text", + "YYY", + ParserUtils.trimAllTags("YYY", false) + ); + assertStringEquals( + "modified text", + "> OK <", + ParserUtils.trimAllTags("> OK <", true) + ); } catch (Exception e) *************** *** 274,277 **** --- 335,361 ---- ParserUtils.trimTags("<DIV><DIV> +12.5 </DIV></DIV> ALL OK", filter, false, true) ); + NodeFilter filterTableRow = new TagNameFilter("TR"); + NodeFilter filterTableColumn = new TagNameFilter("TD"); + OrFilter filterOr = new OrFilter(filterTableRow, filterTableColumn); + assertStringEquals( + "modified text", + " ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr) + ); + assertStringEquals( + "modified text", + "<TD> +12.5 </TD> ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr, false, false) + ); + assertStringEquals( + "modified text", + " +12.5 ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr, true, false) + ); + assertStringEquals( + "modified text", + " ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr, false, true) + ); } catch (Exception e) *************** *** 332,335 **** --- 416,442 ---- ParserUtils.trimTags("<DIV><DIV> +12.5 </DIV></DIV> ALL OK", filter, false, true) ); + NodeFilter filterTableRow = new NodeClassFilter(TableRow.class); + NodeFilter filterTableColumn = new NodeClassFilter(TableColumn.class); + OrFilter filterOr = new OrFilter(filterTableRow, filterTableColumn); + assertStringEquals( + "modified text", + " ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr) + ); + assertStringEquals( + "modified text", + "<TD> +12.5 </TD> ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr, false, false) + ); + assertStringEquals( + "modified text", + " +12.5 ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr, true, false) + ); + assertStringEquals( + "modified text", + " ALL OK", + ParserUtils.trimTags("<TR><TD> +12.5 </TD></TR> ALL OK", filterOr, false, true) + ); } catch (Exception e) |