xref: /php-src/ext/zlib/tests/006.phpt (revision 74859783)
1--TEST--
2gzdeflate()/gzinflate() and invalid params
3--EXTENSIONS--
4zlib
5--FILE--
6<?php
7
8try {
9    var_dump(gzcompress("", 1000));
10} catch (\ValueError $e) {
11    echo $e->getMessage() . \PHP_EOL;
12}
13
14var_dump(gzdeflate("", -1));
15
16var_dump(gzdeflate(""));
17var_dump(gzdeflate("", 9));
18
19$string = "Answer me, it can't be so hard
20Cry to relieve what's in your heart
21Desolation, grief and agony";
22
23var_dump($data1 = gzdeflate($string));
24var_dump($data2 = gzdeflate($string, 9));
25
26var_dump(gzinflate(""));
27var_dump(gzinflate("asfwe", 1000));
28
29try {
30    var_dump(gzinflate("asdf", -1));
31} catch (\ValueError $e) {
32    echo $e->getMessage() . \PHP_EOL;
33}
34
35var_dump(gzinflate("asdf"));
36var_dump(gzinflate("asdf", 9));
37
38var_dump(gzinflate($data1));
39var_dump(gzinflate($data2));
40$data2[4] = 0;
41var_dump(gzinflate($data2));
42
43?>
44--EXPECTF--
45gzcompress(): Argument #2 ($level) must be between -1 and 9
46string(%d) "%a"
47string(%d) "%a"
48string(%d) "%a"
49string(%d) "%a"
50string(%d) "%a"
51
52Warning: gzinflate(): data error in %s on line %d
53bool(false)
54
55Warning: gzinflate(): data error in %s on line %d
56bool(false)
57gzinflate(): Argument #2 ($max_length) must be greater than or equal to 0
58
59Warning: gzinflate(): data error in %s on line %d
60bool(false)
61
62Warning: gzinflate(): data error in %s on line %d
63bool(false)
64string(94) "Answer me, it can't be so hard
65Cry to relieve what's in your heart
66Desolation, grief and agony"
67string(94) "Answer me, it can't be so hard
68Cry to relieve what's in your heart
69Desolation, grief and agony"
70
71Warning: gzinflate(): data error in %s on line %d
72bool(false)
73