xref: /PHP-7.2/ext/gmp/tests/gmp_sqrtrem.phpt (revision 17ccbeec)
1--TEST--
2gmp_sqrtrem() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8$r = gmp_sqrtrem(-1);
9var_dump($r);
10
11$r = gmp_sqrtrem("0");
12var_dump(gmp_strval($r[0]));
13var_dump(gmp_strval($r[1]));
14
15$r = gmp_sqrtrem(2);
16var_dump(gmp_strval($r[0]));
17var_dump(gmp_strval($r[1]));
18
19$r = gmp_sqrtrem(10);
20var_dump(gmp_strval($r[0]));
21var_dump(gmp_strval($r[1]));
22
23$r = gmp_sqrtrem(7);
24var_dump(gmp_strval($r[0]));
25var_dump(gmp_strval($r[1]));
26
27$r = gmp_sqrtrem(3);
28var_dump(gmp_strval($r[0]));
29var_dump(gmp_strval($r[1]));
30
31$r = gmp_sqrtrem(100000);
32var_dump(gmp_strval($r[0]));
33var_dump(gmp_strval($r[1]));
34
35$r = gmp_sqrtrem("1000000");
36var_dump(gmp_strval($r[0]));
37var_dump(gmp_strval($r[1]));
38
39$r = gmp_sqrtrem("1000001");
40var_dump(gmp_strval($r[0]));
41var_dump(gmp_strval($r[1]));
42
43
44$n = gmp_init(-1);
45$r = gmp_sqrtrem($n);
46var_dump($r);
47
48$n = gmp_init(1000001);
49$r = gmp_sqrtrem($n);
50var_dump(gmp_strval($r[0]));
51var_dump(gmp_strval($r[1]));
52
53var_dump(gmp_sqrtrem(array()));
54var_dump(gmp_sqrtrem());
55
56echo "Done\n";
57?>
58--EXPECTF--
59Warning: gmp_sqrtrem(): Number has to be greater than or equal to 0 in %s on line %d
60bool(false)
61string(1) "0"
62string(1) "0"
63string(1) "1"
64string(1) "1"
65string(1) "3"
66string(1) "1"
67string(1) "2"
68string(1) "3"
69string(1) "1"
70string(1) "2"
71string(3) "316"
72string(3) "144"
73string(4) "1000"
74string(1) "0"
75string(4) "1000"
76string(1) "1"
77
78Warning: gmp_sqrtrem(): Number has to be greater than or equal to 0 in %s on line %d
79bool(false)
80string(4) "1000"
81string(1) "1"
82
83Warning: gmp_sqrtrem(): Unable to convert variable to GMP - wrong type in %s on line %d
84bool(false)
85
86Warning: gmp_sqrtrem() expects exactly 1 parameter, 0 given in %s on line %d
87NULL
88Done
89