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