1
#!/usr/local/bin/perl -I./blib/arch -I./blib/lib
5
$string1 = "This is the test string";
7
$l1 = length($string1);
9
print "1..", $l1+4, "\n";
11
print "\n1) Test the CRC of a string variable\n";
12
$v1 = String::CRC32::crc32($string1);
13
print ($v1 == 1835534707 ? "ok 1\n" : "not ok 1\n");
15
print "\n2) Test the CRC of a string\n";
16
$v1 = String::CRC32::crc32("This is another test string");
17
print ($v1 == 2154698217 ? "ok 2\n" : "not ok 2\n");
22
print "\n3..$l) Test the CRC of various substrings (using crcinit)\n";
23
for ($j = 0; $j <= $l1; $j++) {
24
$v1 = String::CRC32::crc32(substr($string1, 0, $j));
25
$v1 = String::CRC32::crc32(substr($string1, $j), $v1);
27
print ($v1 == 1835534707 ? "ok $i\n" : "not ok $i\n");
31
print "\n$l) Test the CRC of a file\n";
33
open(TESTFILE,"testfile") ||
34
open(TESTFILE,"t/testfile") ||
35
open(TESTFILE," ../testfile") || die "No such file!\n";
36
$v1 = String::CRC32::crc32(*TESTFILE);
38
print ($v1 == 1925609391 ? "ok $i\n" : "not ok $i\n");