aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/type-checks.test
blob: 73cb7fb6420e4f9b1a9accac15c8399317de78c4 (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
42
43
44
45
46
47
48
49
50
51
52
#!/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('type-checks');

my $n_tests = 6;

# Whenever object-types.pdf is edited, object-types-os.pdf should be
# regenerated.
$td->runtest("ensure object-types-os is up-to-date",
             {$td->COMMAND =>
                  "qpdf" .
                  " --object-streams=generate" .
                  " --deterministic-id" .
                  " --stream-data=uncompress" .
                  " object-types.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check file",
             {$td->COMMAND => "qpdf-test-compare a.pdf object-types-os.pdf"},
             {$td->FILE => "object-types-os.pdf", $td->EXIT_STATUS => 0});
$td->runtest("type checks",
             {$td->COMMAND => "test_driver 42 object-types.pdf"},
             {$td->FILE => "object-types.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("type checks with object streams",
             {$td->COMMAND => "test_driver 42 object-types-os.pdf"},
             {$td->FILE => "object-types-os.out",
              $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("compound type checks",
             {$td->COMMAND => "test_driver 82 object-types-os.pdf"},
             {$td->STRING => "test 82 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("indirect objects belonging to destroyed QPDF",
             {$td->COMMAND => "test_driver 92 -"},
             {$td->STRING => "test 92 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

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