aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/newline-before-endstream.test
blob: 2066375ed7fecd6d7c7b9cec7a63118caa7423bd (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
53
54
55
56
57
58
59
#!/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('newline-before-endstream');

my $n_tests = 12;

# From issue 133, http://verapdf.org/software/ is an open source
# package that can verify PDF/A compliance. This could potentially be
# useful for manual or automated verification that qpdf doesn't break
# PDF/A compliance should that ever be desired.

foreach my $d (
    ['--qdf', 'qdf', 'qdf'],
    ['--newline-before-endstream', 'newline', 'nl'],
    ['--qdf --newline-before-endstream', 'newline and qdf', 'nl-qdf'],
    ['--object-streams=generate --newline-before-endstream',
     'newline and object streams', 'nl-objstm'],
    )
{
    my ($flags, $description, $suffix) = @$d;
    $td->runtest("newline before endstream: $description",
                 {$td->COMMAND => "qpdf --static-id --stream-data=preserve" .
                      " $flags streams-with-newlines.pdf a.pdf"},
                 {$td->STRING => "", $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("check output ($description)",
                 {$td->COMMAND => "qpdf-test-compare a.pdf newline-before-endstream-$suffix.pdf"},
                 {$td->FILE => "newline-before-endstream-$suffix.pdf", $td->EXIT_STATUS => 0});
    if ($flags =~ /qdf/)
    {
        $td->runtest("fix-qdf",
                     {$td->COMMAND => "fix-qdf a.pdf"},
                     {$td->FILE => "a.pdf", $td->EXIT_STATUS => 0});
    }
}

$td->runtest("newline before endstream (C)",
             {$td->COMMAND =>
                  "qpdf-ctest 22 streams-with-newlines.pdf '' a.pdf"},
             {$td->STRING => "C test 22 done\n", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->COMMAND => "qpdf-test-compare a.pdf newline-before-endstream-nl.pdf"},
             {$td->FILE => "newline-before-endstream-nl.pdf", $td->EXIT_STATUS => 0});

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