collate.test 1.16 KB
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

unshift(@INC, '.');
require qpdf_test_helpers;

chdir("qpdf") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('collate');

my @collate = (
    ["", "three-files", "collate-odd",
     "collate-odd.pdf 1-5 minimal.pdf collate-even.pdf 7-1"],
    [1, "three-files", "collate-odd",
     "collate-odd.pdf 1-5 minimal.pdf collate-even.pdf 7-1"],
    [2, "three-files-2", "collate-odd",
     "collate-odd.pdf 1-5 minimal.pdf collate-even.pdf 7-1"],
    );
my $n_tests = 2 * scalar(@collate);

foreach my $d (@collate)
{
    my ($n, $description, $first, $args) = @$d;
    my $collate = '--collate';
    if ($n)
    {
        $collate .= "=$n";
    }
    $td->runtest("collate pages: $description",
                 {$td->COMMAND =>
                      "qpdf --qdf --static-id $collate $first.pdf" .
                      " --pages $args -- a.pdf"},
                 {$td->STRING => "", $td->EXIT_STATUS => 0});
    $td->runtest("check output",
                 {$td->FILE => "a.pdf"},
                 {$td->FILE => "$description-collate-out.pdf"});
}

cleanup();
$td->report($n_tests);