4 @INC = ("../lib", "lib/compress");
8 use lib qw(t t/compress);
18 plan skip_all => "Lengthy Tests Disabled\n" .
19 "set COMPRESS_ZLIB_RUN_ALL to run this test suite"
20 unless defined $ENV{COMPRESS_ZLIB_RUN_ALL} ;
22 # use Test::NoWarnings, if available
25 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
27 plan tests => 76 + $extra ;
30 use_ok('Compress::Zlib', 2) ;
31 use_ok('IO::Compress::Gzip', qw($GzipError)) ;
32 use_ok('IO::Uncompress::Gunzip', qw($GunzipError)) ;
33 use_ok('IO::Compress::Gzip::Constants');
41 for my $offset ( -1 .. 1 )
43 next if $wrap == 0 && $offset < 0 ;
45 title "Wrap $wrap, Offset $offset" ;
47 my $size = (GZIP_ISIZE_MAX * $wrap) + $offset ;
51 $expected_isize = $offset ;
53 elsif ($wrap == 1 && $offset <= 0) {
54 $expected_isize = GZIP_ISIZE_MAX + $offset ;
57 $expected_isize = GZIP_ISIZE_MAX + $offset - 1;
60 $expected_isize = $offset - 1;
69 my $inc = 1024 * 5000 ;
70 my $buff = 'x' x $inc ;
76 if ($max == 0 && $index == 0) {
77 $expected_crc = crc32('') ;
78 ok $gzip->close(), ' IO::Compress::Gzip::close ok X' ;
81 return length $compressed ;
84 return 0 if $index >= $max ;
86 while ( ! length $compressed )
92 #print "Write " . length($buff) . "\n" ;
93 #print "# LEN Compressed " . length($compressed) . "\n" ;
94 $expected_crc = crc32($buff, $expected_crc) ;
98 #print "Write $left\n" ;
99 $gzip->write('x' x $left) ;
100 #print "# LEN Compressed " . length($compressed) . "\n" ;
101 $expected_crc = crc32('x' x $left, $expected_crc) ;
102 ok $gzip->close(), ' IO::Compress::Gzip::close ok ' ;
107 my $len = length $compressed ;
108 $_[0] .= $compressed ;
110 #print "# LEN $len\n" if $len <=0 ;
116 my $gzip = new IO::Compress::Gzip \$compressed,
120 ok $gzip, " Created IO::Compress::Gzip object";
122 my $gunzip = new IO::Uncompress::Gunzip gzipClosure($gzip, $size),
123 -BlockSize => 1024 * 500 ,
127 ok $gunzip, " Created IO::Uncompress::Gunzip object";
129 my $inflate = *$gunzip->{Inflate} ;
130 my $deflate = *$gzip->{Deflate} ;
135 while (($status = $gunzip->read($uncompressed)) > 0) {
136 #print "# READ $status\n" ;
140 is $status, 0, ' IO::Uncompress::Gunzip::read returned 0'
141 or diag "error status is $status, error is $GunzipError" ;
143 ok $gunzip->close(), " IO::Uncompress::Gunzip Closed ok" ;
145 is $actual, $size, " Length of Gunzipped data is $size"
146 or diag "Expected $size, got $actual";
148 my $gunzip_hdr = $gunzip->getHeaderInfo();
150 is $gunzip_hdr->{ISIZE}, $expected_isize,
151 sprintf(" ISIZE is $expected_isize [0x%X]", $expected_isize);
152 is $gunzip_hdr->{CRC32}, $expected_crc,
153 sprintf(" CRC32 is $expected_crc [0x%X]", $expected_crc);