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