Merge remote-tracking branch 'origin/master' into new/bug_5327
authorPaul Poulain <paul.poulain@biblibre.com>
Thu, 15 Dec 2011 12:49:47 +0000 (13:49 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Thu, 15 Dec 2011 12:49:47 +0000 (13:49 +0100)
C4/TTParser.pm
t/AuthoritiesMarc_UNIMARC.t
t/Boolean.t
t/SIP_Sip.t
t/Scrubber.t

index e088124..2ea31a6 100755 (executable)
@@ -22,7 +22,6 @@ sub next_token{
 
 #unshift token back on @tokens
 sub unshift_token{
-    my $self = shift;
     unshift @tokens, shift;
 }
 
index 0a55cd6..4d26f39 100755 (executable)
@@ -6,9 +6,11 @@
 use strict;
 use warnings;
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 
 BEGIN {
         use_ok('C4::AuthoritiesMarc::UNIMARC');
 }
 
+my @test = C4::AuthoritiesMarc::UNIMARC::default_auth_type_location();
+ok(($test[0] == 152) && ($test[1] eq 'b'), "correct variables being returned");
index fb3b0bf..af5c8b7 100755 (executable)
@@ -19,3 +19,4 @@ is( true_p('YES'),  '1', 'verified case insensitivity' );
 
 is( true_p(undef), undef, 'recognizes undefined as not boolean' );
 is( true_p('foo'), undef, 'recognizes \'foo\' as not boolean' );
+is( true_p([]), undef, 'recognizes a reference as not a boolean' );
index 879c983..d837609 100755 (executable)
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 4;
+use Test::More tests => 8;
 
 BEGIN {
         use FindBin;
@@ -25,3 +25,19 @@ like( $date_time, qr/^\d{8}    \d{6}$/, 'Timestamp format secs');
 $date_time = Sip::timestamp('2011-01-12');
 ok( $date_time eq '20110112    235900', 'Timestamp iso date string');
 
+my $myChecksum = Sip::Checksum::checksum("12345");
+my $checker = 65281;
+my $stringChecksum = Sip::Checksum::checksum("teststring");
+my $stringChecker = 64425;
+
+is( $myChecksum, $checker, "Checksum: $myChecksum matches expected output");
+is( $stringChecksum, $stringChecker, "Checksum: $stringChecksum matches expected output");
+
+my $testdata = "abcdAZ";
+my $something = Sip::Checksum::checksum($testdata);
+
+$something =  sprintf("%4X", $something);
+ok( Sip::Checksum::verify_cksum($testdata.$something), "Checksum: $something is valid.");
+
+my $invalidTest = Sip::Checksum::verify_cksum("1234567");
+is($invalidTest, 0, "Checksum: 1234567 is invalid as expected");
index ce1503f..0fe3a60 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 11;
+use Test::More tests => 19;
 BEGIN {
        use FindBin;
        use lib $FindBin::Bin;
@@ -20,7 +20,7 @@ sub pretty_line {
 
 my ($scrubber,$html,$result,@types,$collapse);
 $collapse = 1;
-@types = qw(comment tag);
+@types = qw(default comment tag staff);
 $html = q|
 <![CDATA[selfdestruct]]&#x5d;>
 <?php  echo(" EVIL EVIL EVIL "); ?>    <!-- COMMENT -->
@@ -58,7 +58,7 @@ $collapse and $result =~ s/\s*\n\s*/\n/g;
 print pretty_line('default'), $result, "\n", pretty_line();
 
 foreach(@types) {
-       ok($scrubber = C4::Scrubber->new($_), "Constructor: C4::Scrubber->new($_)");
+       ok($scrubber = C4::Scrubber->new($_), "testing Constructor: C4::Scrubber->new($_)");
        ok(printf("# scrubber settings: default %s, comment %s, process %s\n",
                $scrubber->default(),$scrubber->comment(),$scrubber->process()),
                "Outputting settings from scrubber object (type: $_)"
@@ -67,4 +67,22 @@ foreach(@types) {
        $collapse and $result =~ s/\s*\n\s*/\n/g;
        print pretty_line($_), $result, "\n", pretty_line();
 }
+
+print "\n\n######################################################\nStart of invalid tests\n";
+
+#Test for invalid new entry
+eval{
+       C4::Scrubber->new("");
+       fail("test should fail on entry of ''\n");
+};
+pass("Test should have failed on entry of '' (empty string) and it did. YAY!\n");
+
+eval{
+       C4::Scrubber->new("Client");
+       fail("test should fail on entry of 'Client'\n");
+};
+pass("Test should have failed on entry of 'Client' and it did. YAY!\n");
+
+print "######################################################\n";
+
 diag "done.\n";