add tests for all quoting functions
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 31 Mar 2007 00:59:40 +0000 (02:59 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 31 Mar 2007 00:59:40 +0000 (02:59 +0200)
test.pl

diff --git a/test.pl b/test.pl
index ee6478ed648d5930cdcf2cf1f729383c1d8c6599..a6c6e920f7f7ce1d4d887a0fc4ddadaf0a052e29 100644 (file)
--- a/test.pl
+++ b/test.pl
@@ -1,20 +1,38 @@
-
-# TODO - Write tests.
-
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl test.pl'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use Test;
-BEGIN { plan tests => 1 };
-use PLP;
-ok(1); # If we made it this far, we're ok.
-
-#########################
-
-# Insert your test code below, the Test module is use()ed here so read
-# its man page ( perldoc Test ) for help writing this test script.
+use strict;
+
+use Test::More tests => 6;
+
+BEGIN { use_ok('PLP') }
+
+PLP::Functions->import();
+
+is(
+       Entity(q{<a test="'&'"/>}),
+       "&lt;a test=&quot;'&amp;'&quot;/&gt;",
+       'Entity escaping'
+);
+
+is(
+       Entity(" . .  .   .\t. \n"),
+       " . .&nbsp;&nbsp;.&nbsp;&nbsp; .&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;. <br>\n",
+       'Entity formatting'
+);
+
+is(
+       EncodeURI("/test.plp?f00=~_a&b!\n "),
+       '/test.plp?f00%3d~_a%26b!%0a%20',
+       'EncodeURI'
+);
+
+is(
+       DecodeURI('?f0%30+%20b%61r!'),
+       '?f00  bar!',
+       'DecodeURI'
+);
+
+is(
+       DecodeURI('%0A%0a%a %000 %fg%%fF'."\377"),
+       "\n\n%a \0000 %fg%\377\377",
+       'DecodeURI 2'
+);