diff options
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qpdf-ctest.c | 14 | ||||
-rw-r--r-- | qpdf/qpdf.testcov | 1 | ||||
-rw-r--r-- | qpdf/qtest/qpdf.test | 10 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/c-empty.pdf | 17 |
4 files changed, 41 insertions, 1 deletions
diff --git a/qpdf/qpdf-ctest.c b/qpdf/qpdf-ctest.c index 414c0eaa..502cede9 100644 --- a/qpdf/qpdf-ctest.c +++ b/qpdf/qpdf-ctest.c @@ -1242,6 +1242,19 @@ static void test40(char const* infile, report_errors(); } +static void test41(char const* infile, + char const* password, + char const* outfile, + char const* xarg) +{ + /* Empty PDF -- infile is ignored*/ + assert(qpdf_empty_pdf(qpdf) == 0); + qpdf_init_write(qpdf, outfile); + qpdf_set_static_ID(qpdf, QPDF_TRUE); + qpdf_write(qpdf); + report_errors(); +} + int main(int argc, char* argv[]) { char* p = 0; @@ -1322,6 +1335,7 @@ int main(int argc, char* argv[]) (n == 38) ? test38 : (n == 39) ? test39 : (n == 40) ? test40 : + (n == 41) ? test41 : 0); if (fn == 0) diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index 1e0f336e..77ef2fc9 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -639,3 +639,4 @@ QPDFJob json encrypt no key length 0 QPDFJob json encrypt duplicate key length 0 QPDFJob json encrypt missing password 0 QPDFJob json pages no file 0 +qpdf-c called qpdf_empty_pdf 0 diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index bf386168..b211f33f 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -3553,7 +3553,7 @@ my @capi = ( [8, 'no original object ids'], [9, 'uncompressed streams'], ); -$n_tests += (2 * @capi) + 3; +$n_tests += (2 * @capi) + 5; foreach my $d (@capi) { my ($n, $description) = @$d; @@ -3590,6 +3590,14 @@ $td->runtest("write damaged", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); +$td->runtest("empty PDF", + {$td->COMMAND => "qpdf-ctest 41 - '' a.pdf"}, + {$td->STRING => "C test 41 done\n", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("check output", + {$td->FILE => "a.pdf"}, + {$td->FILE => "c-empty.pdf"}); + show_ntests(); # ---------- $td->notify("--- Deterministic ID Tests ---"); diff --git a/qpdf/qtest/qpdf/c-empty.pdf b/qpdf/qtest/qpdf/c-empty.pdf new file mode 100644 index 00000000..a60e8169 --- /dev/null +++ b/qpdf/qtest/qpdf/c-empty.pdf @@ -0,0 +1,17 @@ +%PDF-1.3 +%¿÷¢þ +1 0 obj +<< /Pages 2 0 R /Type /Catalog >> +endobj +2 0 obj +<< /Count 0 /Kids [ ] /Type /Pages >> +endobj +xref +0 3 +0000000000 65535 f +0000000015 00000 n +0000000064 00000 n +trailer << /Root 1 0 R /Size 3 /ID [<31415926535897932384626433832795><31415926535897932384626433832795>] >> +startxref +117 +%%EOF |