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 => 98 + $extra ;
25 use_ok('Compress::Raw::Zlib', 2) ;
30 my $hello = "I am a HAL 9000 computer" x 2001;
33 my ($err, $x, $X, $status);
35 ok( ($x, $err) = new Compress::Raw::Zlib::Deflate (-AppendOutput => 1));
37 cmp_ok $err, '==', Z_OK, " status is Z_OK" ;
40 $status = $x->deflate($tmp, $out) ;
41 cmp_ok $status, '==', Z_OK, " status is Z_OK" ;
43 cmp_ok $x->flush($out), '==', Z_OK, " flush returned Z_OK" ;
46 sub getOut { my $x = ''; return \$x }
48 for my $bufsize (1, 2, 3, 13, 4096, 1024*10)
50 print "#\n#Bufsize $bufsize\n#\n";
54 ok(($k, $err) = new Compress::Raw::Zlib::Inflate( AppendOutput => 1,
59 cmp_ok $err, '==', Z_OK, " status is Z_OK" ;
61 ok ! defined $k->msg(), " no msg" ;
62 is $k->total_in(), 0, " total_in == 0" ;
63 is $k->total_out(), 0, " total_out == 0" ;
71 my $prev = length $GOT;
72 $status = $k->inflate($tmp, $GOT) ;
73 last if $status == Z_STREAM_END || $status == Z_DATA_ERROR || $status == Z_STREAM_ERROR ;
74 $deltaOK = 0 if length($GOT) - $prev > $bufsize;
77 ok $deltaOK, " Output Delta never > $bufsize";
78 cmp_ok $looped, '>=', 1, " looped $looped";
79 is length($tmp), 0, " length of input buffer is zero";
81 cmp_ok $status, '==', Z_STREAM_END, " status is Z_STREAM_END" ;
82 is $$GOT, $hello, " got expected output" ;
83 ok ! defined $k->msg(), " no msg" ;
84 is $k->total_in(), length $out, " length total_in ok" ;
85 is $k->total_out(), length $hello, " length total_out ok " . $k->total_out() ;
94 1 while $obj->inflate($input, $data) != Z_STREAM_END ;
99 title "regression test";
101 my ($err, $x, $X, $status);
103 ok( ($x, $err) = new Compress::Raw::Zlib::Deflate (-AppendOutput => 1));
105 cmp_ok $err, '==', Z_OK, " status is Z_OK" ;
107 my $line1 = ("abcdefghijklmnopq" x 1000) . "\n" ;
108 my $line2 = "second line\n" ;
109 my $text = $line1 . $line2 ;
113 $status = $x->deflate($tmp, $out) ;
114 cmp_ok $status, '==', Z_OK, " status is Z_OK" ;
116 cmp_ok $x->flush($out), '==', Z_OK, " flush returned Z_OK" ;
119 ok(($k, $err) = new Compress::Raw::Zlib::Inflate( AppendOutput => 1,
124 my $c = getit($k, $out);