xref: /PHP-8.3/ext/zlib/tests/bug_34821.phpt (revision 74859783)
1--TEST--
2Bug #34821 (zlib encoders fail on widely varying binary data)
3--EXTENSIONS--
4zlib
5--FILE--
6<?php
7
8// test 50 bytes to 50k
9$b = array(
10    50,
11    500,
12    5000,
13    50000,
14//	1000000, // works, but test would take too long
15);
16
17$s = '';
18$i = 0;
19
20foreach ($b as $size) {
21    do {
22        $s .= chr(rand(0,255));
23    } while (++$i < $size);
24    var_dump($s === gzinflate(gzdeflate($s)));
25    var_dump($s === gzuncompress(gzcompress($s)));
26    var_dump($s === gzinflate(substr(gzencode($s), 10, -8)));
27}
28?>
29--EXPECT--
30bool(true)
31bool(true)
32bool(true)
33bool(true)
34bool(true)
35bool(true)
36bool(true)
37bool(true)
38bool(true)
39bool(true)
40bool(true)
41bool(true)
42