Test some error conditions
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 16 Jun 2018 21:11:38 +0000 (00:11 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 16 Jun 2018 21:11:38 +0000 (00:11 +0300)
Makefile.PL
README
t/Digest-HighwayHash.t

index 79a7349796486c724286aca8fe53f5c68b860f15..4c8cab39c274fa8f2ecd8dc2d0939dd68cb6f4b1 100644 (file)
@@ -12,6 +12,9 @@ WriteMakefile(
        PREREQ_PM         => {
                qw/Math::Int64 0/,
        },
+       TEST_REQUIRES     => {
+               qw/Test::Exception 0/,
+       },
        INC               => '-I. -Ihighwayhash/c',
        OBJECT            => '$(O_FILES)',
        META_ADD         => {
diff --git a/README b/README
index cb8733643896a7709212350b4d4d5ad22243554c..d614c0851a478d4a8ec07d1e5636bacff317aad4 100644 (file)
--- a/README
+++ b/README
@@ -18,6 +18,7 @@ DEPENDENCIES
 This module requires these other modules and libraries:
 
 * Math::Int64
+* Test::Exception
 
 COPYRIGHT AND LICENCE
 
index c4880a4d00d7ca22397f6e4fe265a80f5113ca04..594b4da0f68fa7649207189701282cd08c6e1cac 100644 (file)
@@ -2,9 +2,15 @@
 use strict;
 use warnings;
 
-use Test::More tests => 4;
+use Test::More tests => 7;
+use Test::Exception;
+
 BEGIN { use_ok('Digest::HighwayHash') };
 
 is highway_hash64([1, 2, 3, 4], 'hello'), '11956820856122239241', 'highway_hash64';
 is_deeply highway_hash128([1, 2, 3, 4], 'hello'), ['3048112761216189476', '13900443277579286659'], 'highway_hash128';
 is_deeply highway_hash256([1, 2, 3, 4], 'hello'), ['8099666330974151427', '17027479935588128037', '4015249936799013189', '10027181291351549853'], 'highway_hash256';
+
+throws_ok { highway_hash64 1, 'hello' }                qr/not an ARRAY reference/, 'bad key 1';
+throws_ok { highway_hash128 [1, 2], 'hello' }          qr/Key for highway_hash must be a 4-element array/, 'bad key 2';
+throws_ok { highway_hash256 [1, 2, 3, 4, 5], 'hello' } qr/Key for highway_hash must be a 4-element array/, 'bad key 3';
This page took 0.012444 seconds and 4 git commands to generate.