12 plan skip_all => "Lengthy Tests Disabled\n" .
13 "set COMPRESS_ZLIB_RUN_ALL to run this test suite"
14 unless defined $ENV{COMPRESS_ZLIB_RUN_ALL} ;
16 # use Test::NoWarnings, if available
19 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
21 plan tests => 76 + $extra ;
24 use_ok('Compress::Zlib', 2) ;
25 use_ok('IO::Compress::Gzip', qw($GzipError)) ;
26 use_ok('IO::Uncompress::Gunzip', qw($GunzipError)) ;
27 use_ok('Compress::Gzip::Constants');
35 for my $offset ( -1 .. 1 )
37 next if $wrap == 0 && $offset < 0 ;
39 title "Wrap $wrap, Offset $offset" ;
41 my $size = (GZIP_ISIZE_MAX * $wrap) + $offset ;
45 $expected_isize = $offset ;
47 elsif ($wrap == 1 && $offset <= 0) {
48 $expected_isize = GZIP_ISIZE_MAX + $offset ;
51 $expected_isize = GZIP_ISIZE_MAX + $offset - 1;
54 $expected_isize = $offset - 1;
63 my $inc = 1024 * 5000 ;
64 my $buff = 'x' x $inc ;
70 if ($max == 0 && $index == 0) {
71 $expected_crc = crc32('') ;
72 ok $gzip->close(), ' IO::Compress::Gzip::close ok X' ;
75 return length $compressed ;
78 return 0 if $index >= $max ;
80 while ( ! length $compressed )
86 #print "Write " . length($buff) . "\n" ;
87 #print "# LEN Compressed " . length($compressed) . "\n" ;
88 $expected_crc = crc32($buff, $expected_crc) ;
92 #print "Write $left\n" ;
93 $gzip->write('x' x $left) ;
94 #print "# LEN Compressed " . length($compressed) . "\n" ;
95 $expected_crc = crc32('x' x $left, $expected_crc) ;
96 ok $gzip->close(), ' IO::Compress::Gzip::close ok ' ;
101 my $len = length $compressed ;
102 $_[0] .= $compressed ;
104 #print "# LEN $len\n" if $len <=0 ;
110 my $gzip = new IO::Compress::Gzip \$compressed,
114 ok $gzip, " Created IO::Compress::Gzip object";
116 my $gunzip = new IO::Uncompress::Gunzip gzipClosure($gzip, $size),
117 -BlockSize => 1024 * 500 ,
121 ok $gunzip, " Created IO::Uncompress::Gunzip object";
123 my $inflate = *$gunzip->{Inflate} ;
124 my $deflate = *$gzip->{Deflate} ;
129 while (($status = $gunzip->read($uncompressed)) > 0) {
130 #print "# READ $status\n" ;
134 is $status, 0, ' IO::Uncompress::Gunzip::read returned 0'
135 or diag "error status is $status, error is $GunzipError" ;
137 ok $gunzip->close(), " IO::Uncompress::Gunzip Closed ok" ;
139 is $actual, $size, " Length of Gunzipped data is $size"
140 or diag "Expected $size, got $actual";
142 my $gunzip_hdr = $gunzip->getHeaderInfo();
144 is $gunzip_hdr->{ISIZE}, $expected_isize,
145 sprintf(" ISIZE is $expected_isize [0x%X]", $expected_isize);
146 is $gunzip_hdr->{CRC32}, $expected_crc,
147 sprintf(" CRC32 is $expected_crc [0x%X]", $expected_crc);