diff options
Diffstat (limited to 't')
-rw-r--r-- | t/29-app-hashl.t | 15 | ||||
-rw-r--r-- | t/in/1k-firsthalf | bin | 0 -> 512 bytes |
2 files changed, 14 insertions, 1 deletions
diff --git a/t/29-app-hashl.t b/t/29-app-hashl.t index 325c3b2..fd8f95b 100644 --- a/t/29-app-hashl.t +++ b/t/29-app-hashl.t @@ -3,7 +3,7 @@ use strict; use warnings; use 5.010; -use Test::More tests => 28; +use Test::More tests => 31; use_ok('App::Hashl'); @@ -76,3 +76,16 @@ unlink('t/in/hashl.db'); is($hashl->file_in_db('t/in/4'), $IGNORED, 'file still ignored'); is_deeply([$hashl->files()], [], 'no files in db'); + +undef $hashl; + +my $hash_512 = App::Hashl->new(read_size => 512)->hash_file('t/in/1k'); +my $hash_1k = App::Hashl->new(read_size => 1024)->hash_file('t/in/1k'); +my $hash_2k = App::Hashl->new(read_size => 2048)->hash_file('t/in/1k'); + +my $hash_1k_half = App::Hashl->new()->hash_file('t/in/1k-firsthalf'); + +is($hash_1k, $hash_2k, + 'Same hash for read_size > filesize and read_size == file_size'); +isnt($hash_512, $hash_1k, 'Partial hashing does not hash full file'); +is($hash_512, $hash_1k_half, 'Partial hashing produces correct hash'); diff --git a/t/in/1k-firsthalf b/t/in/1k-firsthalf Binary files differnew file mode 100644 index 0000000..eda0143 --- /dev/null +++ b/t/in/1k-firsthalf |