4 @INC = ("../lib", "lib/compress");
8 use lib qw(t t/compress);
18 # use Test::NoWarnings, if available
21 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
23 plan tests => 288 + $extra ;
25 use_ok('Compress::Raw::Zlib', 2) ;
34 my $len = length $hello ;
36 # Check zlib_version and ZLIB_VERSION are the same.
38 skip "TEST_SKIP_VERSION_CHECK is set", 1
39 if $ENV{TEST_SKIP_VERSION_CHECK};
40 is Compress::Raw::Zlib::zlib_version, ZLIB_VERSION,
41 "ZLIB_VERSION matches Compress::Raw::Zlib::zlib_version" ;
48 print "#\n#Length $i\n#\n";
50 my $hello = "I am a HAL 9000 computer" x 2001;
55 while $tmp =~ s/^(.{$i})//;
56 push @hello, $tmp if length $tmp ;
58 my ($err, $x, $X, $status);
60 ok( ($x, $err) = new Compress::Raw::Zlib::Deflate (-AppendOutput => 1));
62 cmp_ok $err, '==', Z_OK, " status is Z_OK" ;
64 ok ! defined $x->msg(), " no msg" ;
65 is $x->total_in(), 0, " total_in == 0" ;
66 is $x->total_out(), 0, " total_out == 0" ;
71 $status = $x->deflate($_, $out) ;
72 last unless $status == Z_OK ;
75 cmp_ok $status, '==', Z_OK, " status is Z_OK" ;
77 cmp_ok $x->flush($out), '==', Z_OK, " flush returned Z_OK" ;
79 ok ! defined $x->msg(), " no msg" ;
80 is $x->total_in(), length $hello, " length total_in" ;
81 is $x->total_out(), length $out, " length total_out" ;
85 push @Answer, $1 while $tmp =~ s/^(.{$i})//;
86 push @Answer, $tmp if length $tmp ;
89 ok(($k, $err) = new Compress::Raw::Zlib::Inflate( -AppendOutput => 1));
91 cmp_ok $err, '==', Z_OK, " status is Z_OK" ;
93 ok ! defined $k->msg(), " no msg" ;
94 is $k->total_in(), 0, " total_in == 0" ;
95 is $k->total_out(), 0, " total_out == 0" ;
101 $status = $k->inflate($_, $GOT) ;
102 last if $status == Z_STREAM_END or $status != Z_OK ;
106 cmp_ok $status, '==', Z_STREAM_END, " status is Z_STREAM_END" ;
107 is $GOT, $hello, " got expected output" ;
108 ok ! defined $k->msg(), " no msg" ;
109 is $k->total_in(), length $out, " length total_in ok" ;
110 is $k->total_out(), length $hello, " length total_out ok" ;