zlib/test/example.c

547 lines
15 KiB
C
Raw Normal View History

2011-09-10 09:36:31 +04:00
/* example.c -- usage example of the zlib compression library
2016-12-31 22:41:31 +03:00
* Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly
2011-09-10 10:21:57 +04:00
* For conditions of distribution and use, see copyright notice in zlib.h
2011-09-10 09:36:31 +04:00
*/
2011-09-10 10:17:33 +04:00
/* @(#) $Id$ */
2011-09-10 09:36:31 +04:00
#include "zlib.h"
2011-09-10 10:25:27 +04:00
#include <stdio.h>
2011-09-10 09:36:31 +04:00
2011-09-10 10:03:14 +04:00
#ifdef STDC
# include <string.h>
2011-09-10 10:11:37 +04:00
# include <stdlib.h>
2011-09-10 10:03:14 +04:00
#endif
2011-09-10 10:20:29 +04:00
#if defined(VMS) || defined(RISCOS)
# define TESTFILE "foo-gz"
#else
# define TESTFILE "foo.gz"
#endif
2011-09-10 09:36:31 +04:00
#define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \
2011-09-10 10:08:07 +04:00
exit(1); \
2011-09-10 09:36:31 +04:00
} \
}
static z_const char hello[] = "hello, hello!";
2011-09-10 10:09:18 +04:00
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
2011-09-10 09:36:31 +04:00
static const char dictionary[] = "hello";
static uLong dictId; /* Adler32 value of the dictionary */
2011-09-10 10:14:39 +04:00
#ifdef Z_SOLO
static void *myalloc(void *q, unsigned n, unsigned m) {
(void)q;
return calloc(n, m);
}
static void myfree(void *q, void *p) {
(void)q;
free(p);
}
static alloc_func zalloc = myalloc;
static free_func zfree = myfree;
#else /* !Z_SOLO */
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;
2011-09-10 09:36:31 +04:00
/* ===========================================================================
* Test compress() and uncompress()
*/
static void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
2011-09-10 09:36:31 +04:00
int err;
2011-09-10 10:22:37 +04:00
uLong len = (uLong)strlen(hello)+1;
2011-09-10 09:36:31 +04:00
2011-09-10 10:14:39 +04:00
err = compress(compr, &comprLen, (const Bytef*)hello, len);
2011-09-10 09:36:31 +04:00
CHECK_ERR(err, "compress");
2011-09-10 10:03:14 +04:00
strcpy((char*)uncompr, "garbage");
2011-09-10 09:36:31 +04:00
err = uncompress(uncompr, &uncomprLen, compr, comprLen);
CHECK_ERR(err, "uncompress");
2011-09-10 10:03:14 +04:00
if (strcmp((char*)uncompr, hello)) {
2011-09-10 10:08:07 +04:00
fprintf(stderr, "bad uncompress\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 09:36:31 +04:00
} else {
2011-09-10 10:20:15 +04:00
printf("uncompress(): %s\n", (char *)uncompr);
2011-09-10 09:36:31 +04:00
}
}
/* ===========================================================================
* Test read/write of .gz files
*/
static void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
2011-09-10 10:22:48 +04:00
#ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else
2011-09-10 09:36:31 +04:00
int err;
2011-09-10 10:22:37 +04:00
int len = (int)strlen(hello)+1;
2011-09-10 09:36:31 +04:00
gzFile file;
2011-09-10 10:17:33 +04:00
z_off_t pos;
2011-09-10 09:36:31 +04:00
2011-09-10 10:22:37 +04:00
file = gzopen(fname, "wb");
2011-09-10 09:36:31 +04:00
if (file == NULL) {
2011-09-10 10:08:07 +04:00
fprintf(stderr, "gzopen error\n");
exit(1);
2011-09-10 09:36:31 +04:00
}
2011-09-10 10:18:57 +04:00
gzputc(file, 'h');
2011-09-10 10:19:21 +04:00
if (gzputs(file, "ello") != 4) {
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:19:21 +04:00
}
if (gzprintf(file, ", %s!", "hello") != 8) {
2011-09-10 10:17:33 +04:00
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 09:36:31 +04:00
}
2011-09-10 10:17:33 +04:00
gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
2011-09-10 09:36:31 +04:00
gzclose(file);
2011-09-10 10:22:37 +04:00
file = gzopen(fname, "rb");
2011-09-10 09:36:31 +04:00
if (file == NULL) {
2011-09-10 10:08:07 +04:00
fprintf(stderr, "gzopen error\n");
2011-09-10 10:22:37 +04:00
exit(1);
2011-09-10 09:36:31 +04:00
}
2011-09-10 10:03:14 +04:00
strcpy((char*)uncompr, "garbage");
2011-09-10 09:36:31 +04:00
2011-09-10 10:22:37 +04:00
if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
2011-09-10 10:08:07 +04:00
fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 09:36:31 +04:00
}
2011-09-10 10:03:14 +04:00
if (strcmp((char*)uncompr, hello)) {
2011-09-10 10:18:57 +04:00
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 09:36:31 +04:00
} else {
2011-09-10 10:22:37 +04:00
printf("gzread(): %s\n", (char*)uncompr);
2011-09-10 09:36:31 +04:00
}
2011-09-10 10:17:33 +04:00
2011-09-10 10:18:57 +04:00
pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) {
2011-09-10 10:21:57 +04:00
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
(long)pos, (long)gztell(file));
exit(1);
2011-09-10 10:17:33 +04:00
}
2011-09-10 10:18:57 +04:00
if (gzgetc(file) != ' ') {
2011-09-10 10:21:57 +04:00
fprintf(stderr, "gzgetc error\n");
exit(1);
2011-09-10 10:18:57 +04:00
}
2011-09-10 10:22:10 +04:00
if (gzungetc(' ', file) != ' ') {
fprintf(stderr, "gzungetc error\n");
exit(1);
}
2011-09-10 10:22:37 +04:00
gzgets(file, (char*)uncompr, (int)uncomprLen);
if (strlen((char*)uncompr) != 7) { /* " hello!" */
2011-09-10 10:19:21 +04:00
fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:17:33 +04:00
}
2011-09-10 10:22:37 +04:00
if (strcmp((char*)uncompr, hello + 6)) {
2011-09-10 10:19:21 +04:00
fprintf(stderr, "bad gzgets after gzseek\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:17:33 +04:00
} else {
2011-09-10 10:22:37 +04:00
printf("gzgets() after gzseek: %s\n", (char*)uncompr);
2011-09-10 10:17:33 +04:00
}
gzclose(file);
2011-09-10 10:22:48 +04:00
#endif
2011-09-10 09:36:31 +04:00
}
#endif /* Z_SOLO */
2011-09-10 09:36:31 +04:00
/* ===========================================================================
2011-09-10 10:03:14 +04:00
* Test deflate() with small buffers
2011-09-10 09:36:31 +04:00
*/
static void test_deflate(Byte *compr, uLong comprLen) {
2011-09-10 09:36:31 +04:00
z_stream c_stream; /* compression stream */
int err;
2011-09-10 10:22:37 +04:00
uLong len = (uLong)strlen(hello)+1;
2011-09-10 09:36:31 +04:00
c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
2011-09-10 10:11:37 +04:00
c_stream.opaque = (voidpf)0;
2011-09-10 09:36:31 +04:00
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
c_stream.next_in = (z_const unsigned char *)hello;
2011-09-10 09:36:31 +04:00
c_stream.next_out = compr;
2011-09-10 10:22:37 +04:00
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
2011-09-10 10:08:07 +04:00
c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
2011-09-10 09:36:31 +04:00
}
/* Finish the stream, still forcing small buffers: */
2011-09-10 10:03:14 +04:00
for (;;) {
2011-09-10 10:08:07 +04:00
c_stream.avail_out = 1;
err = deflate(&c_stream, Z_FINISH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "deflate");
2011-09-10 10:03:14 +04:00
}
2011-09-10 09:36:31 +04:00
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
}
/* ===========================================================================
* Test inflate() with small buffers
*/
static void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
2011-09-10 09:36:31 +04:00
int err;
z_stream d_stream; /* decompression stream */
2011-09-10 10:03:14 +04:00
strcpy((char*)uncompr, "garbage");
2011-09-10 09:36:31 +04:00
d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
2011-09-10 10:11:37 +04:00
d_stream.opaque = (voidpf)0;
2011-09-10 09:36:31 +04:00
d_stream.next_in = compr;
2011-09-10 10:17:33 +04:00
d_stream.avail_in = 0;
2011-09-10 09:36:31 +04:00
d_stream.next_out = uncompr;
2011-09-10 10:17:33 +04:00
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
2011-09-10 10:14:39 +04:00
while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
2011-09-10 10:08:07 +04:00
d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "inflate");
2011-09-10 09:36:31 +04:00
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
2011-09-10 10:03:14 +04:00
if (strcmp((char*)uncompr, hello)) {
2011-09-10 10:08:07 +04:00
fprintf(stderr, "bad inflate\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 09:36:31 +04:00
} else {
2011-09-10 10:20:15 +04:00
printf("inflate(): %s\n", (char *)uncompr);
2011-09-10 09:36:31 +04:00
}
}
2011-09-10 10:11:37 +04:00
/* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level
*/
static void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
2011-09-10 10:11:37 +04:00
z_stream c_stream; /* compression stream */
int err;
c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
2011-09-10 10:11:37 +04:00
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_SPEED);
CHECK_ERR(err, "deflateInit");
c_stream.next_out = compr;
2011-09-10 10:14:39 +04:00
c_stream.avail_out = (uInt)comprLen;
2011-09-10 10:11:37 +04:00
/* At this point, uncompr is still mostly zeroes, so it should compress
* very well:
*/
c_stream.next_in = uncompr;
c_stream.avail_in = (uInt)uncomprLen;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
if (c_stream.avail_in != 0) {
fprintf(stderr, "deflate not greedy\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:11:37 +04:00
}
/* Feed in already compressed data and switch to no compression: */
deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
c_stream.next_in = compr;
c_stream.avail_in = (uInt)uncomprLen/2;
2011-09-10 10:11:37 +04:00
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
/* Switch back to compressing mode: */
deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
c_stream.next_in = uncompr;
c_stream.avail_in = (uInt)uncomprLen;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:11:37 +04:00
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
}
/* ===========================================================================
* Test inflate() with large buffers
*/
static void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
2011-09-10 10:11:37 +04:00
int err;
z_stream d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage");
d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
2011-09-10 10:11:37 +04:00
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
d_stream.avail_in = (uInt)comprLen;
2011-09-10 10:17:33 +04:00
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
2011-09-10 10:11:37 +04:00
for (;;) {
d_stream.next_out = uncompr; /* discard the output */
2011-09-10 10:21:57 +04:00
d_stream.avail_out = (uInt)uncomprLen;
2011-09-10 10:11:37 +04:00
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "large inflate");
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) {
2011-09-10 10:11:37 +04:00
fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:11:37 +04:00
} else {
printf("large_inflate(): OK\n");
}
}
2011-09-10 10:06:52 +04:00
/* ===========================================================================
* Test deflate() with full flush
*/
static void test_flush(Byte *compr, uLong *comprLen) {
2011-09-10 10:06:52 +04:00
z_stream c_stream; /* compression stream */
int err;
2011-09-10 10:22:37 +04:00
uInt len = (uInt)strlen(hello)+1;
2011-09-10 10:06:52 +04:00
c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
2011-09-10 10:11:37 +04:00
c_stream.opaque = (voidpf)0;
2011-09-10 10:06:52 +04:00
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
c_stream.next_in = (z_const unsigned char *)hello;
2011-09-10 10:06:52 +04:00
c_stream.next_out = compr;
c_stream.avail_in = 3;
2011-09-10 10:18:57 +04:00
c_stream.avail_out = (uInt)*comprLen;
2011-09-10 10:06:52 +04:00
err = deflate(&c_stream, Z_FULL_FLUSH);
CHECK_ERR(err, "deflate");
compr[3]++; /* force an error in first compressed block */
c_stream.avail_in = len - 3;
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
2011-09-10 10:08:07 +04:00
CHECK_ERR(err, "deflate");
2011-09-10 10:06:52 +04:00
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
2011-09-10 10:18:57 +04:00
*comprLen = c_stream.total_out;
2011-09-10 10:06:52 +04:00
}
/* ===========================================================================
* Test inflateSync()
*/
static void test_sync(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
2011-09-10 10:06:52 +04:00
int err;
z_stream d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage");
d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
2011-09-10 10:11:37 +04:00
d_stream.opaque = (voidpf)0;
2011-09-10 10:06:52 +04:00
2011-09-10 10:17:33 +04:00
d_stream.next_in = compr;
d_stream.avail_in = 2; /* just read the zlib header */
2011-09-10 10:06:52 +04:00
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr;
2011-09-10 10:11:37 +04:00
d_stream.avail_out = (uInt)uncomprLen;
2011-09-10 10:06:52 +04:00
err = inflate(&d_stream, Z_NO_FLUSH);
2011-09-10 10:06:52 +04:00
CHECK_ERR(err, "inflate");
2011-09-10 10:14:39 +04:00
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
2011-09-10 10:11:37 +04:00
err = inflateSync(&d_stream); /* but skip the damaged part */
2011-09-10 10:06:52 +04:00
CHECK_ERR(err, "inflateSync");
err = inflate(&d_stream, Z_FINISH);
if (err != Z_STREAM_END) {
fprintf(stderr, "inflate should report Z_STREAM_END\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:06:52 +04:00
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
2011-09-10 10:20:15 +04:00
printf("after inflateSync(): hel%s\n", (char *)uncompr);
2011-09-10 10:06:52 +04:00
}
2011-09-10 10:14:39 +04:00
/* ===========================================================================
* Test deflate() with preset dictionary
*/
static void test_dict_deflate(Byte *compr, uLong comprLen) {
2011-09-10 10:14:39 +04:00
z_stream c_stream; /* compression stream */
int err;
c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
2011-09-10 10:14:39 +04:00
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
CHECK_ERR(err, "deflateInit");
err = deflateSetDictionary(&c_stream,
2011-09-11 22:04:49 +04:00
(const Bytef*)dictionary, (int)sizeof(dictionary));
2011-09-10 10:14:39 +04:00
CHECK_ERR(err, "deflateSetDictionary");
dictId = c_stream.adler;
c_stream.next_out = compr;
c_stream.avail_out = (uInt)comprLen;
c_stream.next_in = (z_const unsigned char *)hello;
2011-09-10 10:14:39 +04:00
c_stream.avail_in = (uInt)strlen(hello)+1;
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:14:39 +04:00
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
}
/* ===========================================================================
* Test inflate() with a preset dictionary
*/
static void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
2011-09-10 10:14:39 +04:00
int err;
z_stream d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage");
d_stream.zalloc = zalloc;
d_stream.zfree = zfree;
2011-09-10 10:14:39 +04:00
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
d_stream.avail_in = (uInt)comprLen;
2011-09-10 10:17:33 +04:00
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
2011-09-10 10:14:39 +04:00
d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen;
for (;;) {
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
2011-09-10 10:21:57 +04:00
if (err == Z_NEED_DICT) {
if (d_stream.adler != dictId) {
fprintf(stderr, "unexpected dictionary");
exit(1);
}
err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
2011-09-11 22:04:49 +04:00
(int)sizeof(dictionary));
2011-09-10 10:21:57 +04:00
}
2011-09-10 10:14:39 +04:00
CHECK_ERR(err, "inflate with dict");
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad inflate with dict\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:14:39 +04:00
} else {
2011-09-10 10:20:15 +04:00
printf("inflate with dictionary: %s\n", (char *)uncompr);
2011-09-10 10:14:39 +04:00
}
}
2011-09-10 09:36:31 +04:00
/* ===========================================================================
* Usage: example [output.gz [input.gz]]
*/
int main(int argc, char *argv[]) {
2011-09-10 10:14:39 +04:00
Byte *compr, *uncompr;
uLong uncomprLen = 20000;
uLong comprLen = 3 * uncomprLen;
2011-09-10 10:17:33 +04:00
static const char* myVersion = ZLIB_VERSION;
2011-09-10 09:36:31 +04:00
2011-09-10 10:17:33 +04:00
if (zlibVersion()[0] != myVersion[0]) {
2011-09-10 10:08:07 +04:00
fprintf(stderr, "incompatible zlib version\n");
exit(1);
2011-09-10 09:36:31 +04:00
2011-09-10 10:15:17 +04:00
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version linked: %s\n",
zlibVersion());
2011-09-10 09:36:31 +04:00
}
2011-09-10 10:11:37 +04:00
2011-09-10 10:22:21 +04:00
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
2011-09-10 10:22:10 +04:00
ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
2011-09-10 10:15:17 +04:00
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
/* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well.
*/
2011-09-10 10:11:37 +04:00
if (compr == Z_NULL || uncompr == Z_NULL) {
printf("out of memory\n");
2011-09-10 10:21:57 +04:00
exit(1);
2011-09-10 10:11:37 +04:00
}
#ifdef Z_SOLO
(void)argc;
(void)argv;
#else
2011-09-10 10:11:37 +04:00
test_compress(compr, comprLen, uncompr, uncomprLen);
2011-09-10 09:36:31 +04:00
2011-09-10 10:20:29 +04:00
test_gzio((argc > 1 ? argv[1] : TESTFILE),
2011-09-10 10:22:37 +04:00
uncompr, uncomprLen);
#endif
2011-09-10 10:11:37 +04:00
test_deflate(compr, comprLen);
test_inflate(compr, comprLen, uncompr, uncomprLen);
test_large_deflate(compr, comprLen, uncompr, uncomprLen);
test_large_inflate(compr, comprLen, uncompr, uncomprLen);
2011-09-10 09:36:31 +04:00
2011-09-10 10:18:57 +04:00
test_flush(compr, &comprLen);
2011-09-10 10:11:37 +04:00
test_sync(compr, comprLen, uncompr, uncomprLen);
comprLen = 3 * uncomprLen;
2011-09-10 09:36:31 +04:00
2011-09-10 10:14:39 +04:00
test_dict_deflate(compr, comprLen);
test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
2011-09-10 10:21:47 +04:00
free(compr);
free(uncompr);
2011-09-10 10:21:57 +04:00
return 0;
2011-09-10 09:36:31 +04:00
}