11 # use Test::NoWarnings, if available
14 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
16 plan tests => 190 + $extra ;
18 use_ok('IO::Uncompress::AnyUncompress', qw($AnyUncompressError)) ;
25 my $CompressClass = identify();
26 my $UncompressClass = getInverse($CompressClass);
27 my $Error = getErrorRef($CompressClass);
28 my $UnError = getErrorRef($UncompressClass);
34 push @buffers, <<EOM ;
37 some more stuff on this line
41 push @buffers, <<EOM ;
45 push @buffers, <<EOM ;
56 foreach my $fb ( qw( file filehandle buffer ) )
59 foreach my $i (1 .. @buffers) {
61 title "Testing $CompressClass with $i streams to $fb";
63 my @buffs = @buffers[0..$i -1] ;
65 if ($CompressClass eq 'IO::Compress::Gzip') {
68 Comment => "this is a comment",
69 ExtraField => ["so" => "me extra"],
74 my $lex = new LexFile my $name ;
79 $output = \$compressed;
81 elsif ($fb eq 'filehandle')
83 $output = new IO::File ">$name" ;
90 my $x = new $CompressClass($output, AutoClose => 1, %headers);
91 isa_ok $x, $CompressClass, ' $x' ;
93 foreach my $buffer (@buffs) {
94 ok $x->write($buffer), " Write OK" ;
95 # this will add an extra "empty" stream
96 ok $x->newStream(), " newStream OK" ;
98 ok $x->close, " Close ok" ;
100 #hexDump($compressed) ;
102 foreach my $unc ($UncompressClass, 'IO::Uncompress::AnyUncompress') {
103 title " Testing $CompressClass with $unc and $i streams, from $fb";
105 if ($fb eq 'filehandle')
107 $cc = new IO::File "<$name" ;
109 my $gz = new $unc($cc,
116 isa_ok $gz, $UncompressClass, ' $gz' ;
119 1 while $gz->read($un) > 0 ;
120 #print "[[$un]]\n" while $gz->read($un) > 0 ;
121 ok ! $gz->error(), " ! error()"
122 or diag "Error is " . $gz->error() ;
123 ok $gz->eof(), " eof()";
124 ok $gz->close(), " close() ok"
125 or diag "errno $!\n" ;
127 is $gz->streamCount(), $i +1, " streamCount ok"
128 or diag "Stream count is " . $gz->streamCount();
129 ok $un eq join('', @buffs), " expected output" ;
138 # corrupt one of the streams - all previous should be ok
140 # need a way to skip to the start of the next stream.
141 # check that "tell" works ok