@@ -237,6 +237,40 @@ static char *test_small_blocksize(void) {
237
237
}
238
238
239
239
240
+ /* Check small buffer */
241
+ static char * test_small_buffer (void ) {
242
+ blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS ;
243
+ cparams .typesize = 1 ;
244
+ blosc2_context * cctx = blosc2_create_cctx (cparams );
245
+ blosc2_dparams dparams = BLOSC2_DPARAMS_DEFAULTS ;
246
+ blosc2_context * dctx = blosc2_create_dctx (dparams );
247
+ size = 2 ;
248
+ uint8_t * src2 = calloc (size , 1 );
249
+ for (int i = 0 ; i < size ; i ++ ) {
250
+ src2 [i ] = (uint8_t )i ;
251
+ }
252
+
253
+ /* Using contexts */
254
+ cbytes = blosc2_compress_ctx (cctx , src2 , size , dest , size + BLOSC2_MAX_OVERHEAD );
255
+ nbytes = blosc2_decompress_ctx (dctx , dest , size + BLOSC2_MAX_OVERHEAD , src , size );
256
+ mu_assert ("ERROR: nbytes is not correct" , nbytes == size );
257
+
258
+ /* Not using contexts */
259
+ cbytes = blosc2_compress (9 , 1 , cparams .typesize , src2 , size , dest , size + BLOSC2_MAX_OVERHEAD );
260
+ nbytes = blosc2_decompress (dest , size + BLOSC2_MAX_OVERHEAD , src , size );
261
+ mu_assert ("ERROR: nbytes is not correct" , nbytes == size );
262
+
263
+ /* Using Blosc1 interface */
264
+ cbytes = blosc1_compress (9 , 1 , cparams .typesize , size , src2 , dest , size + BLOSC2_MAX_OVERHEAD );
265
+ nbytes = blosc1_decompress (dest , src , size );
266
+ mu_assert ("ERROR: nbytes is not correct" , nbytes == size );
267
+
268
+ free (src2 );
269
+ blosc2_free_ctx (cctx );
270
+ blosc2_free_ctx (dctx );
271
+ return 0 ;
272
+ }
273
+
240
274
241
275
static char * all_tests (void ) {
242
276
mu_run_test (test_compressor );
@@ -248,6 +282,7 @@ static char *all_tests(void) {
248
282
mu_run_test (test_delta );
249
283
mu_run_test (test_typesize );
250
284
mu_run_test (test_small_blocksize );
285
+ mu_run_test (test_small_buffer );
251
286
252
287
return 0 ;
253
288
}
0 commit comments