xref: /openbsd/gnu/usr.bin/perl/cpan/IO-Zlib/t/basic.t (revision 3cab2bb3)
1use IO::Zlib;
2
3sub ok
4{
5    my ($no, $ok) = @_ ;
6
7    #++ $total ;
8    #++ $totalBad unless $ok ;
9
10    print "ok $no\n" if $ok ;
11    print "not ok $no\n" unless $ok ;
12}
13
14$name="test.gz";
15
16print "1..17\n";
17
18$hello = <<EOM ;
19hello world
20this is a test
21EOM
22
23ok(1, $file = IO::Zlib->new($name, "wb"));
24ok(2, $file->print($hello));
25ok(3, $file->opened());
26ok(4, $file->close());
27ok(5, !$file->opened());
28
29ok(6, $file = IO::Zlib->new());
30ok(7, $file->open($name, "rb"));
31ok(8, !$file->eof());
32ok(9, $file->read($uncomp, 1024) == length($hello));
33ok(10, $uncomp eq $hello);
34ok(11, $file->eof());
35ok(12, $file->opened());
36ok(13, $file->close());
37ok(14, !$file->opened());
38
39$file = IO::Zlib->new($name, "rb");
40ok(15, $file->read($uncomp, 1024, length($uncomp)) == length($hello));
41ok(16, $uncomp eq $hello . $hello);
42$file->close();
43
44unlink($name);
45
46ok(17, !defined(IO::Zlib->new($name, "rb")));
47