xref: /PHP-8.0/ext/zlib/tests/gzread_error2.phpt (revision c5401854)
1--TEST--
2Test function gzread() by calling it invalid lengths
3--SKIPIF--
4<?php
5if (!extension_loaded("zlib")) {
6    print "skip - ZLIB extension not loaded";
7}
8?>
9--FILE--
10<?php
11$f = __DIR__."/004.txt.gz";
12$h = gzopen($f, 'r');
13var_dump(gzread($h, 10));
14try {
15    var_dump(gzread($h, 0));
16} catch (\ValueError $e) {
17    echo $e->getMessage() . \PHP_EOL;
18}
19var_dump(gzread($h, 5));
20try {
21    var_dump(gzread($h, -1));
22} catch (\ValueError $e) {
23    echo $e->getMessage() . \PHP_EOL;
24}
25var_dump(gzread($h, 8));
26gzclose($h);
27
28?>
29--EXPECT--
30string(10) "When you'r"
31gzread(): Argument #2 ($length) must be greater than 0
32string(5) "e tau"
33gzread(): Argument #2 ($length) must be greater than 0
34string(8) "ght thro"
35