MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_large_inflate

Function test_large_inflate

freebsd/contrib/zstd/zlibWrapper/examples/example.c:359–395  ·  view source on GitHub ↗

=========================================================================== * Test inflate() with large buffers */

(compr, comprLen, uncompr, uncomprLen)

Source from the content-addressed store, hash-verified

357 * Test inflate() with large buffers
358 */
359void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
360 Byte *compr, *uncompr;
361 uLong comprLen, uncomprLen;
362{
363 int err;
364 z_stream d_stream; /* decompression stream */
365
366 strcpy((char*)uncompr, "garbage");
367
368 d_stream.zalloc = zalloc;
369 d_stream.zfree = zfree;
370 d_stream.opaque = (voidpf)0;
371
372 d_stream.next_in = compr;
373 d_stream.avail_in = (uInt)comprLen;
374
375 err = inflateInit(&d_stream);
376 CHECK_ERR(err, "inflateInit");
377
378 for (;;) {
379 d_stream.next_out = uncompr; /* discard the output */
380 d_stream.avail_out = (uInt)uncomprLen;
381 err = inflate(&d_stream, Z_NO_FLUSH);
382 if (err == Z_STREAM_END) break;
383 CHECK_ERR(err, "large inflate");
384 }
385
386 err = inflateEnd(&d_stream);
387 CHECK_ERR(err, "inflateEnd");
388
389 if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
390 fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
391 exit(1);
392 } else {
393 printf("large_inflate(): OK\n");
394 }
395}
396
397/* ===========================================================================
398 * Test deflate() with full flush

Callers 1

mainFunction · 0.70

Calls 1

printfFunction · 0.50

Tested by

no test coverage detected