summaryrefslogtreecommitdiff
path: root/ext/zlib/tests/inflate_init_reuse.phpt
blob: a6b8a309c0cd49876f4168ca42e4649b315a7602 (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
31
32
--TEST--
Test incremental inflate_init() context reuse
--SKIPIF--
<?php 
if (!extension_loaded("zlib")) {
    print "skip - ZLIB extension not loaded"; 
}
?>
--FILE--
<?php
$resource = inflate_init(ZLIB_ENCODING_GZIP);

$uncompressed = implode(range("a","z"));
$compressed = gzencode($uncompressed);
$inflated = "";
for ($i=0;$i<strlen($compressed);$i++) {
    $inflated .= inflate_add($resource, $compressed[$i]);
}
$inflated .= inflate_add($resource, "", ZLIB_FINISH);
assert($inflated === $uncompressed);

// Now reuse the existing resource after finishing the previous operations ...
$inflated = "";
for ($i=0;$i<strlen($compressed);$i++) {
    $inflated .= inflate_add($resource, $compressed[$i]);
}
$inflated .= inflate_add($resource, "", ZLIB_FINISH);
assert($inflated === $uncompressed);
?>
===DONE===
--EXPECTF--
===DONE===