summaryrefslogtreecommitdiff
path: root/ext/zlib/tests/gzread_error2.phpt
blob: ff0dfe80289feefea93eca7e60a7cd9d016e6d1e (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
33
34
--TEST--
Test function gzread() by calling it invalid lengths
--SKIPIF--
<?php
if (!extension_loaded("zlib")) {
	print "skip - ZLIB extension not loaded";
}
?>
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$h = gzopen($f, 'r');
var_dump(gzread($h, 10));
try {
    var_dump(gzread($h, 0));
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}
var_dump(gzread($h, 5));
try {
    var_dump(gzread($h, -1));
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}
var_dump(gzread($h, 8));
gzclose($h);

?>
--EXPECT--
string(10) "When you'r"
gzread(): Argument #2 ($length) must be greater than 0
string(5) "e tau"
gzread(): Argument #2 ($length) must be greater than 0
string(8) "ght thro"