26#include "lib/res/file/archive/compression.h"
37 std::mt19937 engine(42);
38 std::uniform_int_distribution<u8> distribution(0x00, 0x07);
39 const size_t data_size = 10000;
41 for(
size_t i = 0; i < data_size; i++)
42 data[i] = distribution(engine);
44 u8* cdata;
size_t csize;
48 uintptr_t c = comp_alloc(CT_COMPRESSION, CM_DEFLATE);
51 const size_t csizeBound = comp_max_output_size(c, data_size);
53 const ssize_t cdata_produced = comp_feed(c, data, data_size);
54 TS_ASSERT(cdata_produced >= 0);
57 TS_ASSERT(cdata_produced <= (
ssize_t)csize);
61 uintptr_t d = comp_alloc(CT_DECOMPRESSION, CM_DEFLATE);
64 comp_set_output(d, udata, data_size);
65 const ssize_t udata_produced = comp_feed(d, cdata, csize);
66 TS_ASSERT(udata_produced >= 0);
67 u8* udata_final;
size_t usize_final;
u32 checksum;
68 TS_ASSERT_OK(comp_finish(d, &udata_final, &usize_final, &checksum));
69 TS_ASSERT(udata_produced <= (
ssize_t)usize_final);
70 TS_ASSERT_EQUALS(udata_final, udata);
71 TS_ASSERT_EQUALS(usize_final, data_size);
78 TS_ASSERT_SAME_DATA(data, udata, data_size);
Definition: test_compression.h:31
void test_compress_decompress_compare()
Definition: test_compression.h:33
#define TS_ASSERT_OK(expr)
Definition: self_test.h:127
uint8_t u8
Definition: types.h:37
uint32_t u32
Definition: types.h:39
intptr_t ssize_t
Definition: wposix_types.h:82