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

Function test_deflate

freebsd/contrib/zlib/test/example.c:200–233  ·  view source on GitHub ↗

=========================================================================== * Test deflate() with small buffers */

(compr, comprLen)

Source from the content-addressed store, hash-verified

198 * Test deflate() with small buffers
199 */
200void 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

Callers 1

mainFunction · 0.70

Calls 2

deflateFunction · 0.85
deflateEndFunction · 0.85

Tested by

no test coverage detected