From: eldy <> Date: Fri, 30 Dec 2011 17:31:16 +0000 (+0000) Subject: Add unit test X-Git-Tag: AWSTATS_7_1_BETA2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=384417c97c71954cdd95d5142a26f9dd81f6953b;p=thirdparty%2FAWStats.git Add unit test --- diff --git a/test/test.pl b/test/test.pl index 831e65ef..d75fef56 100644 --- a/test/test.pl +++ b/test/test.pl @@ -146,7 +146,7 @@ while(1==1) # Compare html file - print "Test $test terminé avec succès.\n"; + print "Test $test finished success.\n"; } sleep 5; diff --git a/test/testunit/testuncompileregex.pl b/test/testunit/testuncompileregex.pl new file mode 100755 index 00000000..1b6972e6 --- /dev/null +++ b/test/testunit/testuncompileregex.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl -w +use Test::Simple tests => 1; + + +# Functions to tests (copy paste from awstats.pl) +sub UnCompileRegex { + shift =~ /\(\?[-\w]*:(.*)\)/; + return $1; +} +sub UnCompileRegex2 { + shift =~ /\(\?[-\w]*:(.*)\)/; + return $1; +} + + + +push @INC, "../../wwwroot/cgi-bin/lib"; +my $loadret = require "worms.pm"; +@WormsSearchIDOrder = map { qr/$_/i } @WormsSearchIDOrder; + +foreach (@WormsSearchIDOrder) +{ + my $worm = &UnCompileRegex($_); + print "> ".$_." -> ".$worm."\n"; + +} + + +ok(&UnCompileRegex('(?i-xsm:\/default\.ida)') eq '\/default\.ida'); # check that we got something +ok(&UnCompileRegex2('(?i-xsm:\/default\.ida)') eq '\/default\.ida'); # check that we got something + \ No newline at end of file