summaryrefslogtreecommitdiffstats
path: root/ef4f39b2149765cac1f9a7bc5a360e09e9e506e6.patch
blob: cba330d9f7e2fad4c81f360ba15a42b0b141bf1d (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
From ef4f39b2149765cac1f9a7bc5a360e09e9e506e6 Mon Sep 17 00:00:00 2001
From: kj <kjclev@gmail.com>
Date: Tue, 27 Aug 2019 08:49:35 +0900
Subject: [PATCH] Fixed for tests in nightly

---
 tests/002.phpt   |  4 ++-
 tests/002_b.phpt | 68 +++++++++++++++++++++++++++++++++++++++++
 tests/005.phpt   |  2 ++
 tests/005_b.phpt | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 151 insertions(+), 1 deletion(-)
 create mode 100644 tests/002_b.phpt
 create mode 100644 tests/005_b.phpt

diff --git a/tests/002.phpt b/tests/002.phpt
index 5e1f519..adf8509 100644
--- a/tests/002.phpt
+++ b/tests/002.phpt
@@ -1,8 +1,10 @@
 --TEST--
 Test lz4_compress() function : error conditions
 --SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '8.0', '>=')) die('skip PHP is too old');
 --FILE--
-<?php 
+<?php
 if (!extension_loaded('lz4')) {
     dl('lz4.' . PHP_SHLIB_SUFFIX);
 }
diff --git a/tests/002_b.phpt b/tests/002_b.phpt
new file mode 100644
index 0000000..a56dac8
--- /dev/null
+++ b/tests/002_b.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Test lz4_compress() function : error conditions
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '8.0', '<')) die('skip PHP is too new');
+--FILE--
+<?php
+if (!extension_loaded('lz4')) {
+    dl('lz4.' . PHP_SHLIB_SUFFIX);
+}
+
+include(dirname(__FILE__) . '/data.inc');
+
+echo "*** Testing lz4_compress() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing lz4_compress() function with Zero arguments --\n";
+try {
+  var_dump(lz4_compress());
+} catch (Error $e) {
+  echo $e, PHP_EOL;
+}
+
+//Test lz4_compress with one more than the expected number of arguments
+echo "\n-- Testing lz4_compress() function with more than expected no. of arguments --\n";
+$data = 'string_val';
+$extra_arg = 10;
+try {
+  var_dump(lz4_compress($data, 6, false, $extra_arg));
+} catch (Error $e) {
+  echo $e, PHP_EOL;
+}
+
+class Tester {
+    function Hello() {
+        echo "Hello\n";
+    }
+}
+
+echo "\n-- Testing with incorrect parameters --\n";
+$testclass = new Tester();
+try {
+  var_dump(lz4_compress($testclass));
+} catch (Error $e) {
+  echo $e, PHP_EOL;
+}
+?>
+===Done===
+--EXPECTF--
+*** Testing lz4_compress() : error conditions ***
+
+-- Testing lz4_compress() function with Zero arguments --
+ArgumentCountError: lz4_compress() expects at least 1 parameter, 0 given in %s:%d
+Stack trace:
+#0 %s(%d): lz4_compress()
+#1 {main}
+
+-- Testing lz4_compress() function with more than expected no. of arguments --
+ArgumentCountError: lz4_compress() expects at most 3 parameters, 4 given in %s:%d
+Stack trace:
+#0 %s(%d): lz4_compress(%s)
+#1 {main}
+
+-- Testing with incorrect parameters --
+
+Warning: lz4_compress : expects parameter to be string. in %s on line %d
+bool(false)
+===Done===
diff --git a/tests/005.phpt b/tests/005.phpt
index 19add34..6133d83 100644
--- a/tests/005.phpt
+++ b/tests/005.phpt
@@ -1,6 +1,8 @@
 --TEST--
 Test lz4_uncompress() function : error conditions
 --SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '8.0', '>=')) die('skip PHP is too old');
 --FILE--
 <?php
 if (!extension_loaded('lz4')) {
diff --git a/tests/005_b.phpt b/tests/005_b.phpt
new file mode 100644
index 0000000..afb5158
--- /dev/null
+++ b/tests/005_b.phpt
@@ -0,0 +1,78 @@
+--TEST--
+Test lz4_uncompress() function : error conditions
+--SKIPIF--
+<?php
+if (version_compare(PHP_VERSION, '8.0', '<')) die('skip PHP is too new');
+--FILE--
+<?php
+if (!extension_loaded('lz4')) {
+    dl('lz4.' . PHP_SHLIB_SUFFIX);
+}
+
+echo "*** Testing lz4_uncompress() : error conditions ***\n";
+
+// Zero arguments
+echo "\n-- Testing lz4_uncompress() function with Zero arguments --\n";
+try {
+  var_dump( lz4_uncompress() );
+} catch (Error $e) {
+  echo $e, PHP_EOL;
+}
+
+//Test lz4_uncompress with one more than the expected number of arguments
+echo "\n-- Testing lz4_uncompress() function with more than expected no. of arguments --\n";
+$data = 'string_val';
+$extra_arg = 10;
+try {
+  var_dump( lz4_uncompress($data, -1, -1, $extra_arg) );
+} catch (Error $e) {
+  echo $e, PHP_EOL;
+}
+
+
+echo "\n-- Testing with incorrect arguments --\n";
+try {
+  var_dump(lz4_uncompress(123));
+} catch (Error $e) {
+  echo $e, PHP_EOL;
+}
+
+class Tester
+{
+    function Hello()
+    {
+        echo "Hello\n";
+    }
+}
+
+$testclass = new Tester();
+try {
+  var_dump(lz4_uncompress($testclass));
+} catch (Error $e) {
+  echo $e, PHP_EOL;
+}
+?>
+===DONE===
+--EXPECTF--
+*** Testing lz4_uncompress() : error conditions ***
+
+-- Testing lz4_uncompress() function with Zero arguments --
+ArgumentCountError: lz4_uncompress() expects at least 1 parameter, 0 given in %s:%d
+Stack trace:
+#0 %s(%d): lz4_uncompress()
+#1 {main}
+
+-- Testing lz4_uncompress() function with more than expected no. of arguments --
+ArgumentCountError: lz4_uncompress() expects at most 3 parameters, 4 given in %s:%d
+Stack trace:
+#0 %s(%d): lz4_uncompress(%s)
+#1 {main}
+
+-- Testing with incorrect arguments --
+
+Warning: lz4_uncompress : expects parameter to be string. in %s on line %d
+bool(false)
+
+Warning: lz4_uncompress : expects parameter to be string. in %s on line %d
+bool(false)
+===DONE===