summaryrefslogtreecommitdiff
path: root/ext/zlib/tests/inflate_get_read_len.phpt
blob: 37c977789f541e6415fefd296485b2bc9431e70a (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
--TEST--
inflate_get_read_len()
--SKIPIF--
<?php if (!extension_loaded("zlib")) print "skip"; ?>
--FILE--
<?php

$uncompressed = "Hello world.";
$random_junk = str_repeat("qebsouesl", 128);;

$compressed = zlib_encode($uncompressed, ZLIB_ENCODING_DEFLATE);
$compressed_len = strlen($compressed);
$compressed .= $random_junk;

$ctx = inflate_init(ZLIB_ENCODING_DEFLATE);
$buf = inflate_add($ctx, $compressed);
$detected_compressed_len = inflate_get_read_len($ctx);

echo 'Status: ' . inflate_get_status($ctx) . "\n";
echo 'Original compressed length: ' . $compressed_len . "\n";
echo 'Detected compressed length: ' . $detected_compressed_len . "\n";

echo ($compressed_len == $detected_compressed_len) ? 'The lengths are equal.' : 'The lengths are unequal.';
?>
--EXPECT--
Status: 1
Original compressed length: 20
Detected compressed length: 20
The lengths are equal.