=========================================================================== * Test deflate() with preset dictionary */
(compr, comprLen)
| 455 | * Test deflate() with preset dictionary |
| 456 | */ |
| 457 | void test_dict_deflate(compr, comprLen) |
| 458 | Byte *compr; |
| 459 | uLong comprLen; |
| 460 | { |
| 461 | z_stream c_stream; /* compression stream */ |
| 462 | int err; |
| 463 | |
| 464 | c_stream.zalloc = zalloc; |
| 465 | c_stream.zfree = zfree; |
| 466 | c_stream.opaque = (voidpf)0; |
| 467 | |
| 468 | err = deflateInit(&c_stream, Z_BEST_COMPRESSION); |
| 469 | CHECK_ERR(err, "deflateInit"); |
| 470 | |
| 471 | err = deflateSetDictionary(&c_stream, |
| 472 | (const Bytef*)dictionary, (int)sizeof(dictionary)); |
| 473 | CHECK_ERR(err, "deflateSetDictionary"); |
| 474 | |
| 475 | dictId = c_stream.adler; |
| 476 | c_stream.next_out = compr; |
| 477 | c_stream.avail_out = (uInt)comprLen; |
| 478 | |
| 479 | c_stream.next_in = (z_const unsigned char *)hello; |
| 480 | c_stream.avail_in = (uInt)strlen(hello)+1; |
| 481 | |
| 482 | err = deflate(&c_stream, Z_FINISH); |
| 483 | if (err != Z_STREAM_END) { |
| 484 | fprintf(stderr, "deflate should report Z_STREAM_END\n"); |
| 485 | exit(1); |
| 486 | } |
| 487 | err = deflateEnd(&c_stream); |
| 488 | CHECK_ERR(err, "deflateEnd"); |
| 489 | } |
| 490 | |
| 491 | /* =========================================================================== |
| 492 | * Test inflate() with a preset dictionary |
no test coverage detected