Commit | Line | Data |
---|---|---|
8d0ec8cf RGS |
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 | ||
82d8f834 | 16 | print "1..17\n"; |
8d0ec8cf RGS |
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)); | |
82d8f834 SP |
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()); | |
8d0ec8cf | 38 | |
82d8f834 SP |
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(); | |
8d0ec8cf | 43 | |
82d8f834 | 44 | unlink($name); |
8d0ec8cf | 45 | |
82d8f834 | 46 | ok(17, !defined(IO::Zlib->new($name, "rb"))); |