Restore coverage case

Previous commit lost coverage case for buffer-based replaceStreamData.
This commit is contained in:
Jay Berkenbilt 2012-07-25 22:32:14 -04:00
parent 9c00874e77
commit f689324214
3 changed files with 18 additions and 16 deletions

View File

@ -1,3 +1,9 @@
2012-07-25 Jay Berkenbilt <ejb@ql.org>
* From Tobias: add QPDFObjectHandle::replaceStreamData that takes
a std::string analogous to the QPDFObjectHandle::newStream that
takes a string that was added earlier.
2012-07-21 Jay Berkenbilt <ejb@ql.org>
* Change configure to have image comparison tests disabled by

View File

@ -61,12 +61,7 @@ int main(int argc, char* argv[])
char const* password = (argc == 4) ? argv[3] : "";
// Text to prepend to each page's contents
char const* content = "2 0 0 2 0 0 cm\n";
// Copy text into a buffer without the null terminator
PointerHolder<Buffer> b = new Buffer(strlen(content));
unsigned char* bp = b->getBuffer();
memcpy(bp, (unsigned char*)content, strlen(content));
std::string content = "2 0 0 2 0 0 cm\n";
try
{
@ -80,7 +75,8 @@ int main(int argc, char* argv[])
QPDFObjectHandle& page = *iter;
// Prepend the buffer to the page's contents
page.addPageContents(QPDFObjectHandle::newStream(&qpdf, b), true);
page.addPageContents(
QPDFObjectHandle::newStream(&qpdf, content), true);
// Double the size of each of the content boxes
doubleBoxSize(page, "/MediaBox");

View File

@ -455,11 +455,9 @@ void runtest(int n, char const* filename1, char const* filename2)
{
throw std::logic_error("test 7 run on file with no QStream");
}
PointerHolder<Buffer> b = new Buffer(20);
unsigned char* bp = b->getBuffer();
memcpy(bp, (char*)"new data for stream\n", 20); // no null!
qstream.replaceStreamData(
b, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
"new data for stream\n",
QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
QPDFWriter w(pdf, "a.pdf");
w.setStaticID(true);
w.setStreamDataMode(qpdf_s_preserve);
@ -509,8 +507,12 @@ void runtest(int n, char const* filename1, char const* filename2)
else if (n == 9)
{
QPDFObjectHandle root = pdf.getRoot();
// Explicitly exercise the Buffer version of newStream
PointerHolder<Buffer> buf = new Buffer(20);
unsigned char* bp = buf->getBuffer();
memcpy(bp, (char*)"data for new stream\n", 20); // no null!
QPDFObjectHandle qstream = QPDFObjectHandle::newStream(
&pdf, "data for new stream\n");
&pdf, buf);
QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf);
try
{
@ -521,11 +523,9 @@ void runtest(int n, char const* filename1, char const* filename2)
{
std::cout << "exception: " << e.what() << std::endl;
}
PointerHolder<Buffer> buf = new Buffer(22);
unsigned char* bp = buf->getBuffer();
memcpy(bp, (char*)"data for other stream\n", 22); // no null!
rstream.replaceStreamData(
buf, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
"data for other stream\n",
QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
root.replaceKey("/QStream", qstream);
root.replaceKey("/RStream", rstream);
QPDFWriter w(pdf, "a.pdf");