diff options
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qtest/qpdf.test | 9 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/unique-resources.pdf | bin | 0 -> 849 bytes | |||
-rw-r--r-- | qpdf/test_driver.cc | 17 |
3 files changed, 25 insertions, 1 deletions
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index 817f6174..8f86844d 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -1032,12 +1032,19 @@ $td->runtest("detect foreign object in write", show_ntests(); # ---------- $td->notify("--- Merge Dictionary ---"); -$n_tests += 1; +$n_tests += 3; $td->runtest("merge dictionary", {$td->COMMAND => "test_driver 50 merge-dict.pdf"}, {$td->FILE => "merge-dict.out", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); +$td->runtest("unique resource name", + {$td->COMMAND => "test_driver 60 minimal.pdf"}, + {$td->STRING => "test 60 done\n", $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); +$td->runtest("check output", + {$td->FILE => "a.pdf"}, + {$td->FILE => "unique-resources.pdf"}); show_ntests(); # ---------- diff --git a/qpdf/qtest/qpdf/unique-resources.pdf b/qpdf/qtest/qpdf/unique-resources.pdf Binary files differnew file mode 100644 index 00000000..1f789ea1 --- /dev/null +++ b/qpdf/qtest/qpdf/unique-resources.pdf diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 57dad636..a03c4b98 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -2016,6 +2016,23 @@ void runtest(int n, char const* filename1, char const* arg2) w.setStaticID(true); w.write(); } + else if (n == 60) + { + // Boundary condition testing for getUniqueResourceName + QPDFObjectHandle r1 = QPDFObjectHandle::newDictionary(); + int min_suffix = 1; + for (int i = 1; i < 3; ++i) + { + std::string name = r1.getUniqueResourceName("/Quack", min_suffix); + r1.mergeResources(QPDFObjectHandle::parse("<< /Z << >> >>")); + r1.getKey("/Z").replaceKey( + name, QPDFObjectHandle::newString("moo")); + } + pdf.getTrailer().replaceKey("/QTest", r1); + QPDFWriter w(pdf, "a.pdf"); + w.setStaticID(true); + w.write(); + } else { throw std::runtime_error(std::string("invalid test ") + |