1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as `perl Digest-FNV.t' 3 4######################### 5 6# change 'tests => 2' to 'tests => last_test_to_print'; 7 8use Test::More tests => 10; 9use lib ( @INC, '../lib', '../blib/arch/auto/Digest/FNV' ); 10BEGIN { use_ok('Digest::FNV') }; 11 12 13my $fail = 0; 14foreach my $constname (qw( 15 FNV0_32_INIT FNV1A_64_LOWER FNV1A_64_UPPER FNV1_32A_INIT FNV1_32_INIT 16 FNV1_64_LOWER FNV1_64_UPPER)) { 17 next if (eval "my \$a = $constname; 1"); 18 if ($@ =~ /^Your vendor has not defined Digest::FNV macro $constname/) { 19 print "# pass: $@"; 20 } else { 21 print "# fail: $@"; 22 $fail = 1; 23 } 24 25} 26 27ok( $fail == 0 , 'Constants' ); 28######################### 29 30# Insert your test code below, the Test::More module is use()ed here so read 31# its man page ( perldoc Test::More ) for help writing this test script. 32 33my %test32 = ( 34 'http://www.google.com/' => 1088293357, 35 'Digest::FNV' => 2884831097, 36 'abc123' => 3613024805, 37 'pgsql://10.0.1.33:5432/postgres' => 1222035128 38); 39 40my %test32a = ( 41 'http://www.google.com/' => 912201313, 42 'Digest::FNV' => 3166764897, 43 'abc123' => 951228933, 44 'pgsql://10.0.1.33:5432/postgres' => 713413542 45); 46 47# Test fnv() && fnv32 48foreach my $key (keys %test32) { 49 my $fnv = Digest::FNV::fnv($key); 50 my $fnv32 = Digest::FNV::fnv32($key); 51 ok ( 52 $fnv == $fnv32 && 53 $fnv == $test32{$key}, 54 'fnv/fnv32: '.$key 55 ); 56} 57 58# Test fnv32a() 59foreach my $key (keys %test32) { 60 my $fnv32a = Digest::FNV::fnv32a($key); 61 ok ( 62 $fnv32a == $test32a{$key}, 63 'fnv32a: '.$key 64 ); 65} 66