summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qpdf/qtest/qpdf.test6
-rw-r--r--qpdf/qtest/qpdf/page_api_1.out21
-rw-r--r--qpdf/test_driver.cc9
3 files changed, 15 insertions, 1 deletions
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 4ec68c53..94252db4 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -111,7 +111,7 @@ $td->runtest("new stream",
show_ntests();
# ----------
$td->notify("--- Page API Tests ---");
-$n_tests += 8;
+$n_tests += 9;
$td->runtest("basic page API",
{$td->COMMAND => "test_driver 15 page_api_1.pdf"},
@@ -142,6 +142,10 @@ $td->runtest("duplicate page",
{$td->COMMAND => "test_driver 19 page_api_1.pdf"},
{$td->FILE => "page_api_1.out", $td->EXIT_STATUS => 2},
$td->NORMALIZE_NEWLINES);
+$td->runtest("remove page we don't have",
+ {$td->COMMAND => "test_driver 22 page_api_1.pdf"},
+ {$td->FILE => "page_api_1.out2", $td->EXIT_STATUS => 2},
+ $td->NORMALIZE_NEWLINES);
# ----------
$td->notify("--- Miscellaneous Tests ---");
$n_tests += 40;
diff --git a/qpdf/qtest/qpdf/page_api_1.out2 b/qpdf/qtest/qpdf/page_api_1.out2
new file mode 100644
index 00000000..c945f0e8
--- /dev/null
+++ b/qpdf/qtest/qpdf/page_api_1.out2
@@ -0,0 +1 @@
+page_api_1.pdf (page object: object 4 0): page object not referenced in /Pages tree
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index a3d2570c..6fd4faec 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -826,6 +826,15 @@ void runtest(int n, char const* filename)
contents.shallowCopy();
std::cout << "you can't see this" << std::endl;
}
+ else if (n == 22)
+ {
+ // Try to remove a page we don't have
+ std::vector<QPDFObjectHandle> const& pages = pdf.getAllPages();
+ QPDFObjectHandle page = pages[0];
+ pdf.removePage(page);
+ pdf.removePage(page);
+ std::cout << "you can't see this" << std::endl;
+ }
else
{
throw std::runtime_error(std::string("invalid test ") +