xref: /PHP-7.0/ext/gmp/tests/gmp_divexact.phpt (revision 9586b152)
1--TEST--
2gmp_divexact() tests
3--SKIPIF--
4<?php
5if (!extension_loaded("gmp")) die ("skip");
6if (!defined('GMP_VERSION') || version_compare("4.2.1", GMP_VERSION, ">=")) {
7	die("skip your GMP is too old and will crash");
8}
9?>
10--FILE--
11<?php
12
13var_dump(gmp_divexact(1, 1, 1));
14var_dump(gmp_divexact());
15
16$r = gmp_divexact("233", "23345555555555555555555555");
17var_dump(gmp_strval($r));
18
19$r = gmp_divexact("233", "0");
20var_dump(gmp_strval($r));
21
22$r = gmp_divexact("100", "10");
23var_dump(gmp_strval($r));
24
25$r = gmp_divexact("1024", "2");
26var_dump(gmp_strval($r));
27
28$n = gmp_init("10000000000000000000");
29$r = gmp_divexact($n, "2");
30var_dump(gmp_strval($r));
31
32$r = gmp_divexact($n, "50");
33var_dump(gmp_strval($r));
34
35$n1 = gmp_init("-100000000000000000000000000");
36$r = gmp_divexact($n1, $n);
37var_dump(gmp_strval($r));
38
39echo "Done\n";
40?>
41--EXPECTF--
42Warning: gmp_divexact() expects exactly 2 parameters, 3 given in %s on line %d
43NULL
44
45Warning: gmp_divexact() expects exactly 2 parameters, 0 given in %s on line %d
46NULL
47string(1) "0"
48
49Warning: gmp_divexact(): Zero operand not allowed in %s on line %d
50string(1) "0"
51string(2) "10"
52string(3) "512"
53string(19) "5000000000000000000"
54string(18) "200000000000000000"
55string(9) "-10000000"
56Done
57