xref: /php-src/ext/gmp/tests/gmp_hamdist.phpt (revision e9f783fc)
1--TEST--
2gmp_hamdist() basic tests
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8var_dump(gmp_hamdist(1231231, 0));
9var_dump(gmp_hamdist(1231231, -1));
10var_dump(gmp_hamdist(1231231, "8765434567897654333334567"));
11var_dump(gmp_hamdist(-364264234, "8333765434567897654333334567"));
12
13$n = gmp_init("8765434567");
14$n1 = gmp_init("987654445678");
15var_dump(gmp_hamdist($n, "8333765434567897654333334567"));
16var_dump(gmp_hamdist($n, $n));
17var_dump(gmp_hamdist($n, $n1));
18
19try {
20    var_dump(gmp_hamdist($n, array()));
21} catch (\TypeError $e) {
22    echo $e->getMessage() . \PHP_EOL;
23}
24try {
25    var_dump(gmp_hamdist(array(), $n));
26} catch (\TypeError $e) {
27    echo $e->getMessage() . \PHP_EOL;
28}
29try {
30    var_dump(gmp_hamdist(array(), array()));
31} catch (\TypeError $e) {
32    echo $e->getMessage() . \PHP_EOL;
33}
34
35echo "Done\n";
36?>
37--EXPECT--
38int(13)
39int(-1)
40int(36)
41int(-1)
42int(43)
43int(0)
44int(26)
45gmp_hamdist(): Argument #2 ($num2) must be of type GMP|string|int, array given
46gmp_hamdist(): Argument #1 ($num1) must be of type GMP|string|int, array given
47gmp_hamdist(): Argument #1 ($num1) must be of type GMP|string|int, array given
48Done
49