2022-05-03 12:21:01 +00:00
|
|
|
#include <qpdf/assert_test.h>
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
#include <qpdf/Pl_Buffer.hh>
|
2012-06-27 14:02:23 +00:00
|
|
|
#include <qpdf/Pl_Concatenate.hh>
|
|
|
|
#include <qpdf/Pl_Flate.hh>
|
2013-02-24 02:46:21 +00:00
|
|
|
#include <qpdf/QUtil.hh>
|
2012-06-27 14:02:23 +00:00
|
|
|
#include <iostream>
|
2022-03-07 13:46:53 +00:00
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
static void
|
|
|
|
pipeStringAndFinish(Pipeline* p, std::string const& str)
|
2012-06-27 14:02:23 +00:00
|
|
|
{
|
2013-02-24 02:46:21 +00:00
|
|
|
p->write(QUtil::unsigned_char_pointer(str), str.length());
|
2012-06-27 14:02:23 +00:00
|
|
|
p->finish();
|
|
|
|
}
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
int
|
|
|
|
main(int argc, char* argv[])
|
2012-06-27 14:02:23 +00:00
|
|
|
{
|
|
|
|
Pl_Buffer b1("compressed");
|
|
|
|
Pl_Flate deflate("compress", &b1, Pl_Flate::a_deflate);
|
|
|
|
Pl_Concatenate concat("concat", &deflate);
|
|
|
|
pipeStringAndFinish(&concat, "-one-");
|
|
|
|
pipeStringAndFinish(&concat, "-two-");
|
|
|
|
concat.manualFinish();
|
|
|
|
|
2022-02-06 16:40:24 +00:00
|
|
|
auto b1_buf = b1.getBufferSharedPointer();
|
2012-06-27 14:02:23 +00:00
|
|
|
Pl_Buffer b2("uncompressed");
|
|
|
|
Pl_Flate inflate("uncompress", &b2, Pl_Flate::a_inflate);
|
|
|
|
inflate.write(b1_buf->getBuffer(), b1_buf->getSize());
|
|
|
|
inflate.finish();
|
2022-02-06 16:40:24 +00:00
|
|
|
auto b2_buf = b2.getBufferSharedPointer();
|
2022-04-02 21:14:10 +00:00
|
|
|
std::string result(
|
|
|
|
reinterpret_cast<char*>(b2_buf->getBuffer()), b2_buf->getSize());
|
|
|
|
if (result == "-one--two-") {
|
2012-06-27 14:02:23 +00:00
|
|
|
std::cout << "concatenate test passed" << std::endl;
|
2022-04-02 21:14:10 +00:00
|
|
|
} else {
|
2012-06-27 14:02:23 +00:00
|
|
|
std::cout << "concatenate test failed: " << result << std::endl;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|