diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-12-18 19:08:55 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-12-18 22:46:10 +0100 |
commit | f38df27aa3eae905e3ee90365099335e317173d8 (patch) | |
tree | 3a0c8ac95e389889cbcee3a92924d2652e2d42a0 /qpdf/test_driver.cc | |
parent | 077d3d451204393d17b9a14c2145487c35fce572 (diff) | |
download | qpdf-f38df27aa3eae905e3ee90365099335e317173d8.tar.zst |
Add QPDFNumberTreeObjectHelper
Diffstat (limited to 'qpdf/test_driver.cc')
-rw-r--r-- | qpdf/test_driver.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc index 74b34396..3bcb173e 100644 --- a/qpdf/test_driver.cc +++ b/qpdf/test_driver.cc @@ -6,6 +6,7 @@ #include <qpdf/QPDFPageDocumentHelper.hh> #include <qpdf/QPDFPageObjectHelper.hh> #include <qpdf/QPDFAcroFormDocumentHelper.hh> +#include <qpdf/QPDFNumberTreeObjectHelper.hh> #include <qpdf/QUtil.hh> #include <qpdf/QTC.hh> #include <qpdf/Pl_StdioFile.hh> @@ -1660,6 +1661,35 @@ void runtest(int n, char const* filename1, char const* arg2) exit(3); } } + else if (n == 46) + { + // Test number tree. This test is crafted to work with + // number-tree.pdf + QPDFObjectHandle qtest = pdf.getTrailer().getKey("/QTest"); + QPDFNumberTreeObjectHelper ntoh(qtest); + QPDFNumberTreeObjectHelper::idx_map ntoh_map = ntoh.getAsMap(); + for (QPDFNumberTreeObjectHelper::idx_map::iterator iter = + ntoh_map.begin(); + iter != ntoh_map.end(); ++iter) + { + std::cout << (*iter).first << " " + << (*iter).second.getStringValue() + << std::endl; + } + assert(1 == ntoh.getMin()); + assert(29 == ntoh.getMax()); + assert(ntoh.hasIndex(6)); + assert(! ntoh.hasIndex(500)); + QPDFObjectHandle oh; + assert(! ntoh.findObject(4, oh)); + assert(ntoh.findObject(3, oh)); + assert("three" == oh.getStringValue()); + QPDFNumberTreeObjectHelper::numtree_number offset = 0; + assert(! ntoh.findObjectAtOrBelow(0, oh, offset)); + assert(ntoh.findObjectAtOrBelow(8, oh, offset)); + assert("six" == oh.getStringValue()); + assert(2 == offset); + } else { throw std::runtime_error(std::string("invalid test ") + |