~ubuntu-branches/ubuntu/warty/libstring-crc32-perl/warty

« back to all changes in this revision

Viewing changes to t/crc.t

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2002-10-27 15:19:27 UTC
  • Revision ID: james.westby@ubuntu.com-20021027151927-0gz9w7qltmbjrnlh
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/local/bin/perl  -I./blib/arch -I./blib/lib
 
2
 
 
3
require String::CRC32;
 
4
 
 
5
$string1 = "This is the test string";
 
6
 
 
7
$l1 = length($string1);
 
8
 
 
9
print "1..", $l1+4, "\n";
 
10
 
 
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");
 
14
 
 
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");
 
18
 
 
19
$i = 2;
 
20
 
 
21
$l=$l1+3;
 
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);
 
26
  $i++;
 
27
  print ($v1 == 1835534707 ? "ok $i\n" : "not ok $i\n");
 
28
}
 
29
 
 
30
$l=$l1+4;
 
31
print "\n$l) Test the CRC of a file\n";
 
32
$i++;
 
33
open(TESTFILE,"testfile") || 
 
34
  open(TESTFILE,"t/testfile") ||
 
35
  open(TESTFILE," ../testfile") || die "No such file!\n";
 
36
$v1 = String::CRC32::crc32(*TESTFILE);
 
37
close TESTFILE;
 
38
print ($v1 == 1925609391 ? "ok $i\n" : "not ok $i\n");