xref: /PHP-7.2/ext/gmp/tests/gmp_xor.phpt (revision 17ccbeec)
1--TEST--
2gmp_xor() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_xor("111111", "2222222")));
9var_dump(gmp_strval(gmp_xor(123123, 435234)));
10var_dump(gmp_strval(gmp_xor(555, "2342341123")));
11var_dump(gmp_strval(gmp_xor(-1, 3333)));
12var_dump(gmp_strval(gmp_xor(4545, -20)));
13var_dump(gmp_strval(gmp_xor("test", "no test")));
14
15$n = gmp_init("987657876543456");
16var_dump(gmp_strval(gmp_xor($n, "34332")));
17$n1 = gmp_init("987657878765436543456");
18var_dump(gmp_strval(gmp_xor($n, $n1)));
19
20var_dump(gmp_xor($n, $n1, 1));
21var_dump(gmp_xor(1));
22var_dump(gmp_xor(array(), 1));
23var_dump(gmp_xor(1, array()));
24var_dump(gmp_xor(array(), array()));
25
26echo "Done\n";
27?>
28--EXPECTF--
29string(7) "2120329"
30string(6) "476369"
31string(10) "2342340648"
32string(5) "-3334"
33string(5) "-4563"
34
35Warning: gmp_xor(): Unable to convert variable to GMP - string is not an integer in %s on line %d
36string(1) "0"
37string(15) "987657876574716"
38string(21) "987658017016065701376"
39
40Warning: gmp_xor() expects exactly 2 parameters, 3 given in %s on line %d
41NULL
42
43Warning: gmp_xor() expects exactly 2 parameters, 1 given in %s on line %d
44NULL
45
46Warning: gmp_xor(): Unable to convert variable to GMP - wrong type in %s on line %d
47bool(false)
48
49Warning: gmp_xor(): Unable to convert variable to GMP - wrong type in %s on line %d
50bool(false)
51
52Warning: gmp_xor(): Unable to convert variable to GMP - wrong type in %s on line %d
53bool(false)
54Done
55