Commit d6cb2b94187d5abc7d8f7f595ed42d6739bbfcd5
1 parent
f07e3370
Add test code for Pl_Concatenate
Showing
2 changed files
with
39 additions
and
0 deletions
libtests/build.mk
libtests/concatenate.cc
0 → 100644
| 1 | +#include <qpdf/Pl_Concatenate.hh> | |
| 2 | +#include <qpdf/Pl_Flate.hh> | |
| 3 | +#include <qpdf/Pl_Buffer.hh> | |
| 4 | +#include <iostream> | |
| 5 | +#include <assert.h> | |
| 6 | + | |
| 7 | +static void pipeStringAndFinish(Pipeline* p, std::string const& str) | |
| 8 | +{ | |
| 9 | + p->write((unsigned char*)str.c_str(), str.length()); | |
| 10 | + p->finish(); | |
| 11 | +} | |
| 12 | + | |
| 13 | +int main(int argc, char* argv[]) | |
| 14 | +{ | |
| 15 | + Pl_Buffer b1("compressed"); | |
| 16 | + Pl_Flate deflate("compress", &b1, Pl_Flate::a_deflate); | |
| 17 | + Pl_Concatenate concat("concat", &deflate); | |
| 18 | + pipeStringAndFinish(&concat, "-one-"); | |
| 19 | + pipeStringAndFinish(&concat, "-two-"); | |
| 20 | + concat.manualFinish(); | |
| 21 | + | |
| 22 | + PointerHolder<Buffer> b1_buf = b1.getBuffer(); | |
| 23 | + Pl_Buffer b2("uncompressed"); | |
| 24 | + Pl_Flate inflate("uncompress", &b2, Pl_Flate::a_inflate); | |
| 25 | + inflate.write(b1_buf->getBuffer(), b1_buf->getSize()); | |
| 26 | + inflate.finish(); | |
| 27 | + PointerHolder<Buffer> b2_buf = b2.getBuffer(); | |
| 28 | + std::string result((char const*)b2_buf->getBuffer(), b2_buf->getSize()); | |
| 29 | + if (result == "-one--two-") | |
| 30 | + { | |
| 31 | + std::cout << "concatenate test passed" << std::endl; | |
| 32 | + } | |
| 33 | + else | |
| 34 | + { | |
| 35 | + std::cout << "concatenate test failed: " << result << std::endl; | |
| 36 | + } | |
| 37 | + return 0; | |
| 38 | +} | ... | ... |