aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/preserve-unref.test
blob: 3a290841539713fe1356a4c92704329af5cfa5a6 (plain) (blame)
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
#!/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('preserve-unref');

my $n_tests = 6;

$td->runtest("drop unused objects",
             {$td->COMMAND => "qpdf --static-id unreferenced-objects.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "unreferenced-dropped.pdf"});
$td->runtest("keep unused objects",
             {$td->COMMAND => "qpdf --static-id --preserve-unreferenced" .
                  " unreferenced-objects.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "unreferenced-preserved.pdf"});
$td->runtest("keep unused objects (C)",
             {$td->COMMAND =>
                  "qpdf-ctest 21 unreferenced-objects.pdf '' a.pdf"},
             {$td->STRING => "C test 21 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "unreferenced-preserved.pdf"});
cleanup();
$td->report($n_tests);