1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
use lib 't';
use strict;
use warnings;
use bytes;
use Test::More ;
use CompTestUtils;
our ($extra);
BEGIN {
plan skip_all => "Lengthy Tests Disabled\n" .
"set COMPRESS_ZLIB_RUN_ALL or COMPRESS_ZLIB_RUN_MOST to run this test suite"
unless defined $ENV{COMPRESS_ZLIB_RUN_ALL} or defined $ENV{COMPRESS_ZLIB_RUN_MOST};
# use Test::NoWarnings, if available
$extra = 0 ;
$extra = 1
if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
}
sub run
{
my $CompressClass = identify();
my $UncompressClass = getInverse($CompressClass);
my $Error = getErrorRef($CompressClass);
my $UnError = getErrorRef($UncompressClass);
my $hello = <<EOM ;
hello world
this is a test
some more stuff on this line
ad finally...
EOM
print "#\n# Testing $UncompressClass\n#\n";
my $compressed = mkComplete($CompressClass, $hello);
my $cc = $compressed ;
plan tests => (length($compressed) * 6 * 7) + 1 + $extra ;
is anyUncompress(\$cc), $hello ;
for my $blocksize (1, 2, 13)
{
for my $i (0 .. length($compressed) - 1)
{
for my $useBuf (0 .. 1)
{
print "#\n# BlockSize $blocksize, Length $i, Buffer $useBuf\n#\n" ;
my $lex = new LexFile my $name ;
my $prime = substr($compressed, 0, $i);
my $rest = substr($compressed, $i);
my $start ;
if ($useBuf) {
$start = \$rest ;
}
else {
$start = $name ;
writeFile($name, $rest);
}
#my $gz = new $UncompressClass $name,
my $gz = new $UncompressClass $start,
-Append => 1,
-BlockSize => $blocksize,
-Prime => $prime,
-Transparent => 0
;
ok $gz;
ok ! $gz->error() ;
my $un ;
my $status = 1 ;
$status = $gz->read($un) while $status > 0 ;
is $status, 0 ;
ok ! $gz->error()
or print "Error is '" . $gz->error() . "'\n";
is $un, $hello ;
ok $gz->eof() ;
ok $gz->close() ;
}
}
}
}
1;
|