File: read-sha.t

package info (click to toggle)
libio-callback-perl 2.00-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 248 kB
  • sloc: perl: 389; makefile: 2; sh: 1
file content (29 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# IO::Callback 1.08 t/read-sha.t
# Check that IO::Callback inter-operates with Digest::SHA

use strict;
use warnings;

use Test::More;
BEGIN {
    eval 'use Digest::SHA';
    plan skip_all => 'Digest::SHA required' if $@;
    plan skip_all => "Bad Digest::SHA"
        if Digest::SHA->VERSION eq '5.89'
        || Digest::SHA->VERSION eq '5.90';
    plan tests => 2;
}
use Test::NoWarnings;

use IO::Callback;

my $block = "foo\n" x 1000;
my $lines = 0;
my $fh = IO::Callback->new('<', sub {
    return if $lines++ >= 1000;
    return $block;
});

my $digest = Digest::SHA->new(256)->addfile($fh)->hexdigest;
is( $digest, "df1c1217e3256c67362044595cfe27918f43b25287721174c96726c078e3ecbe", "digest as expected" );