]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Add unit test
authoreldy <>
Fri, 30 Dec 2011 17:31:16 +0000 (17:31 +0000)
committereldy <>
Fri, 30 Dec 2011 17:31:16 +0000 (17:31 +0000)
test/test.pl
test/testunit/testuncompileregex.pl [new file with mode: 0755]

index 831e65ef7edb0659f80d90220344b9593510eff0..d75fef5677299bc67a06bdfddd06b40bde504fe7 100644 (file)
@@ -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 (executable)
index 0000000..1b6972e
--- /dev/null
@@ -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