2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-11 07:30:57 +00:00

Add test case for removing a page we don't have

This commit is contained in:
Jay Berkenbilt 2012-06-23 18:32:14 -04:00
parent 4f305488d8
commit 2a057ac0d4
3 changed files with 15 additions and 1 deletions

View File

@ -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;

View File

@ -0,0 +1 @@
page_api_1.pdf (page object: object 4 0): page object not referenced in /Pages tree

View File

@ -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 ") +