Browse Source

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>
3.8.x
Duncan Tyler 10 years ago
committed by Paul Poulain
parent
commit
7876d4fa8d
  1. 18
      t/SIP_Sip.t

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

Loading…
Cancel
Save