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
CommitLineData
8d0ec8cf
RGS
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
82d8f834 16print "1..17\n";
8d0ec8cf
RGS
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));
82d8f834
SP
33ok(10, $uncomp eq $hello);
34ok(11, $file->eof());
35ok(12, $file->opened());
36ok(13, $file->close());
37ok(14, !$file->opened());
8d0ec8cf 38
82d8f834
SP
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();
8d0ec8cf 43
82d8f834 44unlink($name);
8d0ec8cf 45
82d8f834 46ok(17, !defined(IO::Zlib->new($name, "rb")));