1--TEST--
2Test dictionary usage on zlib methods
3--FILE--
4<?php
5
6$dict = range("a", "z");
7
8$r = deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]);
9$a = deflate_add($r, "abdcde", ZLIB_FINISH);
10var_dump($a);
11
12$r = deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => implode("\0", $dict)."\0"]);
13$dictStr_a = deflate_add($r, "abdcde", ZLIB_FINISH);
14var_dump($dictStr_a === $a);
15
16$r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]);
17var_dump(inflate_add($r, $a, ZLIB_FINISH));
18
19
20$r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => ["8"] + range("a", "z")]);
21var_dump(inflate_add($r, $a, ZLIB_FINISH));
22
23?>
24--EXPECTF--
25string(%d) "%s"
26bool(true)
27string(6) "abdcde"
28
29Warning: inflate_add(): dictionary does not match expected dictionary (incorrect adler32 hash) in %s on line %d
30bool(false)
31