[Patches] [PATCH] [SIGNED-OFF] Added unit tests for Sip Checksum.pm

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Tue Dec 13 22:05:53 NZDT 2011


From: Duncan Tyler <duncan at duncan-SoT.wgtn.cat-it.co.nz>
Date: Thu, 8 Dec 2011 14:38:28 +1300
Subject: [PATCH] [SIGNED-OFF] Added unit tests for Sip Checksum.pm

http://bugs.koha-community.org/show_bug.cgi?id=5327
Signed-off-by: Katrin Fischer <Katrin.Fischer.83 at web.de>
Test passes.
---
 t/SIP_Sip.t |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/t/SIP_Sip.t b/t/SIP_Sip.t
index 879c983..d837609 100755
--- a/t/SIP_Sip.t
+++ b/t/SIP_Sip.t
@@ -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");
-- 
1.7.5.4


More information about the Patches mailing list