2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-22 19:08:59 +00:00
qpdf/libtests/qtest/flate.test
Jay Berkenbilt 9a0b88bf77 update release date to actual date
git-svn-id: svn+q:///qpdf/trunk@599 71b93d88-0707-0410-a8cf-f5a4172ac649
2008-04-29 12:55:25 +00:00

74 lines
1.5 KiB
Perl

#!/usr/bin/env perl
require 5.008;
BEGIN { $^W = 1; }
use strict;
use File::Copy;
use Digest::MD5;
chdir("flate") or die "chdir testdir failed: $!\n";
require TestDriver;
cleanup();
my $td = new TestDriver('flate');
cleanup();
open(F, ">farbage") or die;
print F "q" x 10000, "\n";
print F "w" x 10000, "\n";
print F "e" x 10000, "\n";
print F "r" x 10000, "\n";
print F "t" x 10000, "\n";
print F "y" x 10000, "\n";
print F "u" x 10000, "\n";
print F "i" x 10000, "\n";
print F "o" x 10000, "\n";
print F "p" x 10000, "\n";
close(F);
check_file("farbage", "a6449c61db5b0645c0693b7560b77a60");
$td->runtest("run driver",
{$td->COMMAND => "flate farbage"},,
{$td->STRING => "bytes written to o3: 100010\ndone\n",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
check_file("farbage", "a6449c61db5b0645c0693b7560b77a60");
$td->runtest("compressed file correct",
{$td->FILE => "farbage.1"},
{$td->FILE => "compressed"});
$td->runtest("uncompress filter works",
{$td->FILE => "farbage"},
{$td->FILE => "farbage.2"});
$td->runtest("double filter works",
{$td->FILE => "farbage"},
{$td->FILE => "farbage.3"});
cleanup();
$td->report(6);
sub cleanup
{
system("rm -f farbage*");
}
sub check_file
{
my ($file, $sum) = @_;
open(F, "<$file") or die "open $file";
my $md5 = new Digest::MD5;
$md5->addfile(*F);
close(F);
my $result = $md5->hexdigest;
$td->runtest("check $file",
{$td->STRING => "$result\n"},
{$td->STRING => "$sum\n"});
}