xref: /PHP-8.1/ext/gmp/tests/gmp_cmp.phpt (revision e9f783fc)
1--TEST--
2gmp_cmp() basic tests
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8var_dump(gmp_cmp(123123,-123123));
9var_dump(gmp_cmp("12345678900987654321","12345678900987654321"));
10var_dump(gmp_cmp("12345678900987654321","123456789009876543211"));
11var_dump(gmp_cmp(0,0));
12var_dump(gmp_cmp(1231222,0));
13var_dump(gmp_cmp(0,345355));
14
15$n = gmp_init("827278512385463739");
16var_dump(gmp_cmp(0,$n) < 0);
17$n1 = gmp_init("827278512385463739");
18var_dump(gmp_cmp($n1,$n));
19
20try {
21    var_dump(gmp_cmp(array(),array()));
22} catch (\TypeError $e) {
23    echo $e->getMessage() . \PHP_EOL;
24}
25
26echo "Done\n";
27?>
28--EXPECT--
29int(2)
30int(0)
31int(-1)
32int(0)
33int(1)
34int(-1)
35bool(true)
36int(0)
37gmp_cmp(): Argument #1 ($num1) must be of type GMP|string|int, array given
38Done
39