1b39c5158Smillert 2b39c5158Smillertuse lib 't'; 3b39c5158Smillert 4b39c5158Smillertuse strict; 5b39c5158Smillertuse warnings; 6b39c5158Smillertuse bytes; 7b39c5158Smillert 8b39c5158Smillertuse Test::More ; 9b39c5158Smillertuse CompTestUtils; 10b39c5158Smillert 11b39c5158SmillertBEGIN { 12b39c5158Smillert # use Test::NoWarnings, if available 13b39c5158Smillert my $extra = 0 ; 14b39c5158Smillert $extra = 1 15b39c5158Smillert if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; 16b39c5158Smillert 17b39c5158Smillert plan tests => 36 + $extra ; 18b39c5158Smillert} 19b39c5158Smillert 20b39c5158Smillertsub run 21b39c5158Smillert{ 22b39c5158Smillert my $CompressClass = identify(); 23b39c5158Smillert my $AnyClass = getClass(); 24b39c5158Smillert my $UncompressClass = getInverse($CompressClass); 25b39c5158Smillert my $Error = getErrorRef($CompressClass); 26b39c5158Smillert my $UnError = getErrorRef($UncompressClass); 27b39c5158Smillert 28b39c5158Smillert my $AnyConstruct = "IO::Uncompress::${AnyClass}" ; 29b39c5158Smillert no strict refs; 30b39c5158Smillert my $AnyError = \${ "IO::Uncompress::${AnyClass}::${AnyClass}Error" }; 31b39c5158Smillert 32b39c5158Smillert for my $trans ( 0, 1 ) 33b39c5158Smillert { 34b39c5158Smillert for my $file ( 0, 1 ) 35b39c5158Smillert { 36b39c5158Smillert title "$AnyClass(Transparent => $trans, File=>$file) with $CompressClass" ; 37b39c5158Smillert my $string = "some text" x 100 ; 38b39c5158Smillert 39b39c5158Smillert my $buffer ; 40*256a93a4Safresh1 my $x = $CompressClass->can('new')->( $CompressClass, \$buffer) ; 41b39c5158Smillert ok $x, " create $CompressClass object" ; 42b39c5158Smillert ok $x->write($string), " write to object" ; 43b39c5158Smillert ok $x->close, " close ok" ; 44b39c5158Smillert 45*256a93a4Safresh1 my $lex = LexFile->new( my $output ); 46b39c5158Smillert my $input ; 47b39c5158Smillert 48b39c5158Smillert if ($file) { 49b39c5158Smillert writeFile($output, $buffer); 50b39c5158Smillert $input = $output; 51b39c5158Smillert } 52b39c5158Smillert else { 53b39c5158Smillert $input = \$buffer; 54b39c5158Smillert } 55b39c5158Smillert 56b39c5158Smillert { 57*256a93a4Safresh1 my $unc = $AnyConstruct->can('new')->( $AnyConstruct, $input, Transparent => $trans 58*256a93a4Safresh1 Append => 1 ); 59b39c5158Smillert 60b39c5158Smillert ok $unc, " Created $AnyClass object" 61b39c5158Smillert or print "# $$AnyError\n"; 62b39c5158Smillert my $uncomp ; 63b39c5158Smillert 1 while $unc->read($uncomp) > 0 ; 64b39c5158Smillert #ok $unc->read($uncomp) > 0 65b39c5158Smillert # or print "# $$AnyError\n"; 66b39c5158Smillert my $y; 67b39c5158Smillert is $unc->read($y, 1), 0, " at eof" ; 68b39c5158Smillert ok $unc->eof(), " at eof" ; 69b39c5158Smillert #ok $unc->type eq $Type; 70b39c5158Smillert 71b39c5158Smillert is $uncomp, $string, " expected output" ; 72b39c5158Smillert } 73b39c5158Smillert 74b39c5158Smillert { 75*256a93a4Safresh1 my $unc = $AnyConstruct->can('new')->( $AnyConstruct, $input, Transparent => $trans, 76*256a93a4Safresh1 Append =>1 ); 77b39c5158Smillert 78b39c5158Smillert ok $unc, " Created $AnyClass object" 79b39c5158Smillert or print "# $$AnyError\n"; 80b39c5158Smillert my $uncomp ; 81b39c5158Smillert 1 while $unc->read($uncomp, 10) > 0 ; 82b39c5158Smillert my $y; 83b39c5158Smillert is $unc->read($y, 1), 0, " at eof" ; 84b39c5158Smillert ok $unc->eof(), " at eof" ; 85b39c5158Smillert #ok $unc->type eq $Type; 86b39c5158Smillert 87b39c5158Smillert is $uncomp, $string, " expected output" ; 88b39c5158Smillert } 89b39c5158Smillert } 90b39c5158Smillert } 91b39c5158Smillert} 92b39c5158Smillert 93b39c5158Smillert1; 94