xref: /PHP-7.1/ext/gmp/tests/gmp_random.phpt (revision 7af945e2)
1--TEST--
2gmp_random() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval(gmp_random()));
9var_dump(gmp_strval(gmp_random(-1)));
10var_dump(gmp_strval(gmp_random(0)));
11var_dump(gmp_strval(gmp_random(10)));
12var_dump(gmp_strval(gmp_random("-10")));
13var_dump(gmp_strval(gmp_random(-10)));
14
15var_dump(gmp_random(array()));
16var_dump(gmp_random(array(),1));
17var_dump(gmp_random(""));
18var_dump(gmp_random("test"));
19
20echo "Done\n";
21?>
22--EXPECTF--
23string(%d) "%d"
24string(%d) "%d"
25string(1) "%d"
26string(%d) "%d"
27string(%d) "%d"
28string(%d) "%d"
29
30Warning: gmp_random() expects parameter 1 to be integer, array given in %s on line %d
31NULL
32
33Warning: gmp_random() expects at most 1 parameter, 2 given in %s on line %d
34NULL
35
36Warning: gmp_random() expects parameter 1 to be integer, string given in %s on line %d
37NULL
38
39Warning: gmp_random() expects parameter 1 to be integer, string given in %s on line %d
40NULL
41Done
42