aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-06-24 00:32:14 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-24 00:32:14 +0200
commit2a057ac0d4053d2306f48bc9e89b0dcb1959b9da (patch)
tree598cdb4bc9b787d265668b9cfa9d1a17e7960e32
parent4f305488d85f9237c561f04a88570f9b0584cb0d (diff)
downloadqpdf-2a057ac0d4053d2306f48bc9e89b0dcb1959b9da.tar.zst
Add test case for removing a page we don't have
-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 ") +