Chris@4: (* example.c -- usage example of the zlib compression library Chris@4: * Copyright (C) 1995-2003 Jean-loup Gailly. Chris@4: * For conditions of distribution and use, see copyright notice in zlib.h Chris@4: * Chris@4: * Pascal translation Chris@4: * Copyright (C) 1998 by Jacques Nomssi Nzali. Chris@4: * For conditions of distribution and use, see copyright notice in readme.txt Chris@4: * Chris@4: * Adaptation to the zlibpas interface Chris@4: * Copyright (C) 2003 by Cosmin Truta. Chris@4: * For conditions of distribution and use, see copyright notice in readme.txt Chris@4: *) Chris@4: Chris@4: program example; Chris@4: Chris@4: {$DEFINE TEST_COMPRESS} Chris@4: {DO NOT $DEFINE TEST_GZIO} Chris@4: {$DEFINE TEST_DEFLATE} Chris@4: {$DEFINE TEST_INFLATE} Chris@4: {$DEFINE TEST_FLUSH} Chris@4: {$DEFINE TEST_SYNC} Chris@4: {$DEFINE TEST_DICT} Chris@4: Chris@4: uses SysUtils, zlibpas; Chris@4: Chris@4: const TESTFILE = 'foo.gz'; Chris@4: Chris@4: (* "hello world" would be more standard, but the repeated "hello" Chris@4: * stresses the compression code better, sorry... Chris@4: *) Chris@4: const hello: PChar = 'hello, hello!'; Chris@4: Chris@4: const dictionary: PChar = 'hello'; Chris@4: Chris@4: var dictId: LongInt; (* Adler32 value of the dictionary *) Chris@4: Chris@4: procedure CHECK_ERR(err: Integer; msg: String); Chris@4: begin Chris@4: if err <> Z_OK then Chris@4: begin Chris@4: WriteLn(msg, ' error: ', err); Chris@4: Halt(1); Chris@4: end; Chris@4: end; Chris@4: Chris@4: procedure EXIT_ERR(const msg: String); Chris@4: begin Chris@4: WriteLn('Error: ', msg); Chris@4: Halt(1); Chris@4: end; Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test compress and uncompress Chris@4: *) Chris@4: {$IFDEF TEST_COMPRESS} Chris@4: procedure test_compress(compr: Pointer; comprLen: LongInt; Chris@4: uncompr: Pointer; uncomprLen: LongInt); Chris@4: var err: Integer; Chris@4: len: LongInt; Chris@4: begin Chris@4: len := StrLen(hello)+1; Chris@4: Chris@4: err := compress(compr, comprLen, hello, len); Chris@4: CHECK_ERR(err, 'compress'); Chris@4: Chris@4: StrCopy(PChar(uncompr), 'garbage'); Chris@4: Chris@4: err := uncompress(uncompr, uncomprLen, compr, comprLen); Chris@4: CHECK_ERR(err, 'uncompress'); Chris@4: Chris@4: if StrComp(PChar(uncompr), hello) <> 0 then Chris@4: EXIT_ERR('bad uncompress') Chris@4: else Chris@4: WriteLn('uncompress(): ', PChar(uncompr)); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test read/write of .gz files Chris@4: *) Chris@4: {$IFDEF TEST_GZIO} Chris@4: procedure test_gzio(const fname: PChar; (* compressed file name *) Chris@4: uncompr: Pointer; Chris@4: uncomprLen: LongInt); Chris@4: var err: Integer; Chris@4: len: Integer; Chris@4: zfile: gzFile; Chris@4: pos: LongInt; Chris@4: begin Chris@4: len := StrLen(hello)+1; Chris@4: Chris@4: zfile := gzopen(fname, 'wb'); Chris@4: if zfile = NIL then Chris@4: begin Chris@4: WriteLn('gzopen error'); Chris@4: Halt(1); Chris@4: end; Chris@4: gzputc(zfile, 'h'); Chris@4: if gzputs(zfile, 'ello') <> 4 then Chris@4: begin Chris@4: WriteLn('gzputs err: ', gzerror(zfile, err)); Chris@4: Halt(1); Chris@4: end; Chris@4: {$IFDEF GZ_FORMAT_STRING} Chris@4: if gzprintf(zfile, ', %s!', 'hello') <> 8 then Chris@4: begin Chris@4: WriteLn('gzprintf err: ', gzerror(zfile, err)); Chris@4: Halt(1); Chris@4: end; Chris@4: {$ELSE} Chris@4: if gzputs(zfile, ', hello!') <> 8 then Chris@4: begin Chris@4: WriteLn('gzputs err: ', gzerror(zfile, err)); Chris@4: Halt(1); Chris@4: end; Chris@4: {$ENDIF} Chris@4: gzseek(zfile, 1, SEEK_CUR); (* add one zero byte *) Chris@4: gzclose(zfile); Chris@4: Chris@4: zfile := gzopen(fname, 'rb'); Chris@4: if zfile = NIL then Chris@4: begin Chris@4: WriteLn('gzopen error'); Chris@4: Halt(1); Chris@4: end; Chris@4: Chris@4: StrCopy(PChar(uncompr), 'garbage'); Chris@4: Chris@4: if gzread(zfile, uncompr, uncomprLen) <> len then Chris@4: begin Chris@4: WriteLn('gzread err: ', gzerror(zfile, err)); Chris@4: Halt(1); Chris@4: end; Chris@4: if StrComp(PChar(uncompr), hello) <> 0 then Chris@4: begin Chris@4: WriteLn('bad gzread: ', PChar(uncompr)); Chris@4: Halt(1); Chris@4: end Chris@4: else Chris@4: WriteLn('gzread(): ', PChar(uncompr)); Chris@4: Chris@4: pos := gzseek(zfile, -8, SEEK_CUR); Chris@4: if (pos <> 6) or (gztell(zfile) <> pos) then Chris@4: begin Chris@4: WriteLn('gzseek error, pos=', pos, ', gztell=', gztell(zfile)); Chris@4: Halt(1); Chris@4: end; Chris@4: Chris@4: if gzgetc(zfile) <> ' ' then Chris@4: begin Chris@4: WriteLn('gzgetc error'); Chris@4: Halt(1); Chris@4: end; Chris@4: Chris@4: if gzungetc(' ', zfile) <> ' ' then Chris@4: begin Chris@4: WriteLn('gzungetc error'); Chris@4: Halt(1); Chris@4: end; Chris@4: Chris@4: gzgets(zfile, PChar(uncompr), uncomprLen); Chris@4: uncomprLen := StrLen(PChar(uncompr)); Chris@4: if uncomprLen <> 7 then (* " hello!" *) Chris@4: begin Chris@4: WriteLn('gzgets err after gzseek: ', gzerror(zfile, err)); Chris@4: Halt(1); Chris@4: end; Chris@4: if StrComp(PChar(uncompr), hello + 6) <> 0 then Chris@4: begin Chris@4: WriteLn('bad gzgets after gzseek'); Chris@4: Halt(1); Chris@4: end Chris@4: else Chris@4: WriteLn('gzgets() after gzseek: ', PChar(uncompr)); Chris@4: Chris@4: gzclose(zfile); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test deflate with small buffers Chris@4: *) Chris@4: {$IFDEF TEST_DEFLATE} Chris@4: procedure test_deflate(compr: Pointer; comprLen: LongInt); Chris@4: var c_stream: z_stream; (* compression stream *) Chris@4: err: Integer; Chris@4: len: LongInt; Chris@4: begin Chris@4: len := StrLen(hello)+1; Chris@4: Chris@4: c_stream.zalloc := NIL; Chris@4: c_stream.zfree := NIL; Chris@4: c_stream.opaque := NIL; Chris@4: Chris@4: err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); Chris@4: CHECK_ERR(err, 'deflateInit'); Chris@4: Chris@4: c_stream.next_in := hello; Chris@4: c_stream.next_out := compr; Chris@4: Chris@4: while (c_stream.total_in <> len) and Chris@4: (c_stream.total_out < comprLen) do Chris@4: begin Chris@4: c_stream.avail_out := 1; { force small buffers } Chris@4: c_stream.avail_in := 1; Chris@4: err := deflate(c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, 'deflate'); Chris@4: end; Chris@4: Chris@4: (* Finish the stream, still forcing small buffers: *) Chris@4: while TRUE do Chris@4: begin Chris@4: c_stream.avail_out := 1; Chris@4: err := deflate(c_stream, Z_FINISH); Chris@4: if err = Z_STREAM_END then Chris@4: break; Chris@4: CHECK_ERR(err, 'deflate'); Chris@4: end; Chris@4: Chris@4: err := deflateEnd(c_stream); Chris@4: CHECK_ERR(err, 'deflateEnd'); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test inflate with small buffers Chris@4: *) Chris@4: {$IFDEF TEST_INFLATE} Chris@4: procedure test_inflate(compr: Pointer; comprLen : LongInt; Chris@4: uncompr: Pointer; uncomprLen : LongInt); Chris@4: var err: Integer; Chris@4: d_stream: z_stream; (* decompression stream *) Chris@4: begin Chris@4: StrCopy(PChar(uncompr), 'garbage'); Chris@4: Chris@4: d_stream.zalloc := NIL; Chris@4: d_stream.zfree := NIL; Chris@4: d_stream.opaque := NIL; Chris@4: Chris@4: d_stream.next_in := compr; Chris@4: d_stream.avail_in := 0; Chris@4: d_stream.next_out := uncompr; Chris@4: Chris@4: err := inflateInit(d_stream); Chris@4: CHECK_ERR(err, 'inflateInit'); Chris@4: Chris@4: while (d_stream.total_out < uncomprLen) and Chris@4: (d_stream.total_in < comprLen) do Chris@4: begin Chris@4: d_stream.avail_out := 1; (* force small buffers *) Chris@4: d_stream.avail_in := 1; Chris@4: err := inflate(d_stream, Z_NO_FLUSH); Chris@4: if err = Z_STREAM_END then Chris@4: break; Chris@4: CHECK_ERR(err, 'inflate'); Chris@4: end; Chris@4: Chris@4: err := inflateEnd(d_stream); Chris@4: CHECK_ERR(err, 'inflateEnd'); Chris@4: Chris@4: if StrComp(PChar(uncompr), hello) <> 0 then Chris@4: EXIT_ERR('bad inflate') Chris@4: else Chris@4: WriteLn('inflate(): ', PChar(uncompr)); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test deflate with large buffers and dynamic change of compression level Chris@4: *) Chris@4: {$IFDEF TEST_DEFLATE} Chris@4: procedure test_large_deflate(compr: Pointer; comprLen: LongInt; Chris@4: uncompr: Pointer; uncomprLen: LongInt); Chris@4: var c_stream: z_stream; (* compression stream *) Chris@4: err: Integer; Chris@4: begin Chris@4: c_stream.zalloc := NIL; Chris@4: c_stream.zfree := NIL; Chris@4: c_stream.opaque := NIL; Chris@4: Chris@4: err := deflateInit(c_stream, Z_BEST_SPEED); Chris@4: CHECK_ERR(err, 'deflateInit'); Chris@4: Chris@4: c_stream.next_out := compr; Chris@4: c_stream.avail_out := Integer(comprLen); Chris@4: Chris@4: (* At this point, uncompr is still mostly zeroes, so it should compress Chris@4: * very well: Chris@4: *) Chris@4: c_stream.next_in := uncompr; Chris@4: c_stream.avail_in := Integer(uncomprLen); Chris@4: err := deflate(c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, 'deflate'); Chris@4: if c_stream.avail_in <> 0 then Chris@4: EXIT_ERR('deflate not greedy'); Chris@4: Chris@4: (* Feed in already compressed data and switch to no compression: *) Chris@4: deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); Chris@4: c_stream.next_in := compr; Chris@4: c_stream.avail_in := Integer(comprLen div 2); Chris@4: err := deflate(c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, 'deflate'); Chris@4: Chris@4: (* Switch back to compressing mode: *) Chris@4: deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED); Chris@4: c_stream.next_in := uncompr; Chris@4: c_stream.avail_in := Integer(uncomprLen); Chris@4: err := deflate(c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, 'deflate'); Chris@4: Chris@4: err := deflate(c_stream, Z_FINISH); Chris@4: if err <> Z_STREAM_END then Chris@4: EXIT_ERR('deflate should report Z_STREAM_END'); Chris@4: Chris@4: err := deflateEnd(c_stream); Chris@4: CHECK_ERR(err, 'deflateEnd'); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test inflate with large buffers Chris@4: *) Chris@4: {$IFDEF TEST_INFLATE} Chris@4: procedure test_large_inflate(compr: Pointer; comprLen: LongInt; Chris@4: uncompr: Pointer; uncomprLen: LongInt); Chris@4: var err: Integer; Chris@4: d_stream: z_stream; (* decompression stream *) Chris@4: begin Chris@4: StrCopy(PChar(uncompr), 'garbage'); Chris@4: Chris@4: d_stream.zalloc := NIL; Chris@4: d_stream.zfree := NIL; Chris@4: d_stream.opaque := NIL; Chris@4: Chris@4: d_stream.next_in := compr; Chris@4: d_stream.avail_in := Integer(comprLen); Chris@4: Chris@4: err := inflateInit(d_stream); Chris@4: CHECK_ERR(err, 'inflateInit'); Chris@4: Chris@4: while TRUE do Chris@4: begin Chris@4: d_stream.next_out := uncompr; (* discard the output *) Chris@4: d_stream.avail_out := Integer(uncomprLen); Chris@4: err := inflate(d_stream, Z_NO_FLUSH); Chris@4: if err = Z_STREAM_END then Chris@4: break; Chris@4: CHECK_ERR(err, 'large inflate'); Chris@4: end; Chris@4: Chris@4: err := inflateEnd(d_stream); Chris@4: CHECK_ERR(err, 'inflateEnd'); Chris@4: Chris@4: if d_stream.total_out <> 2 * uncomprLen + comprLen div 2 then Chris@4: begin Chris@4: WriteLn('bad large inflate: ', d_stream.total_out); Chris@4: Halt(1); Chris@4: end Chris@4: else Chris@4: WriteLn('large_inflate(): OK'); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test deflate with full flush Chris@4: *) Chris@4: {$IFDEF TEST_FLUSH} Chris@4: procedure test_flush(compr: Pointer; var comprLen : LongInt); Chris@4: var c_stream: z_stream; (* compression stream *) Chris@4: err: Integer; Chris@4: len: Integer; Chris@4: begin Chris@4: len := StrLen(hello)+1; Chris@4: Chris@4: c_stream.zalloc := NIL; Chris@4: c_stream.zfree := NIL; Chris@4: c_stream.opaque := NIL; Chris@4: Chris@4: err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); Chris@4: CHECK_ERR(err, 'deflateInit'); Chris@4: Chris@4: c_stream.next_in := hello; Chris@4: c_stream.next_out := compr; Chris@4: c_stream.avail_in := 3; Chris@4: c_stream.avail_out := Integer(comprLen); Chris@4: err := deflate(c_stream, Z_FULL_FLUSH); Chris@4: CHECK_ERR(err, 'deflate'); Chris@4: Chris@4: Inc(PByteArray(compr)^[3]); (* force an error in first compressed block *) Chris@4: c_stream.avail_in := len - 3; Chris@4: Chris@4: err := deflate(c_stream, Z_FINISH); Chris@4: if err <> Z_STREAM_END then Chris@4: CHECK_ERR(err, 'deflate'); Chris@4: Chris@4: err := deflateEnd(c_stream); Chris@4: CHECK_ERR(err, 'deflateEnd'); Chris@4: Chris@4: comprLen := c_stream.total_out; Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test inflateSync() Chris@4: *) Chris@4: {$IFDEF TEST_SYNC} Chris@4: procedure test_sync(compr: Pointer; comprLen: LongInt; Chris@4: uncompr: Pointer; uncomprLen : LongInt); Chris@4: var err: Integer; Chris@4: d_stream: z_stream; (* decompression stream *) Chris@4: begin Chris@4: StrCopy(PChar(uncompr), 'garbage'); Chris@4: Chris@4: d_stream.zalloc := NIL; Chris@4: d_stream.zfree := NIL; Chris@4: d_stream.opaque := NIL; Chris@4: Chris@4: d_stream.next_in := compr; Chris@4: d_stream.avail_in := 2; (* just read the zlib header *) Chris@4: Chris@4: err := inflateInit(d_stream); Chris@4: CHECK_ERR(err, 'inflateInit'); Chris@4: Chris@4: d_stream.next_out := uncompr; Chris@4: d_stream.avail_out := Integer(uncomprLen); Chris@4: Chris@4: inflate(d_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, 'inflate'); Chris@4: Chris@4: d_stream.avail_in := Integer(comprLen-2); (* read all compressed data *) Chris@4: err := inflateSync(d_stream); (* but skip the damaged part *) Chris@4: CHECK_ERR(err, 'inflateSync'); Chris@4: Chris@4: err := inflate(d_stream, Z_FINISH); Chris@4: if err <> Z_DATA_ERROR then Chris@4: EXIT_ERR('inflate should report DATA_ERROR'); Chris@4: (* Because of incorrect adler32 *) Chris@4: Chris@4: err := inflateEnd(d_stream); Chris@4: CHECK_ERR(err, 'inflateEnd'); Chris@4: Chris@4: WriteLn('after inflateSync(): hel', PChar(uncompr)); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test deflate with preset dictionary Chris@4: *) Chris@4: {$IFDEF TEST_DICT} Chris@4: procedure test_dict_deflate(compr: Pointer; comprLen: LongInt); Chris@4: var c_stream: z_stream; (* compression stream *) Chris@4: err: Integer; Chris@4: begin Chris@4: c_stream.zalloc := NIL; Chris@4: c_stream.zfree := NIL; Chris@4: c_stream.opaque := NIL; Chris@4: Chris@4: err := deflateInit(c_stream, Z_BEST_COMPRESSION); Chris@4: CHECK_ERR(err, 'deflateInit'); Chris@4: Chris@4: err := deflateSetDictionary(c_stream, dictionary, StrLen(dictionary)); Chris@4: CHECK_ERR(err, 'deflateSetDictionary'); Chris@4: Chris@4: dictId := c_stream.adler; Chris@4: c_stream.next_out := compr; Chris@4: c_stream.avail_out := Integer(comprLen); Chris@4: Chris@4: c_stream.next_in := hello; Chris@4: c_stream.avail_in := StrLen(hello)+1; Chris@4: Chris@4: err := deflate(c_stream, Z_FINISH); Chris@4: if err <> Z_STREAM_END then Chris@4: EXIT_ERR('deflate should report Z_STREAM_END'); Chris@4: Chris@4: err := deflateEnd(c_stream); Chris@4: CHECK_ERR(err, 'deflateEnd'); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: (* =========================================================================== Chris@4: * Test inflate with a preset dictionary Chris@4: *) Chris@4: {$IFDEF TEST_DICT} Chris@4: procedure test_dict_inflate(compr: Pointer; comprLen: LongInt; Chris@4: uncompr: Pointer; uncomprLen: LongInt); Chris@4: var err: Integer; Chris@4: d_stream: z_stream; (* decompression stream *) Chris@4: begin Chris@4: StrCopy(PChar(uncompr), 'garbage'); Chris@4: Chris@4: d_stream.zalloc := NIL; Chris@4: d_stream.zfree := NIL; Chris@4: d_stream.opaque := NIL; Chris@4: Chris@4: d_stream.next_in := compr; Chris@4: d_stream.avail_in := Integer(comprLen); Chris@4: Chris@4: err := inflateInit(d_stream); Chris@4: CHECK_ERR(err, 'inflateInit'); Chris@4: Chris@4: d_stream.next_out := uncompr; Chris@4: d_stream.avail_out := Integer(uncomprLen); Chris@4: Chris@4: while TRUE do Chris@4: begin Chris@4: err := inflate(d_stream, Z_NO_FLUSH); Chris@4: if err = Z_STREAM_END then Chris@4: break; Chris@4: if err = Z_NEED_DICT then Chris@4: begin Chris@4: if d_stream.adler <> dictId then Chris@4: EXIT_ERR('unexpected dictionary'); Chris@4: err := inflateSetDictionary(d_stream, dictionary, StrLen(dictionary)); Chris@4: end; Chris@4: CHECK_ERR(err, 'inflate with dict'); Chris@4: end; Chris@4: Chris@4: err := inflateEnd(d_stream); Chris@4: CHECK_ERR(err, 'inflateEnd'); Chris@4: Chris@4: if StrComp(PChar(uncompr), hello) <> 0 then Chris@4: EXIT_ERR('bad inflate with dict') Chris@4: else Chris@4: WriteLn('inflate with dictionary: ', PChar(uncompr)); Chris@4: end; Chris@4: {$ENDIF} Chris@4: Chris@4: var compr, uncompr: Pointer; Chris@4: comprLen, uncomprLen: LongInt; Chris@4: Chris@4: begin Chris@4: if zlibVersion^ <> ZLIB_VERSION[1] then Chris@4: EXIT_ERR('Incompatible zlib version'); Chris@4: Chris@4: WriteLn('zlib version: ', zlibVersion); Chris@4: WriteLn('zlib compile flags: ', Format('0x%x', [zlibCompileFlags])); Chris@4: Chris@4: comprLen := 10000 * SizeOf(Integer); (* don't overflow on MSDOS *) Chris@4: uncomprLen := comprLen; Chris@4: GetMem(compr, comprLen); Chris@4: GetMem(uncompr, uncomprLen); Chris@4: if (compr = NIL) or (uncompr = NIL) then Chris@4: EXIT_ERR('Out of memory'); Chris@4: (* compr and uncompr are cleared to avoid reading uninitialized Chris@4: * data and to ensure that uncompr compresses well. Chris@4: *) Chris@4: FillChar(compr^, comprLen, 0); Chris@4: FillChar(uncompr^, uncomprLen, 0); Chris@4: Chris@4: {$IFDEF TEST_COMPRESS} Chris@4: WriteLn('** Testing compress'); Chris@4: test_compress(compr, comprLen, uncompr, uncomprLen); Chris@4: {$ENDIF} Chris@4: Chris@4: {$IFDEF TEST_GZIO} Chris@4: WriteLn('** Testing gzio'); Chris@4: if ParamCount >= 1 then Chris@4: test_gzio(ParamStr(1), uncompr, uncomprLen) Chris@4: else Chris@4: test_gzio(TESTFILE, uncompr, uncomprLen); Chris@4: {$ENDIF} Chris@4: Chris@4: {$IFDEF TEST_DEFLATE} Chris@4: WriteLn('** Testing deflate with small buffers'); Chris@4: test_deflate(compr, comprLen); Chris@4: {$ENDIF} Chris@4: {$IFDEF TEST_INFLATE} Chris@4: WriteLn('** Testing inflate with small buffers'); Chris@4: test_inflate(compr, comprLen, uncompr, uncomprLen); Chris@4: {$ENDIF} Chris@4: Chris@4: {$IFDEF TEST_DEFLATE} Chris@4: WriteLn('** Testing deflate with large buffers'); Chris@4: test_large_deflate(compr, comprLen, uncompr, uncomprLen); Chris@4: {$ENDIF} Chris@4: {$IFDEF TEST_INFLATE} Chris@4: WriteLn('** Testing inflate with large buffers'); Chris@4: test_large_inflate(compr, comprLen, uncompr, uncomprLen); Chris@4: {$ENDIF} Chris@4: Chris@4: {$IFDEF TEST_FLUSH} Chris@4: WriteLn('** Testing deflate with full flush'); Chris@4: test_flush(compr, comprLen); Chris@4: {$ENDIF} Chris@4: {$IFDEF TEST_SYNC} Chris@4: WriteLn('** Testing inflateSync'); Chris@4: test_sync(compr, comprLen, uncompr, uncomprLen); Chris@4: {$ENDIF} Chris@4: comprLen := uncomprLen; Chris@4: Chris@4: {$IFDEF TEST_DICT} Chris@4: WriteLn('** Testing deflate and inflate with preset dictionary'); Chris@4: test_dict_deflate(compr, comprLen); Chris@4: test_dict_inflate(compr, comprLen, uncompr, uncomprLen); Chris@4: {$ENDIF} Chris@4: Chris@4: FreeMem(compr, comprLen); Chris@4: FreeMem(uncompr, uncomprLen); Chris@4: end.