summaryrefslogtreecommitdiff
path: root/lib/IO/Zlib/t/uncomp1.t
blob: 8424a27363be57ac625808777eec0ad5cc568aa9 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
BEGIN {
    if( $ENV{PERL_CORE} ) {
	@INC = '../lib';
	chdir 't';
    }
}

use IO::Zlib;

sub ok
{
    my ($no, $ok) = @_ ;

    #++ $total ;
    #++ $totalBad unless $ok ;

    print "ok $no\n" if $ok ;
    print "not ok $no\n" unless $ok ;
}

print "1..10\n";

$hello = <<EOM ;
hello world
this is a test
EOM

$name = "IO-Zlib-test";

if (open(FH, ">$name")) {
    binmode FH;
    print FH $hello;
    close FH;
} else {
    die "$name: $!";
}

ok(1, $file = IO::Zlib->new());
ok(2, $file->open($name, "rb"));
ok(3, !$file->eof());
ok(4, $file->read($uncomp, 1024) == length($hello));
ok(5, $file->eof());
ok(6, $file->opened());
ok(7, $file->close());
ok(8, !$file->opened());

unlink($name);

ok(9, $hello eq $uncomp);

ok(10, !defined(IO::Zlib->new($name, "rb")));