34 #define DEFINE_DIFFRLE_BINARY_FORMAT_TEST(fn_name, pcomp_fn, \
38 datatype_t input_buf[] = { 10, 12, 14, 16, 17, 18 }; \
39 size_t input_size = sizeof(input_buf) / sizeof(input_buf[0]); \
40 size_t output_size = pcomp_diffrle_bufsize(input_size) \
41 * sizeof(datatype_t); \
42 datatype_t* output_buf = malloc(output_size); \
44 assert(pcomp_fn(output_buf, &output_size, input_buf, \
45 input_size) == PCOMP_STAT_SUCCESS); \
47 assert(output_size == 5); \
48 assert(output_buf[0] == 10); \
49 assert(output_buf[1] == 3); \
50 assert(output_buf[2] == 2); \
51 assert(output_buf[3] == 2); \
52 assert(output_buf[4] == 1); \
57 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_int8,
59 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_int16,
61 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_int32,
63 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_int64,
66 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_uint8,
68 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_uint16,
71 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_uint32,
74 DEFINE_DIFFRLE_BINARY_FORMAT_TEST(test_diffrle_binary_format_uint64,
78 void test_diffrle_binary_format(
void)
80 test_diffrle_binary_format_int8();
81 test_diffrle_binary_format_int16();
82 test_diffrle_binary_format_int32();
83 test_diffrle_binary_format_int64();
85 test_diffrle_binary_format_uint8();
86 test_diffrle_binary_format_uint16();
87 test_diffrle_binary_format_uint32();
88 test_diffrle_binary_format_uint64();
95 #define DEFINE_DIFFRLE_DECOMPRESS_TEST(fn_name, pcomp_compr_fn, \
96 pcomp_decompr_fn, datatype_t) \
99 const size_t input_size = 10000; \
100 datatype_t* input_buf \
101 = malloc(input_size * sizeof(datatype_t)); \
102 size_t compr_size = pcomp_diffrle_bufsize(input_size) \
103 * sizeof(datatype_t); \
104 datatype_t* compr_buf = malloc(compr_size); \
105 datatype_t* decompr_buf \
106 = malloc(input_size * sizeof(datatype_t)); \
107 size_t decompr_size = input_size; \
110 for (idx = 0; idx < input_size; ++idx) { \
112 input_buf[idx] = random() % 10; \
115 assert(pcomp_compr_fn(compr_buf, &compr_size, input_buf, \
116 input_size) == PCOMP_STAT_SUCCESS); \
117 assert(pcomp_decompr_fn(decompr_buf, decompr_size, compr_buf, \
118 compr_size) == PCOMP_STAT_SUCCESS); \
120 assert(decompr_size == input_size); \
121 for (idx = 0; idx < input_size; ++idx) { \
122 assert(decompr_buf[idx] == input_buf[idx]); \
130 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_int8,
133 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_int16,
136 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_int32,
139 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_int64,
143 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_uint8,
146 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_uint16,
150 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_uint32,
154 DEFINE_DIFFRLE_DECOMPRESS_TEST(test_diffrle_decompress_uint64,
159 void test_diffrle_decompression(
void)
161 test_diffrle_decompress_int8();
162 test_diffrle_decompress_int16();
163 test_diffrle_decompress_int32();
164 test_diffrle_decompress_int64();
166 test_diffrle_decompress_uint8();
167 test_diffrle_decompress_uint16();
168 test_diffrle_decompress_uint32();
169 test_diffrle_decompress_uint64();
174 test_diffrle_binary_format();
175 test_diffrle_decompression();
int pcomp_decompress_diffrle_uint32(uint32_t *output_buf, size_t output_size, const uint32_t *input_buf, size_t input_size)
Compress an array of uint32_t values using the diffRLE compression.
int pcomp_compress_diffrle_uint8(uint8_t *output_buf, size_t *output_size, const uint8_t *input_buf, size_t input_size)
Compress an array of uint8_t values using the diffRLE compression.
int pcomp_decompress_diffrle_int16(int16_t *output_buf, size_t output_size, const int16_t *input_buf, size_t input_size)
Compress an array of int16_t values using the diffRLE compression.
int pcomp_compress_diffrle_int32(int32_t *output_buf, size_t *output_size, const int32_t *input_buf, size_t input_size)
Compress an array of int32_t values using the diffRLE compression.
int pcomp_decompress_diffrle_uint8(uint8_t *output_buf, size_t output_size, const uint8_t *input_buf, size_t input_size)
Compress an array of uint8_t values using the diffRLE compression.
int pcomp_compress_diffrle_uint16(uint16_t *output_buf, size_t *output_size, const uint16_t *input_buf, size_t input_size)
Compress an array of uint16_t values using the diffRLE compression.
int pcomp_decompress_diffrle_int32(int32_t *output_buf, size_t output_size, const int32_t *input_buf, size_t input_size)
Compress an array of int32_t values using the diffRLE compression.
int pcomp_decompress_diffrle_uint16(uint16_t *output_buf, size_t output_size, const uint16_t *input_buf, size_t input_size)
Compress an array of uint16_t values using the diffRLE compression.
int pcomp_compress_diffrle_uint32(uint32_t *output_buf, size_t *output_size, const uint32_t *input_buf, size_t input_size)
Compress an array of uint32_t values using the diffRLE compression.
int pcomp_decompress_diffrle_int8(int8_t *output_buf, size_t output_size, const int8_t *input_buf, size_t input_size)
Decompress an array of int8_t values encoded using the diffRLE compression.
int pcomp_compress_diffrle_int16(int16_t *output_buf, size_t *output_size, const int16_t *input_buf, size_t input_size)
Compress an array of int16_t values using the diffRLE compression.
int pcomp_decompress_diffrle_uint64(uint64_t *output_buf, size_t output_size, const uint64_t *input_buf, size_t input_size)
Compress an array of uint64_t values using the diffRLE compression.
int pcomp_decompress_diffrle_int64(int64_t *output_buf, size_t output_size, const int64_t *input_buf, size_t input_size)
Compress an array of int64_t values using the diffRLE compression.
int pcomp_compress_diffrle_int8(int8_t *output_buf, size_t *output_size, const int8_t *input_buf, size_t input_size)
Compress an array of int8_t values using the diffRLE compression.
int pcomp_compress_diffrle_int64(int64_t *output_buf, size_t *output_size, const int64_t *input_buf, size_t input_size)
Compress an array of int64_t values using the diffRLE compression.
Header file for Libpolycomp.
int pcomp_compress_diffrle_uint64(uint64_t *output_buf, size_t *output_size, const uint64_t *input_buf, size_t input_size)
Compress an array of uint64_t values using the diffRLE compression.