=========================================================================== * Test deflate() with small buffers */
(compr, comprLen)
| 198 | * Test deflate() with small buffers |
| 199 | */ |
| 200 | void test_deflate(compr, comprLen) |
| 201 | Byte *compr; |
| 202 | uLong comprLen; |
| 203 | { |
| 204 | z_stream c_stream; /* compression stream */ |
| 205 | int err; |
| 206 | uLong len = (uLong)strlen(hello)+1; |
| 207 | |
| 208 | c_stream.zalloc = zalloc; |
| 209 | c_stream.zfree = zfree; |
| 210 | c_stream.opaque = (voidpf)0; |
| 211 | |
| 212 | err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); |
| 213 | CHECK_ERR(err, "deflateInit"); |
| 214 | |
| 215 | c_stream.next_in = (z_const unsigned char *)hello; |
| 216 | c_stream.next_out = compr; |
| 217 | |
| 218 | while (c_stream.total_in != len && c_stream.total_out < comprLen) { |
| 219 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ |
| 220 | err = deflate(&c_stream, Z_NO_FLUSH); |
| 221 | CHECK_ERR(err, "deflate"); |
| 222 | } |
| 223 | /* Finish the stream, still forcing small buffers: */ |
| 224 | for (;;) { |
| 225 | c_stream.avail_out = 1; |
| 226 | err = deflate(&c_stream, Z_FINISH); |
| 227 | if (err == Z_STREAM_END) break; |
| 228 | CHECK_ERR(err, "deflate"); |
| 229 | } |
| 230 | |
| 231 | err = deflateEnd(&c_stream); |
| 232 | CHECK_ERR(err, "deflateEnd"); |
| 233 | } |
| 234 | |
| 235 | /* =========================================================================== |
| 236 | * Test inflate() with small buffers |
no test coverage detected