2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 10:58:58 +00:00

zlib-flate: make test work with alternative zlib

This commit is contained in:
Jay Berkenbilt 2023-12-19 08:05:33 -05:00
parent a80e1a578f
commit 513ed69234
3 changed files with 32 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@ -7,22 +7,40 @@ require TestDriver;
my $td = new TestDriver('zlib-flate'); my $td = new TestDriver('zlib-flate');
cleanup();
open(F, "<1.uncompressed") or die;
undef $/;
my $unc = <F>;
close(F);
open(F, ">a.uncompressed") or die;
for (my $i = 0; $i < 100; $i++)
{
print F $unc;
}
close(F);
foreach my $level ('', '=1', '=9') foreach my $level ('', '=1', '=9')
{ {
my $f = $level; my $f = $level;
$f =~ s/=/-/; $f =~ s/=/-/;
$td->runtest("compress", $td->runtest("compress",
{$td->COMMAND => {$td->COMMAND =>
"zlib-flate -compress$level < 1.uncompressed"}, "zlib-flate -compress$level < a.uncompressed > a.$level"},
{$td->FILE => "1.compressed$f", {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->EXIT_STATUS => 0});
$td->runtest("uncompress", $td->runtest("uncompress",
{$td->COMMAND => "zlib-flate -uncompress < 1.compressed"}, {$td->COMMAND => "zlib-flate -uncompress < a.$level"},
{$td->FILE => "1.uncompressed", {$td->FILE => "a.uncompressed", $td->EXIT_STATUS => 0});
$td->EXIT_STATUS => 0});
} }
my $size1 = (stat("a.=1"))[7];
my $size9 = (stat("a.=9"))[7];
$td->runtest("higher compression is smaller",
{$td->STRING => ($size9 < $size1 ? "YES\n" : "$size9 $size1\n")},
{$td->STRING => "YES\n"});
$td->runtest("error", $td->runtest("error",
{$td->COMMAND => "zlib-flate -uncompress < 1.uncompressed"}, {$td->COMMAND => "zlib-flate -uncompress < 1.uncompressed"},
{$td->REGEXP => "flate: inflate: data: .*\n", {$td->REGEXP => "flate: inflate: data: .*\n",
@ -36,4 +54,11 @@ $td->runtest("corrupted input",
$td->EXIT_STATUS => 3}, $td->EXIT_STATUS => 3},
$td->NORMALIZE_NEWLINES); $td->NORMALIZE_NEWLINES);
$td->report(8); $td->report(9);
cleanup();
sub cleanup
{
system("rm -f a.*");
}