File: reread.t

package info (click to toggle)
libcrypt-random-source-perl 0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 556; sh: 6; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 581 bytes parent folder | download | duplicates (2)
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
30
31
32
# ex: set sw=4 et:
use strict;
use warnings;

use Test::More 0.88;
use Test::Fatal;

use ok 'Crypt::Random::Source::Base::Handle';

{
    my $p = Crypt::Random::Source::Base::Handle->new( handle => \*DATA );

    is( $p->handle, \*DATA, "correct handle set up" );

    is( $p->get(4), "foo\n", "read some bytes" );

    like exception { $p->get(100) }, qr/enough bytes/i, "underread";

    $p->allow_under_read(1);

    my $buf;
    is exception { $buf = $p->get(100) }, undef, "underread now allowed";

    is( $buf, '', "nothing read" );
}

done_testing;

__DATA__
foo
bar
gorch