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@web.de>
Test passes.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Duncan Tyler 2011-12-08 14:38:28 +13:00 committed by Paul Poulain
parent ffb544e8e4
commit 7876d4fa8d

View file

@ -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");