xref: /PHP-7.4/ext/gmp/tests/gmp_gcd.phpt (revision 782352c5)
1--TEST--
2gmp_gcd() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_gcd(234,12387)));
9var_dump(gmp_strval(gmp_gcd(0,12387)));
10var_dump(gmp_strval(gmp_gcd(224,0)));
11var_dump(gmp_strval(gmp_gcd(-1,0)));
12var_dump(gmp_strval(gmp_gcd(-1,0)));
13var_dump(gmp_strval(gmp_gcd("12371238123","32618723123")));
14var_dump(gmp_strval(gmp_gcd("7623456735","12372341234")));
15
16$n = gmp_init("8127346234");
17var_dump(gmp_strval(gmp_gcd($n,"12372341234")));
18$n = gmp_init("8127346234");
19var_dump(gmp_strval(gmp_gcd("7623456735",$n)));
20$n = gmp_init("8127346234");
21var_dump(gmp_strval(gmp_gcd($n,$n)));
22$n = gmp_init("8127346234");
23var_dump(gmp_strval(gmp_gcd($n,0)));
24var_dump(gmp_gcd($n,$n,1));
25var_dump(gmp_gcd($n,array(),1));
26var_dump(gmp_gcd(array(),$n,1));
27
28echo "Done\n";
29?>
30--EXPECTF--
31string(1) "3"
32string(5) "12387"
33string(3) "224"
34string(1) "1"
35string(1) "1"
36string(1) "1"
37string(1) "1"
38string(1) "2"
39string(1) "1"
40string(10) "8127346234"
41string(10) "8127346234"
42
43Warning: gmp_gcd() expects exactly 2 parameters, 3 given in %s on line %d
44NULL
45
46Warning: gmp_gcd() expects exactly 2 parameters, 3 given in %s on line %d
47NULL
48
49Warning: gmp_gcd() expects exactly 2 parameters, 3 given in %s on line %d
50NULL
51Done
52