Skip to content

Commit 7b88026

Browse files
committed
add tests
1 parent 6169964 commit 7b88026

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
GMP functions reject values larger than unsigned long on LLP64
3+
--EXTENSIONS--
4+
gmp
5+
--SKIPIF--
6+
<?php
7+
if (PHP_OS_FAMILY !== "Windows" || PHP_INT_SIZE !== 8) die("skip LLP64 (Windows 64-bit) only");
8+
?>
9+
--FILE--
10+
<?php
11+
12+
try {
13+
gmp_pow(2, PHP_INT_MAX);
14+
} catch (ValueError $e) {
15+
echo $e->getMessage() . PHP_EOL;
16+
}
17+
18+
try {
19+
gmp_binomial(10, PHP_INT_MAX);
20+
} catch (ValueError $e) {
21+
echo $e->getMessage() . PHP_EOL;
22+
}
23+
24+
try {
25+
gmp_root(10, PHP_INT_MAX);
26+
} catch (ValueError $e) {
27+
echo $e->getMessage() . PHP_EOL;
28+
}
29+
30+
try {
31+
gmp_rootrem(10, PHP_INT_MAX);
32+
} catch (ValueError $e) {
33+
echo $e->getMessage() . PHP_EOL;
34+
}
35+
36+
$n = gmp_init(2);
37+
try {
38+
$n << PHP_INT_MAX;
39+
} catch (ValueError $e) {
40+
echo $e->getMessage() . PHP_EOL;
41+
}
42+
43+
try {
44+
$n ** PHP_INT_MAX;
45+
} catch (ValueError $e) {
46+
echo $e->getMessage() . PHP_EOL;
47+
}
48+
49+
echo "Done\n";
50+
?>
51+
--EXPECTF--
52+
gmp_pow(): Argument #2 ($exponent) must be between 0 and %d
53+
gmp_binomial(): Argument #2 ($k) must be between 0 and %d
54+
gmp_root(): Argument #2 ($nth) must be between 1 and %d
55+
gmp_rootrem(): Argument #2 ($nth) must be between 1 and %d
56+
Shift must be between 0 and %d
57+
Exponent must be between 0 and %d
58+
Done

0 commit comments

Comments
 (0)