xref: /PHP-5.6/ext/gmp/tests/gmp_cmp.phpt (revision 9586b152)
1--TEST--
2gmp_cmp() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
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
20var_dump(gmp_cmp($n1,$n,1));
21var_dump(gmp_cmp(array(),array()));
22var_dump(gmp_cmp(array()));
23var_dump(gmp_cmp());
24
25echo "Done\n";
26?>
27--EXPECTF--
28int(2)
29int(0)
30int(-1)
31int(0)
32int(1)
33int(-1)
34bool(true)
35int(0)
36
37Warning: gmp_cmp() expects exactly 2 parameters, 3 given in %s on line %d
38NULL
39
40Warning: gmp_cmp(): Unable to convert variable to GMP - wrong type in %s on line %d
41bool(false)
42
43Warning: gmp_cmp() expects exactly 2 parameters, 1 given in %s on line %d
44NULL
45
46Warning: gmp_cmp() expects exactly 2 parameters, 0 given in %s on line %d
47NULL
48Done
49