diff options
author | Paul Marquess <paul.marquess@btinternet.com> | 2006-06-28 15:22:46 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-06-28 14:37:03 +0000 |
commit | 6ecef415672954d64bc0df6bdb809cebe10f89d4 (patch) | |
tree | a6a0c4b65df7ccf2dc0167b1b985c7745ad40aee /t | |
parent | 84b74420ec29626056f47c562bc5572638f87383 (diff) | |
download | perl-6ecef415672954d64bc0df6bdb809cebe10f89d4.tar.gz |
Update for IO::Uncompress::Base
From: "Paul Marquess" <paul.marquess@ntlworld.com>
Message-ID: <001701c69ab5$f4d5d3d0$2405140a@myopwv.com>
p4raw-id: //depot/perl@28445
Diffstat (limited to 't')
-rw-r--r-- | t/lib/compress/CompTestUtils.pm | 13 | ||||
-rw-r--r-- | t/lib/compress/any.pl | 50 | ||||
-rw-r--r-- | t/lib/compress/anyunc.pl | 44 | ||||
-rw-r--r-- | t/lib/compress/multi.pl | 8 | ||||
-rw-r--r-- | t/lib/compress/oneshot.pl | 62 |
5 files changed, 127 insertions, 50 deletions
diff --git a/t/lib/compress/CompTestUtils.pm b/t/lib/compress/CompTestUtils.pm index d86aba5257..7e583a0213 100644 --- a/t/lib/compress/CompTestUtils.pm +++ b/t/lib/compress/CompTestUtils.pm @@ -422,7 +422,11 @@ sub anyUncompress } my $out = ''; - my $o = new IO::Uncompress::AnyUncompress \$data, -Append => 1, Transparent => 0, @opts + my $o = new IO::Uncompress::AnyUncompress \$data, + Append => 1, + Transparent => 0, + RawInflate => 1, + @opts or croak "Cannot open buffer/file: $AnyUncompressError" ; 1 while $o->read($out) > 0 ; @@ -478,7 +482,12 @@ sub getHeaders } my $out = ''; - my $o = new IO::Uncompress::AnyUncompress \$data, MultiStream => 1, -Append => 1, Transparent => 0, @opts + my $o = new IO::Uncompress::AnyUncompress \$data, + MultiStream => 1, + Append => 1, + Transparent => 0, + RawInflate => 1, + @opts or croak "Cannot open buffer/file: $AnyUncompressError" ; 1 while $o->read($out) > 0 ; diff --git a/t/lib/compress/any.pl b/t/lib/compress/any.pl index 74f49254e3..d95766b0a9 100644 --- a/t/lib/compress/any.pl +++ b/t/lib/compress/any.pl @@ -14,7 +14,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 36 + $extra ; + plan tests => 48 + $extra ; } @@ -35,7 +35,7 @@ sub run for my $file ( 0, 1 ) { title "$AnyClass(Transparent => $trans, File=>$file) with $CompressClass" ; - my $string = "some text"; + my $string = "some text" x 100 ; my $buffer ; my $x = new $CompressClass(\$buffer) ; @@ -54,19 +54,43 @@ sub run $input = \$buffer; } - my $unc = new $AnyConstruct $input, Transparent => $trans ; + { + my $unc = new $AnyConstruct $input, Transparent => $trans, + RawInflate => 1, + Append => 1 ; - ok $unc, " Created $AnyClass object" - or print "# $$AnyError\n"; - my $uncomp ; - ok $unc->read($uncomp) > 0 - or print "# $$AnyError\n"; - my $y; - is $unc->read($y, 1), 0, " at eof" ; - ok $unc->eof(), " at eof" ; - #ok $unc->type eq $Type; + ok $unc, " Created $AnyClass object" + or print "# $$AnyError\n"; + my $uncomp ; + 1 while $unc->read($uncomp) > 0 ; + #ok $unc->read($uncomp) > 0 + # or print "# $$AnyError\n"; + my $y; + is $unc->read($y, 1), 0, " at eof" ; + ok $unc->eof(), " at eof" ; + #ok $unc->type eq $Type; - is $uncomp, $string, " expected output" ; + is $uncomp, $string, " expected output" ; + } + + { + my $unc = new $AnyConstruct $input, Transparent => $trans, + RawInflate => 1, + Append => 1 ; + + ok $unc, " Created $AnyClass object" + or print "# $$AnyError\n"; + my $uncomp ; + 1 while $unc->read($uncomp, 100) > 0 ; + #ok $unc->read($uncomp) > 0 + # or print "# $$AnyError\n"; + my $y; + is $unc->read($y, 1), 0, " at eof" ; + ok $unc->eof(), " at eof" ; + #ok $unc->type eq $Type; + + is $uncomp, $string, " expected output" ; + } } } } diff --git a/t/lib/compress/anyunc.pl b/t/lib/compress/anyunc.pl index d79ff22bb5..2860e2571c 100644 --- a/t/lib/compress/anyunc.pl +++ b/t/lib/compress/anyunc.pl @@ -34,7 +34,7 @@ sub run for my $file ( 0, 1 ) { title "$AnyClass(Transparent => $trans, File=>$file) with $CompressClass" ; - my $string = "some text"; + my $string = "some text" x 100 ; my $buffer ; my $x = new $CompressClass(\$buffer) ; @@ -53,19 +53,39 @@ sub run $input = \$buffer; } - my $unc = new $AnyConstruct $input, Transparent => $trans ; + { + my $unc = new $AnyConstruct $input, Transparent => $trans + Append => 1 ; - ok $unc, " Created $AnyClass object" - or print "# $$AnyError\n"; - my $uncomp ; - ok $unc->read($uncomp) > 0 - or print "# $$AnyError\n"; - my $y; - is $unc->read($y, 1), 0, " at eof" ; - ok $unc->eof(), " at eof" ; - #ok $unc->type eq $Type; + ok $unc, " Created $AnyClass object" + or print "# $$AnyError\n"; + my $uncomp ; + 1 while $unc->read($uncomp) > 0 ; + #ok $unc->read($uncomp) > 0 + # or print "# $$AnyError\n"; + my $y; + is $unc->read($y, 1), 0, " at eof" ; + ok $unc->eof(), " at eof" ; + #ok $unc->type eq $Type; - is $uncomp, $string, " expected output" ; + is $uncomp, $string, " expected output" ; + } + + { + my $unc = new $AnyConstruct $input, Transparent => $trans, + Append =>1 ; + + ok $unc, " Created $AnyClass object" + or print "# $$AnyError\n"; + my $uncomp ; + 1 while $unc->read($uncomp, 10) > 0 ; + my $y; + is $unc->read($y, 1), 0, " at eof" ; + ok $unc->eof(), " at eof" ; + #ok $unc->type eq $Type; + + is $uncomp, $string, " expected output" ; + } } } } diff --git a/t/lib/compress/multi.pl b/t/lib/compress/multi.pl index 259447c669..c6aaa7d490 100644 --- a/t/lib/compress/multi.pl +++ b/t/lib/compress/multi.pl @@ -107,7 +107,11 @@ EOM { $cc = new IO::File "<$name" ; } + my @opts = $unc ne $UncompressClass + ? (RawInflate => 1) + : (); my $gz = new $unc($cc, + @opts, Strict => 1, AutoClose => 1, Append => 1, @@ -138,7 +142,11 @@ EOM { $cc = new IO::File "<$name" ; } + my @opts = $unc ne $UncompressClass + ? (RawInflate => 1) + : (); my $gz = new $unc($cc, + @opts, Strict => 1, AutoClose => 1, Append => 1, diff --git a/t/lib/compress/oneshot.pl b/t/lib/compress/oneshot.pl index 3ef6bb2186..50425df4c6 100644 --- a/t/lib/compress/oneshot.pl +++ b/t/lib/compress/oneshot.pl @@ -229,6 +229,10 @@ sub run my $TopTypeInverse = getInverse($bit); my $FuncInverse = getTopFuncRef($TopTypeInverse); + my @opts = (); + @opts = (RawInflate => 1) + if $CompressClass eq 'IO::Compress::RawInflate'; + for my $append ( 1, 0 ) { my $already = ''; @@ -885,6 +889,10 @@ sub run my $incumbent = "incumbent data" ; + my @opts = (); + @opts = (RawInflate => 1) + if $bit eq 'IO::Uncompress::AnyUncompress'; + for my $append (0, 1) { my $expected = $buffer ; @@ -895,7 +903,7 @@ sub run my $output ; $output = $incumbent if $append ; - ok &$Func(\$comp, \$output, Append => $append), ' Uncompressed ok' ; + ok &$Func(\$comp, \$output, Append => $append, @opts), ' Uncompressed ok' ; is $keep_comp, $comp, " Input buffer not changed" ; is $output, $expected, " Uncompressed matches original"; @@ -906,7 +914,7 @@ sub run my @output = ('first'); #$output = $incumbent if $append ; - ok &$Func(\$comp, \@output, Append => $append), ' Uncompressed ok' ; + ok &$Func(\$comp, \@output, Append => $append, @opts), ' Uncompressed ok' ; is $keep_comp, $comp, " Input buffer not changed" ; is $output[0], 'first', " Uncompressed matches original"; @@ -924,7 +932,7 @@ sub run else { ok ! -e $out_file, " Output file does not exist" } - ok &$Func(\$comp, $out_file, Append => $append), ' Uncompressed ok' ; + ok &$Func(\$comp, $out_file, Append => $append, @opts), ' Uncompressed ok' ; ok -e $out_file, " Created output file"; my $content = readFile($out_file) ; @@ -948,7 +956,7 @@ sub run } isa_ok $of, 'IO::File', ' $of' ; - ok &$Func(\$comp, $of, Append => $append, AutoClose => 1), ' Uncompressed ok' ; + ok &$Func(\$comp, $of, Append => $append, AutoClose => 1, @opts), ' Uncompressed ok' ; ok -e $out_file, " Created output file"; my $content = readFile($out_file) ; @@ -968,7 +976,7 @@ sub run writeFile($in_file, $comp); - ok &$Func($in_file, $out_file, Append => $append), ' Uncompressed ok' ; + ok &$Func($in_file, $out_file, Append => $append, @opts), ' Uncompressed ok' ; ok -e $out_file, " Created output file"; my $content = readFile($out_file) ; @@ -994,7 +1002,7 @@ sub run writeFile($in_file, $comp); - ok &$Func($in_file, $out, Append => $append, AutoClose => 1), ' Uncompressed ok' ; + ok &$Func($in_file, $out, Append => $append, AutoClose => 1, @opts), ' Uncompressed ok' ; ok -e $out_file, " Created output file"; my $content = readFile($out_file) ; @@ -1012,7 +1020,7 @@ sub run my $output ; $output = $incumbent if $append ; - ok &$Func($in_file, \$output, Append => $append), ' Uncompressed ok' ; + ok &$Func($in_file, \$output, Append => $append, @opts), ' Uncompressed ok' ; is $keep_comp, $comp, " Input buffer not changed" ; is $output, $expected, " Uncompressed matches original"; @@ -1030,7 +1038,7 @@ sub run writeFile($in_file, $comp); my $in = new IO::File "<$in_file" ; - ok &$Func($in, $out_file, Append => $append), ' Uncompressed ok' ; + ok &$Func($in, $out_file, Append => $append, @opts), ' Uncompressed ok' ; ok -e $out_file, " Created output file"; my $content = readFile($out_file) ; @@ -1057,7 +1065,7 @@ sub run writeFile($in_file, $comp); my $in = new IO::File "<$in_file" ; - ok &$Func($in, $out, Append => $append, AutoClose => 1), ' Uncompressed ok' ; + ok &$Func($in, $out, Append => $append, AutoClose => 1, @opts), ' Uncompressed ok' ; ok -e $out_file, " Created output file"; my $content = readFile($out_file) ; @@ -1076,7 +1084,7 @@ sub run my $output ; $output = $incumbent if $append ; - ok &$Func($in, \$output, Append => $append), ' Uncompressed ok' ; + ok &$Func($in, \$output, Append => $append, @opts), ' Uncompressed ok' ; is $keep_comp, $comp, " Input buffer not changed" ; is $output, $expected, " Uncompressed matches original"; @@ -1095,7 +1103,7 @@ sub run my $output ; $output = $incumbent if $append ; - ok &$Func('-', \$output, Append => $append), ' Uncompressed ok' + ok &$Func('-', \$output, Append => $append, @opts), ' Uncompressed ok' or diag $$Error ; open(STDIN, "<&SAVEIN"); @@ -1117,7 +1125,7 @@ sub run writeFile($in_file, $comp . $appended . $comp . $appended) ; my $in = new IO::File "<$in_file" ; - ok &$Func($in, \$out, Transparent => 0, InputLength => length $comp), ' Uncompressed ok' ; + ok &$Func($in, \$out, Transparent => 0, InputLength => length $comp, @opts), ' Uncompressed ok' ; is $out, $expected, " Uncompressed matches original"; @@ -1126,7 +1134,7 @@ sub run is $buff, $appended, " Appended data ok"; $out = ''; - ok &$Func($in, \$out, Transparent => 0, InputLength => length $comp), ' Uncompressed ok' ; + ok &$Func($in, \$out, Transparent => 0, InputLength => length $comp, @opts), ' Uncompressed ok' ; is $out, $expected, " Uncompressed matches original"; @@ -1151,7 +1159,7 @@ sub run my $output ; - ok &$Func($stdin, \$output, Transparent => 0, InputLength => length $comp), ' Uncompressed ok' + ok &$Func($stdin, \$output, Transparent => 0, InputLength => length $comp, @opts), ' Uncompressed ok' or diag $$Error ; my $buff ; @@ -1182,6 +1190,10 @@ sub run my $comp = compressBuffer(getTopFuncName($UncompressClass), $buffer) ; my $keep_comp = $comp; + my @opts = (); + @opts = (RawInflate => 1) + if $bit eq 'IO::Uncompress::AnyUncompress'; + my $incumbent = "incumbent data" ; my $lex = new LexFile(my $file1, my $file2) ; @@ -1203,7 +1215,7 @@ sub run title "$TopType - From ArrayRef to Buffer" ; my $output ; - ok &$Func(\@input, \$output, AutoClose => 0), ' UnCompressed ok' ; + ok &$Func(\@input, \$output, AutoClose => 0, @opts), ' UnCompressed ok' ; is $output, join('', @expected) } @@ -1214,7 +1226,7 @@ sub run my $lex = new LexFile my $output; $of->open("<$file1") ; - ok &$Func(\@input, $output, AutoClose => 0), ' UnCompressed ok' ; + ok &$Func(\@input, $output, AutoClose => 0, @opts), ' UnCompressed ok' ; is readFile($output), join('', @expected) } @@ -1226,7 +1238,7 @@ sub run my $fh = new IO::File ">$output" ; $of->open("<$file1") ; - ok &$Func(\@input, $fh, AutoClose => 0), ' UnCompressed ok' ; + ok &$Func(\@input, $fh, AutoClose => 0, @opts), ' UnCompressed ok' ; $fh->close; is readFile($output), join('', @expected) @@ -1237,7 +1249,7 @@ sub run my @output = (\'first') ; $of->open("<$file1") ; - ok &$Func(\@input, \@output, AutoClose => 0), ' UnCompressed ok' ; + ok &$Func(\@input, \@output, AutoClose => 0, @opts), ' UnCompressed ok' ; is_deeply \@input, \@keep, " Input array not changed" ; is_deeply [map { defined $$_ ? $$_ : "" } @output], @@ -1264,6 +1276,10 @@ sub run mkdir $tmpDir1, 0777; mkdir $tmpDir2, 0777; + my @opts = (); + @opts = (RawInflate => 1) + if $bit eq 'IO::Uncompress::AnyUncompress'; + ok -d $tmpDir1, " Temp Directory $tmpDir1 exists"; #ok ! -d $tmpDir2, " Temp Directory $tmpDir2 does not exist"; @@ -1276,7 +1292,7 @@ sub run { title "$TopType - From FileGlob to FileGlob" ; - ok &$Func("<$tmpDir1/a*.tmp>" => "<$tmpDir2/a#1.tmp>"), ' UnCompressed ok' + ok &$Func("<$tmpDir1/a*.tmp>" => "<$tmpDir2/a#1.tmp>", @opts), ' UnCompressed ok' or diag $$Error ; my @copy = @expected; @@ -1292,7 +1308,7 @@ sub run title "$TopType - From FileGlob to Arrayref" ; my @output = (\'first'); - ok &$Func("<$tmpDir1/a*.tmp>" => \@output), ' UnCompressed ok' + ok &$Func("<$tmpDir1/a*.tmp>" => \@output, @opts), ' UnCompressed ok' or diag $$Error ; my @copy = ('first', @expected); @@ -1308,7 +1324,7 @@ sub run title "$TopType - From FileGlob to Buffer" ; my $output ; - ok &$Func("<$tmpDir1/a*.tmp>" => \$output), ' UnCompressed ok' + ok &$Func("<$tmpDir1/a*.tmp>" => \$output, @opts), ' UnCompressed ok' or diag $$Error ; is $output, join('', @expected), " got expected uncompressed data"; @@ -1319,7 +1335,7 @@ sub run my $lex = new LexFile my $output ; ok ! -e $output, " $output does not exist" ; - ok &$Func("<$tmpDir1/a*.tmp>" => $output), ' UnCompressed ok' + ok &$Func("<$tmpDir1/a*.tmp>" => $output, @opts), ' UnCompressed ok' or diag $$Error ; ok -e $output, " $output does exist" ; @@ -1332,7 +1348,7 @@ sub run my $output = 'abc' ; my $lex = new LexFile $output ; my $fh = new IO::File ">$output" ; - ok &$Func("<$tmpDir1/a*.tmp>" => $fh, AutoClose => 1), ' UnCompressed ok' + ok &$Func("<$tmpDir1/a*.tmp>" => $fh, AutoClose => 1, @opts), ' UnCompressed ok' or diag $$Error ; ok -e $output, " $output does exist" ; |