17 # use Test::NoWarnings, if available
20 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
22 plan tests => 575 + $extra ;
24 use_ok('Compress::Zlib', 2) ;
26 use_ok('IO::Compress::Gzip', qw($GzipError)) ;
27 use_ok('IO::Uncompress::Gunzip', qw($GunzipError)) ;
28 use_ok('IO::Uncompress::AnyInflate', qw($AnyInflateError)) ;
29 use_ok('IO::Uncompress::Inflate', qw($InflateError)) ;
30 use_ok('IO::Compress::Deflate', qw($DeflateError)) ;
31 use_ok('IO::Uncompress::RawInflate', qw($RawInflateError)) ;
32 use_ok('IO::Compress::RawDeflate', qw($RawDeflateError)) ;
37 push @buffers, <<EOM ;
40 some more stuff on this line
44 push @buffers, <<EOM ;
48 push @buffers, <<EOM ;
52 foreach my $CompressClass ('IO::Compress::Gzip',
53 'IO::Compress::Deflate',
54 'IO::Compress::RawDeflate',
57 my $UncompressClass = getInverse($CompressClass);
66 foreach my $fb ( qw( file filehandle buffer ) )
69 foreach my $i (1 .. @buffers) {
71 title "Testing $CompressClass with $i streams to $fb";
73 my @buffs = @buffers[0..$i -1] ;
75 if ($CompressClass eq 'IO::Compress::Gzip') {
78 Comment => "this is a comment",
79 ExtraField => "some extra",
84 my $name = "test.gz" ;
85 my $lex = new LexFile $name ;
90 $output = \$compressed;
92 elsif ($fb eq 'filehandle')
94 $output = new IO::File ">$name" ;
101 my $x = new $CompressClass($output, AutoClose => 1, %headers);
102 isa_ok $x, $CompressClass, ' $x' ;
104 foreach my $buffer (@buffs) {
105 ok $x->write($buffer), " Write OK" ;
106 # this will add an extra "empty" stream
107 ok $x->newStream(), " newStream OK" ;
109 ok $x->close, " Close ok" ;
111 #hexDump($compressed) ;
113 foreach my $unc ($UncompressClass, 'IO::Uncompress::AnyInflate') {
114 title " Testing $CompressClass with $unc and $i streams, from $fb";
116 if ($fb eq 'filehandle')
118 $cc = new IO::File "<$name" ;
120 my $gz = new $unc($cc,
126 isa_ok $gz, $unc, ' $gz' ;
129 1 while $gz->read($un) > 0 ;
130 #print "[[$un]]\n" while $gz->read($un) > 0 ;
131 ok ! $gz->error(), " ! error()"
132 or diag "Error is " . $gz->error() ;
133 ok $gz->eof(), " eof()";
134 ok $gz->close(), " close() ok"
135 or diag "errno $!\n" ;
137 is $gz->streamCount(), $i +1, " streamCount ok"
138 or diag "Stream count is " . $gz->streamCount();
139 ok $un eq join('', @buffs), " expected output" ;
147 # corrupt one of the streams - all previous should be ok
149 # need a way to skip to the start of the next stream.
150 # check that "tell" works ok