xref: /PHP-8.2/ext/gmp/tests/gmp_invert.phpt (revision e9f783fc)
1--TEST--
2gmp_invert() basic tests
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_invert(123123,5467624)));
9var_dump(gmp_strval(gmp_invert(123123,"3333334345467624")));
10var_dump(gmp_strval(gmp_invert("12312323213123123",7624)));
11
12try {
13    var_dump(gmp_strval(gmp_invert(444,0)));
14} catch (\DivisionByZeroError $e) {
15    echo $e->getMessage() . \PHP_EOL;
16}
17
18var_dump(gmp_strval(gmp_invert(0,28347)));
19var_dump(gmp_strval(gmp_invert(-12,456456)));
20var_dump(gmp_strval(gmp_invert(234234,-435345)));
21
22$n = gmp_init("349827349623423452345");
23$n1 = gmp_init("3498273496234234523451");
24
25var_dump(gmp_strval(gmp_invert($n, $n1)));
26var_dump(gmp_strval(gmp_invert($n1, $n)));
27
28try {
29    var_dump(gmp_invert(array(), 1));
30} catch (\TypeError $e) {
31    echo $e->getMessage() . \PHP_EOL;
32}
33try {
34    var_dump(gmp_invert(1, array()));
35} catch (\TypeError $e) {
36    echo $e->getMessage() . \PHP_EOL;
37}
38try {
39    var_dump(gmp_invert(array(), array()));
40} catch (\TypeError $e) {
41    echo $e->getMessage() . \PHP_EOL;
42}
43
44echo "Done\n";
45?>
46--EXPECT--
47string(7) "2293131"
48string(1) "0"
49string(4) "5827"
50Division by zero
51string(1) "0"
52string(1) "0"
53string(1) "0"
54string(22) "3498273496234234523441"
55string(1) "1"
56gmp_invert(): Argument #1 ($num1) must be of type GMP|string|int, array given
57gmp_invert(): Argument #2 ($num2) must be of type GMP|string|int, array given
58gmp_invert(): Argument #1 ($num1) must be of type GMP|string|int, array given
59Done
60