#!/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('page-without-contents');

my $n_tests = 7;

$td->runtest("check no contents",
             {$td->COMMAND => "qpdf --check no-contents.pdf"},
             {$td->FILE => "no-contents-check.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

foreach my $arg ('--qdf', '--coalesce-contents', '')
{
    $td->runtest("convert no contents ($arg)",
                 {$td->COMMAND =>
                      "qpdf $arg --static-id no-contents.pdf a.pdf"},
                 {$td->STRING => "", $td->EXIT_STATUS => 0});

    my $suf = $arg;
    $suf =~ s/--//;
    if ($suf eq '')
    {
        $suf = "none";
    }
    $td->runtest("check output",
                 {$td->FILE => "a.pdf"},
                 {$td->FILE => "no-contents-$suf.pdf"});
}

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