Commit f6893242148460170253ef0ae51a6cd4b5ec8f95
1 parent
9c00874e
Restore coverage case
Previous commit lost coverage case for buffer-based replaceStreamData.
Showing
3 changed files
with
18 additions
and
16 deletions
ChangeLog
| 1 | +2012-07-25 Jay Berkenbilt <ejb@ql.org> | |
| 2 | + | |
| 3 | + * From Tobias: add QPDFObjectHandle::replaceStreamData that takes | |
| 4 | + a std::string analogous to the QPDFObjectHandle::newStream that | |
| 5 | + takes a string that was added earlier. | |
| 6 | + | |
| 1 | 7 | 2012-07-21 Jay Berkenbilt <ejb@ql.org> |
| 2 | 8 | |
| 3 | 9 | * Change configure to have image comparison tests disabled by | ... | ... |
examples/pdf-double-page-size.cc
| ... | ... | @@ -61,12 +61,7 @@ int main(int argc, char* argv[]) |
| 61 | 61 | char const* password = (argc == 4) ? argv[3] : ""; |
| 62 | 62 | |
| 63 | 63 | // Text to prepend to each page's contents |
| 64 | - char const* content = "2 0 0 2 0 0 cm\n"; | |
| 65 | - | |
| 66 | - // Copy text into a buffer without the null terminator | |
| 67 | - PointerHolder<Buffer> b = new Buffer(strlen(content)); | |
| 68 | - unsigned char* bp = b->getBuffer(); | |
| 69 | - memcpy(bp, (unsigned char*)content, strlen(content)); | |
| 64 | + std::string content = "2 0 0 2 0 0 cm\n"; | |
| 70 | 65 | |
| 71 | 66 | try |
| 72 | 67 | { |
| ... | ... | @@ -80,7 +75,8 @@ int main(int argc, char* argv[]) |
| 80 | 75 | QPDFObjectHandle& page = *iter; |
| 81 | 76 | |
| 82 | 77 | // Prepend the buffer to the page's contents |
| 83 | - page.addPageContents(QPDFObjectHandle::newStream(&qpdf, b), true); | |
| 78 | + page.addPageContents( | |
| 79 | + QPDFObjectHandle::newStream(&qpdf, content), true); | |
| 84 | 80 | |
| 85 | 81 | // Double the size of each of the content boxes |
| 86 | 82 | doubleBoxSize(page, "/MediaBox"); | ... | ... |
qpdf/test_driver.cc
| ... | ... | @@ -455,11 +455,9 @@ void runtest(int n, char const* filename1, char const* filename2) |
| 455 | 455 | { |
| 456 | 456 | throw std::logic_error("test 7 run on file with no QStream"); |
| 457 | 457 | } |
| 458 | - PointerHolder<Buffer> b = new Buffer(20); | |
| 459 | - unsigned char* bp = b->getBuffer(); | |
| 460 | - memcpy(bp, (char*)"new data for stream\n", 20); // no null! | |
| 461 | 458 | qstream.replaceStreamData( |
| 462 | - b, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | |
| 459 | + "new data for stream\n", | |
| 460 | + QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | |
| 463 | 461 | QPDFWriter w(pdf, "a.pdf"); |
| 464 | 462 | w.setStaticID(true); |
| 465 | 463 | w.setStreamDataMode(qpdf_s_preserve); |
| ... | ... | @@ -509,8 +507,12 @@ void runtest(int n, char const* filename1, char const* filename2) |
| 509 | 507 | else if (n == 9) |
| 510 | 508 | { |
| 511 | 509 | QPDFObjectHandle root = pdf.getRoot(); |
| 510 | + // Explicitly exercise the Buffer version of newStream | |
| 511 | + PointerHolder<Buffer> buf = new Buffer(20); | |
| 512 | + unsigned char* bp = buf->getBuffer(); | |
| 513 | + memcpy(bp, (char*)"data for new stream\n", 20); // no null! | |
| 512 | 514 | QPDFObjectHandle qstream = QPDFObjectHandle::newStream( |
| 513 | - &pdf, "data for new stream\n"); | |
| 515 | + &pdf, buf); | |
| 514 | 516 | QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf); |
| 515 | 517 | try |
| 516 | 518 | { |
| ... | ... | @@ -521,11 +523,9 @@ void runtest(int n, char const* filename1, char const* filename2) |
| 521 | 523 | { |
| 522 | 524 | std::cout << "exception: " << e.what() << std::endl; |
| 523 | 525 | } |
| 524 | - PointerHolder<Buffer> buf = new Buffer(22); | |
| 525 | - unsigned char* bp = buf->getBuffer(); | |
| 526 | - memcpy(bp, (char*)"data for other stream\n", 22); // no null! | |
| 527 | 526 | rstream.replaceStreamData( |
| 528 | - buf, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | |
| 527 | + "data for other stream\n", | |
| 528 | + QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | |
| 529 | 529 | root.replaceKey("/QStream", qstream); |
| 530 | 530 | root.replaceKey("/RStream", rstream); |
| 531 | 531 | QPDFWriter w(pdf, "a.pdf"); | ... | ... |