=========================================================================== * Test deflate() with large buffers and dynamic change of compression level */
(compr, comprLen, uncompr, uncomprLen)
| 277 | * Test deflate() with large buffers and dynamic change of compression level |
| 278 | */ |
| 279 | void test_large_deflate(compr, comprLen, uncompr, uncomprLen) |
| 280 | Byte *compr, *uncompr; |
| 281 | uLong comprLen, uncomprLen; |
| 282 | { |
| 283 | z_stream c_stream; /* compression stream */ |
| 284 | int err; |
| 285 | |
| 286 | c_stream.zalloc = zalloc; |
| 287 | c_stream.zfree = zfree; |
| 288 | c_stream.opaque = (voidpf)0; |
| 289 | |
| 290 | err = deflateInit(&c_stream, Z_BEST_SPEED); |
| 291 | CHECK_ERR(err, "deflateInit"); |
| 292 | |
| 293 | c_stream.next_out = compr; |
| 294 | c_stream.avail_out = (uInt)comprLen; |
| 295 | |
| 296 | /* At this point, uncompr is still mostly zeroes, so it should compress |
| 297 | * very well: |
| 298 | */ |
| 299 | c_stream.next_in = uncompr; |
| 300 | c_stream.avail_in = (uInt)uncomprLen; |
| 301 | err = deflate(&c_stream, Z_NO_FLUSH); |
| 302 | CHECK_ERR(err, "deflate"); |
| 303 | if (c_stream.avail_in != 0) { |
| 304 | fprintf(stderr, "deflate not greedy\n"); |
| 305 | exit(1); |
| 306 | } |
| 307 | |
| 308 | /* Feed in already compressed data and switch to no compression: */ |
| 309 | deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); |
| 310 | c_stream.next_in = compr; |
| 311 | c_stream.avail_in = (uInt)comprLen/2; |
| 312 | err = deflate(&c_stream, Z_NO_FLUSH); |
| 313 | CHECK_ERR(err, "deflate"); |
| 314 | |
| 315 | /* Switch back to compressing mode: */ |
| 316 | deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); |
| 317 | c_stream.next_in = uncompr; |
| 318 | c_stream.avail_in = (uInt)uncomprLen; |
| 319 | err = deflate(&c_stream, Z_NO_FLUSH); |
| 320 | CHECK_ERR(err, "deflate"); |
| 321 | |
| 322 | err = deflate(&c_stream, Z_FINISH); |
| 323 | if (err != Z_STREAM_END) { |
| 324 | fprintf(stderr, "deflate should report Z_STREAM_END\n"); |
| 325 | exit(1); |
| 326 | } |
| 327 | err = deflateEnd(&c_stream); |
| 328 | CHECK_ERR(err, "deflateEnd"); |
| 329 | } |
| 330 | |
| 331 | /* =========================================================================== |
| 332 | * Test inflate() with large buffers |
no test coverage detected