example.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. program example;
  2. { example.c -- usage example of the zlib compression library
  3. Copyright (C) 1995-1998 Jean-loup Gailly.
  4. Pascal tranlastion
  5. Copyright (C) 1998 by Jacques Nomssi Nzali
  6. For conditions of distribution and use, see copyright notice in readme.txt
  7. }
  8. {-$define MemCheck}
  9. {$IFNDEF FPC}
  10. {$DEFINE TEST_COMPRESS}
  11. {$ENDIF}
  12. {$DEFINE TEST_GZIO}
  13. {$DEFINE TEST_INFLATE}
  14. {$DEFINE TEST_DEFLATE}
  15. {$DEFINE TEST_SYNC}
  16. {$DEFINE TEST_DICT}
  17. {$DEFINE TEST_FLUSH}
  18. uses
  19. {$ifdef ver80}
  20. WinCrt,
  21. {$endif}
  22. strings,
  23. {$ifndef MSDOS}
  24. SysUtils,
  25. {$endif}
  26. zutil,
  27. zbase,
  28. gzIo,
  29. zInflate,
  30. zDeflate,
  31. zCompres,
  32. zUnCompr
  33. {$ifdef MemCheck}
  34. , MemCheck in '..\..\monotekt\pas\memcheck\memcheck.pas'
  35. {$endif}
  36. ;
  37. procedure Stop;
  38. begin
  39. Write('Program halted...');
  40. ReadLn;
  41. Halt(1);
  42. end;
  43. procedure CHECK_ERR(err : int; msg : string);
  44. begin
  45. if (err <> Z_OK) then
  46. begin
  47. Write(msg, ' error: ', err);
  48. Stop;
  49. end;
  50. end;
  51. const
  52. hello : PChar = 'hello, hello!';
  53. { "hello world" would be more standard, but the repeated "hello"
  54. stresses the compression code better, sorry... }
  55. {$IFDEF TEST_DICT}
  56. const
  57. dictionary : PChar = 'hello';
  58. var
  59. dictId : uLong; { Adler32 value of the dictionary }
  60. {$ENDIF}
  61. { ===========================================================================
  62. Test compress() and uncompress() }
  63. {$IFDEF TEST_COMPRESS}
  64. procedure test_compress(compr : pBytef; var comprLen : uLong;
  65. uncompr : pBytef; uncomprLen : uLong);
  66. var
  67. err : int;
  68. len : uLong;
  69. begin
  70. len := strlen(hello)+1;
  71. err := compress(compr, comprLen, pBytef(hello)^, len);
  72. CHECK_ERR(err, 'compress');
  73. strcopy(PChar(uncompr), 'garbage');
  74. err := uncompress(uncompr, uncomprLen, compr^, comprLen);
  75. CHECK_ERR(err, 'uncompress');
  76. if (strcomp(PChar(uncompr), hello)) <> 0 then
  77. begin
  78. WriteLn('bad uncompress');
  79. Stop;
  80. end
  81. else
  82. WriteLn('uncompress(): ', StrPas(PChar(uncompr)));
  83. end;
  84. {$ENDIF}
  85. { ===========================================================================
  86. Test read/write of .gz files }
  87. {$IFDEF TEST_GZIO}
  88. procedure test_gzio(const outf : string; { output file }
  89. const inf : string; { input file }
  90. uncompr : pBytef;
  91. uncomprLen : int);
  92. var
  93. err : int;
  94. len : int;
  95. var
  96. zfile : gzFile;
  97. pos : z_off_t;
  98. begin
  99. len := strlen(hello)+1;
  100. zfile := gzopen(outf, 'w');
  101. if (zfile = NIL) then
  102. begin
  103. WriteLn('_gzopen error');
  104. Stop;
  105. end;
  106. gzputc(zfile, 'h');
  107. if (gzputs(zfile, 'ello') <> 4) then
  108. begin
  109. WriteLn('gzputs err: ', gzerror(zfile, err));
  110. Stop;
  111. end;
  112. {$ifdef GZ_FORMAT_STRING}
  113. if (gzprintf(zfile, ', %s!', 'hello') <> 8) then
  114. begin
  115. WriteLn('gzprintf err: ', gzerror(zfile, err));
  116. Stop;
  117. end;
  118. {$else}
  119. if (gzputs(zfile, ', hello!') <> 8) then
  120. begin
  121. WriteLn('gzputs err: ', gzerror(zfile, err));
  122. Stop;
  123. end;
  124. {$ENDIF}
  125. gzseek(zfile, Long(1), SEEK_CUR); { add one zero byte }
  126. gzclose(zfile);
  127. zfile := gzopen(inf, 'r');
  128. if (zfile = NIL) then
  129. WriteLn('gzopen error');
  130. strcopy(pchar(uncompr), 'garbage');
  131. uncomprLen := gzread(zfile, uncompr, uInt(uncomprLen));
  132. if (uncomprLen <> len) then
  133. begin
  134. WriteLn('gzread err: ', gzerror(zfile, err));
  135. Stop;
  136. end;
  137. if (strcomp(pchar(uncompr), hello)) <> 0 then
  138. begin
  139. WriteLn('bad gzread: ', pchar(uncompr));
  140. Stop;
  141. end
  142. else
  143. WriteLn('gzread(): ', pchar(uncompr));
  144. pos := gzseek(zfile, Long(-8), SEEK_CUR);
  145. if (pos <> 6) or (gztell(zfile) <> pos) then
  146. begin
  147. WriteLn('gzseek error, pos=',pos,', gztell=',gztell(zfile));
  148. Stop;
  149. end;
  150. if (char(gzgetc(zfile)) <> ' ') then
  151. begin
  152. WriteLn('gzgetc error');
  153. Stop;
  154. end;
  155. gzgets(zfile, pchar(uncompr), uncomprLen);
  156. uncomprLen := strlen(pchar(uncompr));
  157. if (uncomprLen <> 6) then
  158. begin { "hello!" }
  159. WriteLn('gzgets err after gzseek: ', gzerror(zfile, err));
  160. Stop;
  161. end;
  162. if (strcomp(pchar(uncompr), hello+7)) <> 0 then
  163. begin
  164. WriteLn('bad gzgets after gzseek');
  165. Stop;
  166. end
  167. else
  168. WriteLn('gzgets() after gzseek: ', PChar(uncompr));
  169. gzclose(zfile);
  170. end;
  171. {$ENDIF}
  172. { ===========================================================================
  173. Test deflate() with small buffers }
  174. {$IFDEF TEST_DEFLATE}
  175. procedure test_deflate(compr : pBytef; comprLen : uLong);
  176. var
  177. c_stream : z_stream; { compression stream }
  178. err : int;
  179. len : int;
  180. begin
  181. len := strlen(hello)+1;
  182. c_stream.zalloc := NIL; {alloc_func(0);}
  183. c_stream.zfree := NIL; {free_func(0);}
  184. c_stream.opaque := NIL; {voidpf(0);}
  185. err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
  186. CHECK_ERR(err, 'deflateInit');
  187. c_stream.next_in := pBytef(hello);
  188. c_stream.next_out := compr;
  189. while (c_stream.total_in <> uLong(len)) and (c_stream.total_out < comprLen) do
  190. begin
  191. c_stream.avail_out := 1; { force small buffers }
  192. c_stream.avail_in := 1;
  193. err := deflate(c_stream, Z_NO_FLUSH);
  194. CHECK_ERR(err, 'deflate');
  195. end;
  196. { Finish the stream, still forcing small buffers: }
  197. while TRUE do
  198. begin
  199. c_stream.avail_out := 1;
  200. err := deflate(c_stream, Z_FINISH);
  201. if (err = Z_STREAM_END) then
  202. break;
  203. CHECK_ERR(err, 'deflate');
  204. end;
  205. err := deflateEnd(c_stream);
  206. CHECK_ERR(err, 'deflateEnd');
  207. end;
  208. {$ENDIF}
  209. { ===========================================================================
  210. Test inflate() with small buffers
  211. }
  212. {$IFDEF TEST_INFLATE}
  213. procedure test_inflate(compr : pBytef; comprLen : uLong;
  214. uncompr : pBytef; uncomprLen : uLong);
  215. var
  216. err : int;
  217. d_stream : z_stream; { decompression stream }
  218. begin
  219. strcopy(PChar(uncompr), 'garbage');
  220. d_stream.zalloc := NIL; {alloc_func(0);}
  221. d_stream.zfree := NIL; {free_func(0);}
  222. d_stream.opaque := NIL; {voidpf(0);}
  223. d_stream.next_in := compr;
  224. d_stream.avail_in := 0;
  225. d_stream.next_out := uncompr;
  226. err := inflateInit(d_stream);
  227. CHECK_ERR(err, 'inflateInit');
  228. while (d_stream.total_out < uncomprLen) and
  229. (d_stream.total_in < comprLen) do
  230. begin
  231. d_stream.avail_out := 1; { force small buffers }
  232. d_stream.avail_in := 1;
  233. err := inflate(d_stream, Z_NO_FLUSH);
  234. if (err = Z_STREAM_END) then
  235. break;
  236. CHECK_ERR(err, 'inflate');
  237. end;
  238. err := inflateEnd(d_stream);
  239. CHECK_ERR(err, 'inflateEnd');
  240. if (strcomp(PChar(uncompr), hello) <> 0) then
  241. begin
  242. WriteLn('bad inflate');
  243. exit;
  244. end
  245. else
  246. begin
  247. WriteLn('inflate(): ', StrPas(PChar(uncompr)));
  248. end;
  249. end;
  250. {$ENDIF}
  251. { ===========================================================================
  252. Test deflate() with large buffers and dynamic change of compression level
  253. }
  254. {$IFDEF TEST_DEFLATE}
  255. procedure test_large_deflate(compr : pBytef; comprLen : uLong;
  256. uncompr : pBytef; uncomprLen : uLong);
  257. var
  258. c_stream : z_stream; { compression stream }
  259. err : int;
  260. begin
  261. c_stream.zalloc := NIL; {alloc_func(0);}
  262. c_stream.zfree := NIL; {free_func(0);}
  263. c_stream.opaque := NIL; {voidpf(0);}
  264. err := deflateInit(c_stream, Z_BEST_SPEED);
  265. CHECK_ERR(err, 'deflateInit');
  266. c_stream.next_out := compr;
  267. c_stream.avail_out := uInt(comprLen);
  268. { At this point, uncompr is still mostly zeroes, so it should compress
  269. very well: }
  270. c_stream.next_in := uncompr;
  271. c_stream.avail_in := uInt(uncomprLen);
  272. err := deflate(c_stream, Z_NO_FLUSH);
  273. CHECK_ERR(err, 'deflate');
  274. if (c_stream.avail_in <> 0) then
  275. begin
  276. WriteLn('deflate not greedy');
  277. exit;
  278. end;
  279. { Feed in already compressed data and switch to no compression: }
  280. deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
  281. c_stream.next_in := compr;
  282. c_stream.avail_in := uInt(comprLen div 2);
  283. err := deflate(c_stream, Z_NO_FLUSH);
  284. CHECK_ERR(err, 'deflate');
  285. { Switch back to compressing mode: }
  286. deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
  287. c_stream.next_in := uncompr;
  288. c_stream.avail_in := uInt(uncomprLen);
  289. err := deflate(c_stream, Z_NO_FLUSH);
  290. CHECK_ERR(err, 'deflate');
  291. err := deflate(c_stream, Z_FINISH);
  292. if (err <> Z_STREAM_END) then
  293. begin
  294. WriteLn('deflate should report Z_STREAM_END');
  295. exit;
  296. end;
  297. err := deflateEnd(c_stream);
  298. CHECK_ERR(err, 'deflateEnd');
  299. end;
  300. {$ENDIF}
  301. { ===========================================================================
  302. Test inflate() with large buffers }
  303. {$IFDEF TEST_INFLATE}
  304. procedure test_large_inflate(compr : pBytef; comprLen : uLong;
  305. uncompr : pBytef; uncomprLen : uLong);
  306. var
  307. err : int;
  308. d_stream : z_stream; { decompression stream }
  309. begin
  310. strcopy(PChar(uncompr), 'garbage');
  311. d_stream.zalloc := NIL; {alloc_func(0);}
  312. d_stream.zfree := NIL; {free_func(0);}
  313. d_stream.opaque := NIL; {voidpf(0);}
  314. d_stream.next_in := compr;
  315. d_stream.avail_in := uInt(comprLen);
  316. err := inflateInit(d_stream);
  317. CHECK_ERR(err, 'inflateInit');
  318. while TRUE do
  319. begin
  320. d_stream.next_out := uncompr; { discard the output }
  321. d_stream.avail_out := uInt(uncomprLen);
  322. err := inflate(d_stream, Z_NO_FLUSH);
  323. if (err = Z_STREAM_END) then
  324. break;
  325. CHECK_ERR(err, 'large inflate');
  326. end;
  327. err := inflateEnd(d_stream);
  328. CHECK_ERR(err, 'inflateEnd');
  329. if (d_stream.total_out <> 2*uncomprLen + comprLen div 2) then
  330. begin
  331. WriteLn('bad large inflate: ', d_stream.total_out);
  332. Stop;
  333. end
  334. else
  335. WriteLn('large_inflate(): OK');
  336. end;
  337. {$ENDIF}
  338. { ===========================================================================
  339. Test deflate() with full flush
  340. }
  341. {$IFDEF TEST_FLUSH}
  342. procedure test_flush(compr : pBytef; var comprLen : uLong);
  343. var
  344. c_stream : z_stream; { compression stream }
  345. err : int;
  346. len : int;
  347. begin
  348. len := strlen(hello)+1;
  349. c_stream.zalloc := NIL; {alloc_func(0);}
  350. c_stream.zfree := NIL; {free_func(0);}
  351. c_stream.opaque := NIL; {voidpf(0);}
  352. err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION);
  353. CHECK_ERR(err, 'deflateInit');
  354. c_stream.next_in := pBytef(hello);
  355. c_stream.next_out := compr;
  356. c_stream.avail_in := 3;
  357. c_stream.avail_out := uInt(comprLen);
  358. err := deflate(c_stream, Z_FULL_FLUSH);
  359. CHECK_ERR(err, 'deflate');
  360. Inc(pzByteArray(compr)^[3]); { force an error in first compressed block }
  361. c_stream.avail_in := len - 3;
  362. err := deflate(c_stream, Z_FINISH);
  363. if (err <> Z_STREAM_END) then
  364. CHECK_ERR(err, 'deflate');
  365. err := deflateEnd(c_stream);
  366. CHECK_ERR(err, 'deflateEnd');
  367. comprLen := c_stream.total_out;
  368. end;
  369. {$ENDIF}
  370. { ===========================================================================
  371. Test inflateSync()
  372. }
  373. {$IFDEF TEST_SYNC}
  374. procedure test_sync(compr : pBytef; comprLen : uLong;
  375. uncompr : pBytef; uncomprLen : uLong);
  376. var
  377. err : int;
  378. d_stream : z_stream; { decompression stream }
  379. begin
  380. strcopy(PChar(uncompr), 'garbage');
  381. d_stream.zalloc := NIL; {alloc_func(0);}
  382. d_stream.zfree := NIL; {free_func(0);}
  383. d_stream.opaque := NIL; {voidpf(0);}
  384. d_stream.next_in := compr;
  385. d_stream.avail_in := 2; { just read the zlib header }
  386. err := inflateInit(d_stream);
  387. CHECK_ERR(err, 'inflateInit');
  388. d_stream.next_out := uncompr;
  389. d_stream.avail_out := uInt(uncomprLen);
  390. inflate(d_stream, Z_NO_FLUSH);
  391. CHECK_ERR(err, 'inflate');
  392. d_stream.avail_in := uInt(comprLen-2); { read all compressed data }
  393. err := inflateSync(d_stream); { but skip the damaged part }
  394. CHECK_ERR(err, 'inflateSync');
  395. err := inflate(d_stream, Z_FINISH);
  396. if (err <> Z_DATA_ERROR) then
  397. begin
  398. WriteLn('inflate should report DATA_ERROR');
  399. { Because of incorrect adler32 }
  400. Stop;
  401. end;
  402. err := inflateEnd(d_stream);
  403. CHECK_ERR(err, 'inflateEnd');
  404. WriteLn('after inflateSync(): hel', StrPas(PChar(uncompr)));
  405. end;
  406. {$ENDIF}
  407. { ===========================================================================
  408. Test deflate() with preset dictionary
  409. }
  410. {$IFDEF TEST_DICT}
  411. procedure test_dict_deflate(compr : pBytef; comprLen : uLong);
  412. var
  413. c_stream : z_stream; { compression stream }
  414. err : int;
  415. begin
  416. c_stream.zalloc := NIL; {(alloc_func)0;}
  417. c_stream.zfree := NIL; {(free_func)0;}
  418. c_stream.opaque := NIL; {(voidpf)0;}
  419. err := deflateInit(c_stream, Z_BEST_COMPRESSION);
  420. CHECK_ERR(err, 'deflateInit');
  421. err := deflateSetDictionary(c_stream,
  422. pBytef(dictionary), StrLen(dictionary));
  423. CHECK_ERR(err, 'deflateSetDictionary');
  424. dictId := c_stream.adler;
  425. c_stream.next_out := compr;
  426. c_stream.avail_out := uInt(comprLen);
  427. c_stream.next_in := pBytef(hello);
  428. c_stream.avail_in := uInt(strlen(hello)+1);
  429. err := deflate(c_stream, Z_FINISH);
  430. if (err <> Z_STREAM_END) then
  431. begin
  432. WriteLn('deflate should report Z_STREAM_END');
  433. exit;
  434. end;
  435. err := deflateEnd(c_stream);
  436. CHECK_ERR(err, 'deflateEnd');
  437. end;
  438. { ===========================================================================
  439. Test inflate() with a preset dictionary }
  440. procedure test_dict_inflate(compr : pBytef; comprLen : uLong;
  441. uncompr : pBytef; uncomprLen : uLong);
  442. var
  443. err : int;
  444. d_stream : z_stream; { decompression stream }
  445. begin
  446. strcopy(PChar(uncompr), 'garbage');
  447. d_stream.zalloc := NIL; { alloc_func(0); }
  448. d_stream.zfree := NIL; { free_func(0); }
  449. d_stream.opaque := NIL; { voidpf(0); }
  450. d_stream.next_in := compr;
  451. d_stream.avail_in := uInt(comprLen);
  452. err := inflateInit(d_stream);
  453. CHECK_ERR(err, 'inflateInit');
  454. d_stream.next_out := uncompr;
  455. d_stream.avail_out := uInt(uncomprLen);
  456. while TRUE do
  457. begin
  458. err := inflate(d_stream, Z_NO_FLUSH);
  459. if (err = Z_STREAM_END) then
  460. break;
  461. if (err = Z_NEED_DICT) then
  462. begin
  463. if (d_stream.adler <> dictId) then
  464. begin
  465. WriteLn('unexpected dictionary');
  466. Stop;
  467. end;
  468. err := inflateSetDictionary(d_stream, pBytef(dictionary),
  469. StrLen(dictionary));
  470. end;
  471. CHECK_ERR(err, 'inflate with dict');
  472. end;
  473. err := inflateEnd(d_stream);
  474. CHECK_ERR(err, 'inflateEnd');
  475. if (strcomp(PChar(uncompr), hello)) <> 0 then
  476. begin
  477. WriteLn('bad inflate with dict');
  478. Stop;
  479. end
  480. else
  481. begin
  482. WriteLn('inflate with dictionary: ', StrPas(PChar(uncompr)));
  483. end;
  484. end;
  485. {$ENDIF}
  486. function GetFromFile(buf : pBytef; FName : string;
  487. var MaxLen : uInt) : boolean;
  488. const
  489. zOfs = 0;
  490. var
  491. f : file;
  492. Len : uLong;
  493. begin
  494. assign(f, FName);
  495. GetFromFile := false;
  496. {$I-}
  497. filemode := 0; { read only }
  498. reset(f, 1);
  499. if IOresult = 0 then
  500. begin
  501. Len := FileSize(f)-zOfs;
  502. Seek(f, zOfs);
  503. if Len < MaxLen then
  504. MaxLen := Len;
  505. BlockRead(f, buf^, MaxLen);
  506. close(f);
  507. WriteLn(FName);
  508. GetFromFile := (IOresult = 0) and (MaxLen > 0);
  509. end
  510. else
  511. WriteLn('Could not open ', FName);
  512. end;
  513. { ===========================================================================
  514. Usage: example [output.gz [input.gz]]
  515. }
  516. var
  517. compr, uncompr : pBytef;
  518. const
  519. msdoslen = 25000;
  520. comprLenL : uLong = msdoslen div sizeof(uInt); { don't overflow on MSDOS }
  521. uncomprLenL : uLong = msdoslen div sizeof(uInt);
  522. var
  523. zVersion,
  524. myVersion : string;
  525. var
  526. comprLen : uInt;
  527. uncomprLen : uInt;
  528. begin
  529. {$ifdef MemCheck}
  530. MemChk;
  531. {$endif}
  532. comprLen := comprLenL;
  533. uncomprLen := uncomprLenL;
  534. myVersion := ZLIB_VERSION;
  535. zVersion := zlibVersion;
  536. if (zVersion[1] <> myVersion[1]) then
  537. begin
  538. WriteLn('incompatible zlib version');
  539. Stop;
  540. end
  541. else
  542. if (zVersion <> ZLIB_VERSION) then
  543. begin
  544. WriteLn('warning: different zlib version');
  545. end;
  546. GetMem(compr, comprLen*sizeof(uInt));
  547. GetMem(uncompr, uncomprLen*sizeof(uInt));
  548. { compr and uncompr are cleared to avoid reading uninitialized
  549. data and to ensure that uncompr compresses well. }
  550. if (compr = Z_NULL) or (uncompr = Z_NULL) then
  551. begin
  552. WriteLn('out of memory');
  553. Stop;
  554. end;
  555. FillChar(compr^, comprLen*sizeof(uInt), 0);
  556. FillChar(uncompr^, uncomprLen*sizeof(uInt), 0);
  557. if (compr = Z_NULL) or (uncompr = Z_NULL) then
  558. begin
  559. WriteLn('out of memory');
  560. Stop;
  561. end;
  562. {$IFDEF TEST_COMPRESS}
  563. test_compress(compr, comprLenL, uncompr, uncomprLen);
  564. {$ENDIF}
  565. {$IFDEF TEST_GZIO}
  566. Case ParamCount of
  567. 0: test_gzio('foo.gz', 'foo.gz', uncompr, int(uncomprLen));
  568. 1: test_gzio(ParamStr(1), 'foo.gz', uncompr, int(uncomprLen));
  569. else
  570. test_gzio(ParamStr(1), ParamStr(2), uncompr, int(uncomprLen));
  571. end;
  572. {$ENDIF}
  573. {$IFDEF TEST_DEFLATE}
  574. WriteLn('small buffer Deflate');
  575. test_deflate(compr, comprLen);
  576. {$ENDIF}
  577. {$IFDEF TEST_INFLATE}
  578. {$IFNDEF TEST_DEFLATE}
  579. WriteLn('small buffer Inflate');
  580. if GetFromFile(compr, 'u:\nomssi\paszlib\new\test0.z', comprLen) then
  581. {$ENDIF}
  582. test_inflate(compr, comprLen, uncompr, uncomprLen);
  583. {$ENDIF}
  584. readln;
  585. {$IFDEF TEST_DEFLATE}
  586. WriteLn('large buffer Deflate');
  587. test_large_deflate(compr, comprLen, uncompr, uncomprLen);
  588. {$ENDIF}
  589. {$IFDEF TEST_INFLATE}
  590. WriteLn('large buffer Inflate');
  591. test_large_inflate(compr, comprLen, uncompr, uncomprLen);
  592. {$ENDIF}
  593. {$IFDEF TEST_FLUSH}
  594. test_flush(compr, comprLenL);
  595. {$ENDIF}
  596. {$IFDEF TEST_SYNC}
  597. test_sync(compr, comprLen, uncompr, uncomprLen);
  598. {$ENDIF}
  599. comprLen := uncomprLen;
  600. {$IFDEF TEST_DICT}
  601. test_dict_deflate(compr, comprLen);
  602. test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
  603. {$ENDIF}
  604. readln;
  605. FreeMem(compr, comprLen*sizeof(uInt));
  606. FreeMem(uncompr, uncomprLen*sizeof(uInt));
  607. end.