11 # use Test::NoWarnings, if available
14 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
16 plan tests => 575 + $extra ;
18 use_ok('Compress::Zlib', 2) ;
20 use_ok('IO::Compress::Gzip', qw($GzipError)) ;
21 use_ok('IO::Uncompress::Gunzip', qw($GunzipError)) ;
22 use_ok('IO::Uncompress::AnyInflate', qw($AnyInflateError)) ;
23 use_ok('IO::Uncompress::Inflate', qw($InflateError)) ;
24 use_ok('IO::Compress::Deflate', qw($DeflateError)) ;
25 use_ok('IO::Uncompress::RawInflate', qw($RawInflateError)) ;
26 use_ok('IO::Compress::RawDeflate', qw($RawDeflateError)) ;
31 push @buffers, <<EOM ;
34 some more stuff on this line
38 push @buffers, <<EOM ;
42 push @buffers, <<EOM ;
46 foreach my $CompressClass ('IO::Compress::Gzip',
47 'IO::Compress::Deflate',
48 'IO::Compress::RawDeflate',
51 my $UncompressClass = getInverse($CompressClass);
60 foreach my $fb ( qw( file filehandle buffer ) )
63 foreach my $i (1 .. @buffers) {
65 title "Testing $CompressClass with $i streams to $fb";
67 my @buffs = @buffers[0..$i -1] ;
69 if ($CompressClass eq 'IO::Compress::Gzip') {
72 Comment => "this is a comment",
73 ExtraField => "some extra",
78 my $name = "test.gz" ;
79 my $lex = new LexFile $name ;
84 $output = \$compressed;
86 elsif ($fb eq 'filehandle')
88 $output = new IO::File ">$name" ;
95 my $x = new $CompressClass($output, AutoClose => 1, %headers);
96 isa_ok $x, $CompressClass, ' $x' ;
98 foreach my $buffer (@buffs) {
99 ok $x->write($buffer), " Write OK" ;
100 # this will add an extra "empty" stream
101 ok $x->newStream(), " newStream OK" ;
103 ok $x->close, " Close ok" ;
105 #hexDump($compressed) ;
107 foreach my $unc ($UncompressClass, 'IO::Uncompress::AnyInflate') {
108 title " Testing $CompressClass with $unc and $i streams, from $fb";
110 if ($fb eq 'filehandle')
112 $cc = new IO::File "<$name" ;
114 my $gz = new $unc($cc,
120 isa_ok $gz, $unc, ' $gz' ;
123 1 while $gz->read($un) > 0 ;
124 #print "[[$un]]\n" while $gz->read($un) > 0 ;
125 ok ! $gz->error(), " ! error()"
126 or diag "Error is " . $gz->error() ;
127 ok $gz->eof(), " eof()";
128 ok $gz->close(), " close() ok"
129 or diag "errno $!\n" ;
131 is $gz->streamCount(), $i +1, " streamCount ok"
132 or diag "Stream count is " . $gz->streamCount();
133 ok $un eq join('', @buffs), " expected output" ;
141 # corrupt one of the streams - all previous should be ok
143 # need a way to skip to the start of the next stream.
144 # check that "tell" works ok