example.pas 17 KB

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