4 @INC = ("../lib", "lib");
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 $lex = new LexFile my $name ;
89 $output = \$compressed;
91 elsif ($fb eq 'filehandle')
93 $output = new IO::File ">$name" ;
100 my $x = new $CompressClass($output, AutoClose => 1, %headers);
101 isa_ok $x, $CompressClass, ' $x' ;
103 foreach my $buffer (@buffs) {
104 ok $x->write($buffer), " Write OK" ;
105 # this will add an extra "empty" stream
106 ok $x->newStream(), " newStream OK" ;
108 ok $x->close, " Close ok" ;
110 #hexDump($compressed) ;
112 foreach my $unc ($UncompressClass, 'IO::Uncompress::AnyInflate') {
113 title " Testing $CompressClass with $unc and $i streams, from $fb";
115 if ($fb eq 'filehandle')
117 $cc = new IO::File "<$name" ;
119 my $gz = new $unc($cc,
125 isa_ok $gz, $unc, ' $gz' ;
128 1 while $gz->read($un) > 0 ;
129 #print "[[$un]]\n" while $gz->read($un) > 0 ;
130 ok ! $gz->error(), " ! error()"
131 or diag "Error is " . $gz->error() ;
132 ok $gz->eof(), " eof()";
133 ok $gz->close(), " close() ok"
134 or diag "errno $!\n" ;
136 is $gz->streamCount(), $i +1, " streamCount ok"
137 or diag "Stream count is " . $gz->streamCount();
138 ok $un eq join('', @buffs), " expected output" ;
146 # corrupt one of the streams - all previous should be ok
148 # need a way to skip to the start of the next stream.
149 # check that "tell" works ok