This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Scalar-List-Utils to CPAN version 1.26
[perl5.git] / cpan / IO-Zlib / t / basic.t
1 use IO::Zlib;
2
3 sub 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
16 print "1..17\n";
17
18 $hello = <<EOM ;
19 hello world
20 this is a test
21 EOM
22
23 ok(1, $file = IO::Zlib->new($name, "wb"));
24 ok(2, $file->print($hello));
25 ok(3, $file->opened());
26 ok(4, $file->close());
27 ok(5, !$file->opened());
28
29 ok(6, $file = IO::Zlib->new());
30 ok(7, $file->open($name, "rb"));
31 ok(8, !$file->eof());
32 ok(9, $file->read($uncomp, 1024) == length($hello));
33 ok(10, $uncomp eq $hello);
34 ok(11, $file->eof());
35 ok(12, $file->opened());
36 ok(13, $file->close());
37 ok(14, !$file->opened());
38
39 $file = IO::Zlib->new($name, "rb");
40 ok(15, $file->read($uncomp, 1024, length($uncomp)) == length($hello));
41 ok(16, $uncomp eq $hello . $hello);
42 $file->close();
43
44 unlink($name);
45
46 ok(17, !defined(IO::Zlib->new($name, "rb")));