xref: /PHP-7.3/ext/gmp/tests/gmp_setbit.phpt (revision 581c86c0)
1--TEST--
2gmp_setbit() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8$n = gmp_init(-1);
9gmp_setbit($n, 10, -1);
10var_dump(gmp_strval($n));
11
12$n = gmp_init(5);
13var_dump(gmp_setbit($n, -20, 0));
14var_dump(gmp_strval($n));
15
16$n = gmp_init(5);
17gmp_setbit($n, 2, 0);
18var_dump(gmp_strval($n));
19
20$n = gmp_init(5);
21gmp_setbit($n, 1, 1);
22var_dump(gmp_strval($n));
23
24$n = gmp_init("100000000000");
25gmp_setbit($n, 23, 1);
26var_dump(gmp_strval($n));
27
28gmp_setbit($n, 23, 0);
29var_dump(gmp_strval($n));
30
31gmp_setbit($n, 3);
32var_dump(gmp_strval($n));
33
34$b = "";
35gmp_setbit($b, 23);
36gmp_setbit($b);
37gmp_setbit($b, 23,1,1);
38gmp_setbit($b,array());
39$a = array();
40gmp_setbit($a,array());
41
42echo "Done\n";
43?>
44--EXPECTF--
45string(2) "-1"
46
47Warning: gmp_setbit(): Index must be greater than or equal to zero in %s on line %d
48bool(false)
49string(1) "5"
50string(1) "1"
51string(1) "7"
52string(12) "100008388608"
53string(12) "100000000000"
54string(12) "100000000008"
55
56Warning: gmp_setbit() expects parameter 1 to be GMP, string given in %s on line %d
57
58Warning: gmp_setbit() expects at least 2 parameters, 1 given in %s on line %d
59
60Warning: gmp_setbit() expects at most 3 parameters, 4 given in %s on line %d
61
62Warning: gmp_setbit() expects parameter 1 to be GMP, string given in %s on line %d
63
64Warning: gmp_setbit() expects parameter 1 to be GMP, array given in %s on line %d
65Done
66