mirror of
https://github.com/qpdf/qpdf.git
synced 2024-06-03 19:00:51 +00:00
Restore coverage case
Previous commit lost coverage case for buffer-based replaceStreamData.
This commit is contained in:
parent
9c00874e77
commit
f689324214
|
@ -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>
|
2012-07-21 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* Change configure to have image comparison tests disabled by
|
* Change configure to have image comparison tests disabled by
|
||||||
|
|
|
@ -61,12 +61,7 @@ int main(int argc, char* argv[])
|
||||||
char const* password = (argc == 4) ? argv[3] : "";
|
char const* password = (argc == 4) ? argv[3] : "";
|
||||||
|
|
||||||
// Text to prepend to each page's contents
|
// Text to prepend to each page's contents
|
||||||
char const* content = "2 0 0 2 0 0 cm\n";
|
std::string 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));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -80,7 +75,8 @@ int main(int argc, char* argv[])
|
||||||
QPDFObjectHandle& page = *iter;
|
QPDFObjectHandle& page = *iter;
|
||||||
|
|
||||||
// Prepend the buffer to the page's contents
|
// 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
|
// Double the size of each of the content boxes
|
||||||
doubleBoxSize(page, "/MediaBox");
|
doubleBoxSize(page, "/MediaBox");
|
||||||
|
|
|
@ -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");
|
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(
|
qstream.replaceStreamData(
|
||||||
b, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
|
"new data for stream\n",
|
||||||
|
QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
|
||||||
QPDFWriter w(pdf, "a.pdf");
|
QPDFWriter w(pdf, "a.pdf");
|
||||||
w.setStaticID(true);
|
w.setStaticID(true);
|
||||||
w.setStreamDataMode(qpdf_s_preserve);
|
w.setStreamDataMode(qpdf_s_preserve);
|
||||||
|
@ -509,8 +507,12 @@ void runtest(int n, char const* filename1, char const* filename2)
|
||||||
else if (n == 9)
|
else if (n == 9)
|
||||||
{
|
{
|
||||||
QPDFObjectHandle root = pdf.getRoot();
|
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(
|
QPDFObjectHandle qstream = QPDFObjectHandle::newStream(
|
||||||
&pdf, "data for new stream\n");
|
&pdf, buf);
|
||||||
QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf);
|
QPDFObjectHandle rstream = QPDFObjectHandle::newStream(&pdf);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -521,11 +523,9 @@ void runtest(int n, char const* filename1, char const* filename2)
|
||||||
{
|
{
|
||||||
std::cout << "exception: " << e.what() << std::endl;
|
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(
|
rstream.replaceStreamData(
|
||||||
buf, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
|
"data for other stream\n",
|
||||||
|
QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
|
||||||
root.replaceKey("/QStream", qstream);
|
root.replaceKey("/QStream", qstream);
|
||||||
root.replaceKey("/RStream", rstream);
|
root.replaceKey("/RStream", rstream);
|
||||||
QPDFWriter w(pdf, "a.pdf");
|
QPDFWriter w(pdf, "a.pdf");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user