Export cat (stream) interface too
[digest-highwayhash.git] / t / Digest-HighwayHash.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 10;
6 use Test::Exception;
7
8 BEGIN { use_ok('Digest::HighwayHash') };
9
10 is highway_hash64([1, 2, 3, 4], 'hello'), '11956820856122239241', 'highway_hash64';
11 is_deeply highway_hash128([1, 2, 3, 4], 'hello'), ['3048112761216189476', '13900443277579286659'], 'highway_hash128';
12 is_deeply highway_hash256([1, 2, 3, 4], 'hello'), ['8099666330974151427', '17027479935588128037', '4015249936799013189', '10027181291351549853'], 'highway_hash256';
13
14 my $state64 = Digest::HighwayHash->new([1, 2, 3, 4]);
15 my $state128 = Digest::HighwayHash->new([1, 2, 3, 4]);
16 my $state256 = Digest::HighwayHash->new([1, 2, 3, 4]);
17
18 $state64->append('hello');
19 $state64->append('');
20 $state128->append('h');
21 $state128->append('ell');
22 $state128->append('o');
23 $state256->append('hell');
24 $state256->append('o');
25
26 is $state64->finish64, '11956820856122239241', 'finish64';
27 is_deeply $state128->finish128, ['3048112761216189476', '13900443277579286659'], 'finish128';
28 is_deeply $state256->finish256, ['8099666330974151427', '17027479935588128037', '4015249936799013189', '10027181291351549853'], 'finish256';
29
30 throws_ok { highway_hash64 1, 'hello' } qr/not an ARRAY reference/, 'bad key 1';
31 throws_ok { highway_hash128 [1, 2], 'hello' } qr/Key for highway_hash must be a 4-element array/, 'bad key 2';
32 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.024343 seconds and 4 git commands to generate.