php-src/ext/zlib/tests/gzinflate_length.phpt
Michael Wallner 11d24c1593 * implement new output API, fixing some bugs and implementing some feature
requests--let's see what I can dig out of the bugtracker for NEWS--
  and while crossing the road:
   * implemented new zlib API
   * fixed up ext/tidy (what was "s&" in zend_parse_parameters() supposed to do?)

Thanks to Jani and Felipe for pioneering.
2010-05-31 10:29:43 +00:00

27 lines
690 B
PHP

--TEST--
gzinflate() and $length argument
--SKIPIF--
<?php if (!extension_loaded("zlib")) print "skip"; ?>
--FILE--
<?php
$original = 'aaaaaaaaaaaaaaa';
$packed=gzdeflate($original);
echo strlen($packed)." ".strlen($original)."\n";
$unpacked=gzinflate($packed, strlen($original));
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
$unpacked=gzinflate($packed, strlen($original)*10);
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
$unpacked=gzinflate($packed, 1);
if ($unpacked === false) echo "Failed (as expected)\n";
?>
--EXPECTF--
5 15
Strings are equal
Strings are equal
Warning: gzinflate(): insufficient memory in %s on line %d
Failed (as expected)