From c2ae35540e78d4edfbc57d42bfa2fc166c38b8a5 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 27 Jan 2019 08:00:32 -0500 Subject: [PATCH] Add boundary condition test for getUniqueResourceName --- qpdf/qtest/qpdf.test | 9 ++++++++- qpdf/qtest/qpdf/unique-resources.pdf | Bin 0 -> 849 bytes qpdf/test_driver.cc | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 qpdf/qtest/qpdf/unique-resources.pdf 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 new file mode 100644 index 0000000000000000000000000000000000000000..1f789ea132ec910280b64b7fffa38f3960a32aca GIT binary patch literal 849 zcmah{+ltdb81{fr1HQvASWs|HW^!tv1l{chi>Gc|5G=izO=oK~osrCRtzP*8zJXUh zf-m507ZJSD>-8nP6aPt?M(TyhMe-lM|L}c(d(cbv$Q{>efByCHw?)7KdHllacEKL7 zIaff@GX#75<`oC~fN7S?ImEHW#mpp{a1A(+OQC^){UDnun1EYCr!}~$*Fa6UfeOuq zR^V0b9`RYm_T>tzIQRyHLKsoNS_4*KVm;Q7E4eIEoYPF4NQ{&}1pKm493!HT>4<9x zww`JkGtXa}n9lV$54o7@=iqg)W|nJS;5TQQ_joF2B}nOlvxT+#pse%Z;M;3=?9iiD z|MI7=@87NOUcYf={k^re`?t@2j9X_vi)-hXE_}Iob&afTkQ@HYn042Erg*u6eV^y2 zTxTf*`%qxZOw7T4nu&WtWsT!8Tc9Qh5rx=I8QRr?Wvzy9v%hIIK}vcFCh?Vq zX)WZc;3t*?q2+8J2z=l5;RLomg5#P8MB@vPxE&v%sO^rA2H1bc=XU> >>")); + 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 ") +