xref: /PHP-8.0/ext/gmp/tests/gmp_popcount.phpt (revision 25198277)
1--TEST--
2gmp_popcount() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_popcount(-1));
9var_dump(gmp_popcount(0));
10var_dump(gmp_popcount(12123));
11var_dump(gmp_popcount("52638927634234"));
12var_dump(gmp_popcount("-23476123423433"));
13$n = gmp_init("9876546789222");
14var_dump(gmp_popcount($n));
15
16try {
17    var_dump(gmp_popcount(array()));
18} catch (\TypeError $e) {
19    echo $e->getMessage() . \PHP_EOL;
20}
21
22echo "Done\n";
23?>
24--EXPECT--
25int(-1)
26int(0)
27int(10)
28int(31)
29int(-1)
30int(20)
31gmp_popcount(): Argument #1 ($num) must be of type GMP|string|int, array given
32Done
33