php-src/ext/zlib/tests/bug_34821.phpt

42 lines
670 B
Plaintext
Raw Normal View History

2005-10-25 15:17:11 +00:00
--TEST--
2006-12-05 23:03:42 +00:00
Bug #34821 (zlib encoders fail on widely varying binary data)
2005-10-25 15:17:11 +00:00
--SKIPIF--
<?php if (!extension_loaded("zlib")) print "skip"; ?>
--FILE--
<?php
2007-01-03 22:33:33 +00:00
// test 50 bytes to 50k
2005-10-25 15:17:11 +00:00
$b = array(
50,
500,
5000,
2007-01-03 22:33:33 +00:00
50000,
2005-10-25 15:17:11 +00:00
// 1000000, // works, but test would take too long
);
2006-12-28 19:53:30 +00:00
$s = '';
$i = 0;
2005-10-25 15:17:11 +00:00
foreach ($b as $size) {
2006-12-28 19:53:30 +00:00
do {
2005-10-25 15:17:11 +00:00
$s .= chr(rand(0,255));
2006-12-28 19:53:30 +00:00
} while (++$i < $size);
var_dump($s === gzinflate(gzdeflate($s)));
var_dump($s === gzuncompress(gzcompress($s)));
var_dump($s === gzinflate(substr(gzencode($s), 10, -8)));
2005-10-25 15:17:11 +00:00
}
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)