Bug 9446 [Revised] Use DataTables on Z39.50 servers administration page
[koha.git] / t / SIP_Sip.t
blobd837609b34cc2a4771603eeca3bbc490dd622082
1 #!/usr/bin/perl
3 # This Koha test module is a stub!
4 # Add more tests here!!!
6 use strict;
7 use warnings;
9 use Test::More tests => 8;
11 BEGIN {
12 use FindBin;
13 use lib "$FindBin::Bin/../C4/SIP";
14 use_ok('C4::SIP::Sip');
17 my $date_time = Sip::timestamp();
18 like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format no param');
20 my $t = time();
22 $date_time = Sip::timestamp($t);
23 like( $date_time, qr/^\d{8} \d{6}$/, 'Timestamp format secs');
25 $date_time = Sip::timestamp('2011-01-12');
26 ok( $date_time eq '20110112 235900', 'Timestamp iso date string');
28 my $myChecksum = Sip::Checksum::checksum("12345");
29 my $checker = 65281;
30 my $stringChecksum = Sip::Checksum::checksum("teststring");
31 my $stringChecker = 64425;
33 is( $myChecksum, $checker, "Checksum: $myChecksum matches expected output");
34 is( $stringChecksum, $stringChecker, "Checksum: $stringChecksum matches expected output");
36 my $testdata = "abcdAZ";
37 my $something = Sip::Checksum::checksum($testdata);
39 $something = sprintf("%4X", $something);
40 ok( Sip::Checksum::verify_cksum($testdata.$something), "Checksum: $something is valid.");
42 my $invalidTest = Sip::Checksum::verify_cksum("1234567");
43 is($invalidTest, 0, "Checksum: 1234567 is invalid as expected");