summaryrefslogtreecommitdiff
path: root/ext/zlib/tests/dictionary_usage.phpt
blob: f7ef3b3a9cc0c6bbf4a1995658b02e336a2934c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--TEST--
Test dictionary usage on zlib methods
--FILE--
<?php

$dict = range("a", "z");

$r = deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]);
$a = deflate_add($r, "abdcde", ZLIB_FINISH);
var_dump($a);

$r = deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => implode("\0", $dict)."\0"]);
$dictStr_a = deflate_add($r, "abdcde", ZLIB_FINISH);
var_dump($dictStr_a === $a);

$r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => $dict]);
var_dump(inflate_add($r, $a, ZLIB_FINISH));


$r = inflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => ["8"] + range("a", "z")]);
var_dump(inflate_add($r, $a, ZLIB_FINISH));

?>
--EXPECTF--
string(%d) "%s"
bool(true)
string(6) "abdcde"

Warning: inflate_add(): dictionary does not match expected dictionary (incorrect adler32 hash) in %s on line %d
bool(false)