Codebase list libcryptx-perl / 33fef90
missing checksum.t Karel Miko 7 years ago
1 changed file(s) with 47 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 use strict;
1 use warnings;
2
3 use Test::More tests => 24;
4
5 use Crypt::Checksum ':all';
6 use Crypt::Checksum::Adler32;
7 use Crypt::Checksum::CRC32;
8
9 my $a32 = Crypt::Checksum::Adler32->new;
10 is($a32->hexdigest, "00000001");
11 is($a32->hexdigest, "00000001");
12 $a32->add("a");
13 is($a32->hexdigest, "00620062");
14 $a32->reset;
15 is($a32->hexdigest, "00000001");
16 $a32->add("abc");
17 is($a32->hexdigest, "024d0127");
18 $a32->reset;
19 $a32->add("abc");
20 $a32->add("abc");
21 is($a32->hexdigest, "080c024d");
22 $a32->reset;
23 $a32->add("abcabc");
24 is($a32->hexdigest, "080c024d");
25 $a32->reset;
26 $a32->add("\xFF" x 32);
27 is($a32->hexdigest, "0e2e1fe1");
28 is(adler32_data_hex("a"), "00620062");
29 is(adler32_data("a"), pack("H*","00620062"));
30
31 is(crc32_data_hex("a"), "e8b7be43");
32 is(crc32_data_hex("libtomcrypt"), "b37376ef");
33 is(crc32_data_hex("This is the test string"), "6d680973");
34 is(crc32_data_int("This is the test string"), 1835534707);
35 is(crc32_data_hex("This is another test string"), "806e15e9");
36 is(crc32_data_int("This is another test string"), 2154698217);
37
38 is(crc32_file_hex("t/data/binary-test.file"), "24111fed");
39 is(crc32_file_hex("t/data/text-CR.file"), "1ca430c6");
40 is(crc32_file_hex("t/data/text-CRLF.file"), "4d434dfb");
41 is(crc32_file_hex("t/data/text-LF.file"), "9f9b8258");
42
43 is(adler32_file_hex("t/data/binary-test.file"), "f35fb68a");
44 is(adler32_file_hex("t/data/text-CR.file"), "948e2644");
45 is(adler32_file_hex("t/data/text-CRLF.file"), "3f0e2702");
46 is(adler32_file_hex("t/data/text-LF.file"), "86ba260b");