$extra = 1
if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
- plan tests => 944 + $extra ;
+ plan tests => 970 + $extra ;
use_ok('IO::Uncompress::AnyUncompress', qw(anyuncompress $AnyUncompressError)) ;
my $TopFuncName = getTopFuncName($CompressClass);
+ my @MultiValues = getMultiValues($CompressClass);
foreach my $bit ($CompressClass, $UncompressClass,
'IO::Uncompress::AnyUncompress',
like $@, mkErr("^$TopType: unknown key value\\(s\\) Fred"), ' Illegal Parameters';
eval { $a = $Func->() ;} ;
- like $@, mkErr("^$TopType: expected at least 1 parameters"), ' No Parameters';
+ like $@, "/^$TopType: expected at least 1 parameters/", ' No Parameters';
eval { $a = $Func->(\$x, \1) ;} ;
like $$Error, "/^$TopType: output buffer is read-only/", ' Output is read-only' ;
' Input and Output filename are the same';
}
+ {
+ my $dir = "tmpdir";
+ my $lex = new LexDir $dir ;
+ mkdir $dir, 0777 ;
+
+ $a = $Func->($dir, \$x) ;
+ is $a, undef, " $TopType returned undef";
+ like $$Error, "/input file '$dir' is a directory/",
+ ' Input filename is a directory';
+
+ $a = $Func->(\$x, $dir) ;
+ is $a, undef, " $TopType returned undef";
+ like $$Error, "/output file '$dir' is a directory/",
+ ' Output filename is a directory';
+ }
+
eval { $a = $Func->(\$in, \$in) ;} ;
like $@, mkErr("^$TopType: input and output buffer are identical"),
' Input and Output buffer are the same';
- my $lex = new LexFile my $out_file ;
- open OUT, ">$out_file" ;
- eval { $a = $Func->(\*OUT, \*OUT) ;} ;
- like $@, mkErr("^$TopType: input and output handle are identical"),
- ' Input and Output handle are the same';
-
- close OUT;
- is -s $out_file, 0, " File zero length" ;
+ SKIP:
+ {
+ # Threaded 5.6.x seems to have a problem comparing filehandles.
+ use Config;
+
+ skip 'Cannot compare filehandles with threaded $]', 2
+ if $] >= 5.006 && $] < 5.007 && $Config{useithreads};
+
+ my $lex = new LexFile my $out_file ;
+ open OUT, ">$out_file" ;
+ eval { $a = $Func->(\*OUT, \*OUT) ;} ;
+ like $@, mkErr("^$TopType: input and output handle are identical"),
+ ' Input and Output handle are the same';
+
+ close OUT;
+ is -s $out_file, 0, " File zero length" ;
+ }
+
{
my %x = () ;
my $object = bless \%x, "someClass" ;
my $Func = getTopFuncRef($bit);
my $TopType = getTopFuncName($bit);
+ {
+ my $in ;
+ my $out ;
+ my @x ;
+
+ SKIP:
+ {
+ use Config;
+
+ skip 'readonly + threads', 1
+ if $Config{useithreads};
+
+
+ eval { $a = $Func->(\$in, \$out, TrailingData => \"abc") ;} ;
+ like $@, mkErr("^$TopType: Parameter 'TrailingData' not writable"),
+ ' TrailingData output not writable';
+ }
+
+ eval { $a = $Func->(\$in, \$out, TrailingData => \@x) ;} ;
+ like $@, mkErr("^$TopType: Parameter 'TrailingData' not a scalar reference"),
+ ' TrailingData output not scaral reference';
+ }
+ }
+
+ foreach my $bit ($UncompressClass,
+ 'IO::Uncompress::AnyUncompress',
+ )
+ {
+ my $Error = getErrorRef($bit);
+ my $Func = getTopFuncRef($bit);
+ my $TopType = getTopFuncName($bit);
+
my $data = "mary had a little lamb" ;
my $keep = $data ;
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 = '';
}
- foreach my $ms (1, 0)
+ foreach my $ms (@MultiValues)
{
{
title "$TopType - From Array Ref to Buffer, MultiStream $ms" ;
}
}
+ foreach my $bit ($UncompressClass,
+ #'IO::Uncompress::AnyUncompress',
+ )
+ {
+ my $Error = getErrorRef($bit);
+ my $Func = getTopFuncRef($bit);
+ my $TopType = getTopFuncName($bit);
+ my $CompressClass = getInverse($bit);
+ my $C_Func = getTopFuncRef($CompressClass);
+
+
+
+ my $data = "mary had a little lamb" ;
+ my $keep = $data ;
+ my $extra = "after the main event";
+
+ foreach my $fb ( qw( filehandle buffer ) )
+ {
+ title "Trailingdata with $TopType, from $fb";
+
+ my $lex = new LexFile my $name ;
+ my $input ;
+
+ my $compressed ;
+ ok &$C_Func(\$data, \$compressed), ' Compressed ok' ;
+ $compressed .= $extra;
+
+ if ($fb eq 'buffer')
+ {
+ $input = \$compressed;
+ }
+ else
+ {
+ writeFile($name, $compressed);
+
+ $input = new IO::File "<$name" ;
+ }
+
+ my $trailing;
+ my $out;
+ ok $Func->($input, \$out, TrailingData => $trailing), " Uncompressed OK" ;
+ is $out, $keep, " Got uncompressed data";
+
+ my $rest = '';
+ if ($fb eq 'filehandle')
+ {
+ read($input, $rest, 10000) ;
+ }
+
+ is $trailing . $rest, $extra, " Got trailing data";
+
+ }
+ }
+
+
# foreach my $bit ($CompressClass)
# {
# my $Error = getErrorRef($bit);
is @copy, 0, " got all files";
}
- foreach my $ms (0, 1)
+ foreach my $ms (@MultiValues)
{
{
title "$TopType - From FileGlob to Buffer files [@$files], MS $ms" ;
my $incumbent = "incumbent data" ;
+ my @opts = (Strict => 1);
+ push @opts, (RawInflate => 1)
+ if $bit eq 'IO::Uncompress::AnyUncompress';
+
for my $append (0, 1)
{
my $expected = $buffer ;
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";
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";
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) ;
}
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) ;
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) ;
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) ;
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";
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) ;
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) ;
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";
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");
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";
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";
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 ;
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) ;
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)
}
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)
}
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)
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],
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";
{
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;
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);
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";
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" ;
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" ;