Commit 2a057ac0d4053d2306f48bc9e89b0dcb1959b9da
1 parent
4f305488
Add test case for removing a page we don't have
Showing
3 changed files
with
15 additions
and
1 deletions
qpdf/qtest/qpdf.test
| ... | ... | @@ -111,7 +111,7 @@ $td->runtest("new stream", |
| 111 | 111 | show_ntests(); |
| 112 | 112 | # ---------- |
| 113 | 113 | $td->notify("--- Page API Tests ---"); |
| 114 | -$n_tests += 8; | |
| 114 | +$n_tests += 9; | |
| 115 | 115 | |
| 116 | 116 | $td->runtest("basic page API", |
| 117 | 117 | {$td->COMMAND => "test_driver 15 page_api_1.pdf"}, |
| ... | ... | @@ -142,6 +142,10 @@ $td->runtest("duplicate page", |
| 142 | 142 | {$td->COMMAND => "test_driver 19 page_api_1.pdf"}, |
| 143 | 143 | {$td->FILE => "page_api_1.out", $td->EXIT_STATUS => 2}, |
| 144 | 144 | $td->NORMALIZE_NEWLINES); |
| 145 | +$td->runtest("remove page we don't have", | |
| 146 | + {$td->COMMAND => "test_driver 22 page_api_1.pdf"}, | |
| 147 | + {$td->FILE => "page_api_1.out2", $td->EXIT_STATUS => 2}, | |
| 148 | + $td->NORMALIZE_NEWLINES); | |
| 145 | 149 | # ---------- |
| 146 | 150 | $td->notify("--- Miscellaneous Tests ---"); |
| 147 | 151 | $n_tests += 40; | ... | ... |
qpdf/qtest/qpdf/page_api_1.out2
0 → 100644
| 1 | +page_api_1.pdf (page object: object 4 0): page object not referenced in /Pages tree | ... | ... |
qpdf/test_driver.cc
| ... | ... | @@ -826,6 +826,15 @@ void runtest(int n, char const* filename) |
| 826 | 826 | contents.shallowCopy(); |
| 827 | 827 | std::cout << "you can't see this" << std::endl; |
| 828 | 828 | } |
| 829 | + else if (n == 22) | |
| 830 | + { | |
| 831 | + // Try to remove a page we don't have | |
| 832 | + std::vector<QPDFObjectHandle> const& pages = pdf.getAllPages(); | |
| 833 | + QPDFObjectHandle page = pages[0]; | |
| 834 | + pdf.removePage(page); | |
| 835 | + pdf.removePage(page); | |
| 836 | + std::cout << "you can't see this" << std::endl; | |
| 837 | + } | |
| 829 | 838 | else |
| 830 | 839 | { |
| 831 | 840 | throw std::runtime_error(std::string("invalid test ") + | ... | ... |