=========================================================================== * Test deflate() with full flush */
(compr, comprLen)
| 373 | * Test deflate() with full flush |
| 374 | */ |
| 375 | void test_flush(compr, comprLen) |
| 376 | Byte *compr; |
| 377 | uLong *comprLen; |
| 378 | { |
| 379 | z_stream c_stream; /* compression stream */ |
| 380 | int err; |
| 381 | uInt len = (uInt)strlen(hello)+1; |
| 382 | |
| 383 | c_stream.zalloc = zalloc; |
| 384 | c_stream.zfree = zfree; |
| 385 | c_stream.opaque = (voidpf)0; |
| 386 | |
| 387 | err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); |
| 388 | CHECK_ERR(err, "deflateInit"); |
| 389 | |
| 390 | c_stream.next_in = (z_const unsigned char *)hello; |
| 391 | c_stream.next_out = compr; |
| 392 | c_stream.avail_in = 3; |
| 393 | c_stream.avail_out = (uInt)*comprLen; |
| 394 | err = deflate(&c_stream, Z_FULL_FLUSH); |
| 395 | CHECK_ERR(err, "deflate"); |
| 396 | |
| 397 | compr[3]++; /* force an error in first compressed block */ |
| 398 | c_stream.avail_in = len - 3; |
| 399 | |
| 400 | err = deflate(&c_stream, Z_FINISH); |
| 401 | if (err != Z_STREAM_END) { |
| 402 | CHECK_ERR(err, "deflate"); |
| 403 | } |
| 404 | err = deflateEnd(&c_stream); |
| 405 | CHECK_ERR(err, "deflateEnd"); |
| 406 | |
| 407 | *comprLen = c_stream.total_out; |
| 408 | } |
| 409 | |
| 410 | /* =========================================================================== |
| 411 | * Test inflateSync() |
no test coverage detected