26#include "lib/res/file/archive/codec_zlib.h"
35 size_t inConsumed, outProduced;
40 std::mt19937 engine(42);
41 std::uniform_int_distribution<u8> distribution(0x00, 0x07);
42 const size_t usize = 10000;
44 for(
size_t i = 0; i < usize; i++)
45 udata[i] = distribution(engine);
48 u8* cdata;
size_t csize;
50 boost::shared_ptr<ICodec> compressor_zlib = CreateCompressor_ZLib();
51 ICodec* c = compressor_zlib.get();
53 cdata =
new u8[csizeMax];
55 TS_ASSERT_EQUALS(inConsumed, usize);
56 TS_ASSERT_LESS_THAN_EQUALS(outProduced, csizeMax);
59 TS_ASSERT_EQUALS(cdata, cdata2);
60 TS_ASSERT_EQUALS(csize, outProduced);
64 TS_ASSERT(csize != usize || memcmp(udata, cdata, std::min(usize, csize)) != 0);
69 boost::shared_ptr<ICodec> decompressor_zlib = CreateDecompressor_ZLib();
70 ICodec* d = decompressor_zlib.get();
71 TS_ASSERT_OK(decompressor_zlib->Process(cdata, csize, ddata, usize, inConsumed, outProduced));
72 TS_ASSERT_EQUALS(inConsumed, csize);
73 TS_ASSERT_EQUALS(outProduced, usize);
74 u8* ddata2;
size_t dsize;
76 TS_ASSERT_EQUALS(ddata, ddata2);
77 TS_ASSERT_EQUALS(dsize, outProduced);
81 TS_ASSERT_SAME_DATA(udata, ddata, usize);
Definition: test_codec_zlib.h:31
void test_compress_decompress_compare()
Definition: test_codec_zlib.h:33
#define TS_ASSERT_OK(expr)
Definition: self_test.h:127
virtual Status Process(const u8 *in, size_t inSize, u8 *out, size_t outSize, size_t &inConsumed, size_t &outProduced)=0
process (i.e.
virtual size_t MaxOutputSize(size_t inSize) const =0
virtual Status Finish(u32 &checksum, size_t &outProduced)=0
Flush buffers and make sure all output has been produced.
uint8_t u8
Definition: types.h:37
uint32_t u32
Definition: types.h:39