# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..7\n"; } END {print "not ok 1\n" unless $loaded;} use HTMLObject::Base; use HTMLObject::ReadCookie; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): # Test the makeValidHTML method. my $doc = HTMLObject::Base->new(); my $cookieObj = HTMLObject::ReadCookie->new(); my $result = $doc->makeValidHTML(<<"END_OF_HTML"); This is a link Bold

Hello END_OF_HTML if ($result eq $prettyVersion) { print "ok 2\n"; } else { print "not ok 2\n"; } # test the formEncode() method in regards to the ignoreTags and sequence # support. my $unEncodedString = "Hello World!
This \\& That is a tag test."; my $encodedString = "Hello World!<br />This & That is a <a/> <sub><i>tag</i></sub> <sup>test</sup>."; my $result = $doc->formEncode(string => $unEncodedString, ignoreTags => "b|u"); if ($result eq $encodedString) { print "ok 3\n"; } else { print "result = '$result'\n"; print "not ok 3\n"; } $encodedString = "Hello World!<br />This & That is a <a/> tag test."; $result = $doc->formEncode(string => $unEncodedString, sequence => "formatting"); if ($result eq $encodedString) { print "ok 4\n"; } else { print "result = '$result'\n"; print "not ok 4\n"; } $encodedString = "Hello World!
This & That is a <a/> tag test."; $result = $doc->formEncode(string => $unEncodedString, sequence => "formatting,seperator"); if ($result eq $encodedString) { print "ok 5\n"; } else { print "result = '$result'\n"; print "not ok 5\n"; } $encodedString = "Hello <b>World</b>!<br />This & That is a <a/> <sub><u><i>tag</i></u></sub> <sup>test</sup>."; $result = $doc->formEncode($unEncodedString); if ($result eq $encodedString) { print "ok 6\n"; } else { print "result = '$result'\n"; print "not ok 6\n"; } my $string = "This is a cookie encode\n%Test;&&Hello World.1234567890~!@#$%^&*()_-`'\""; $result = $doc->encodeString($string); my $result2 = $cookieObj->decodeString(string => $result); if ($result2 eq $string) { print "ok 7\n"; } else { print "result = '$result', result2 = '$result2'\n"; print "not ok 7\n"; }