xref: /PHP-5.6/ext/gmp/tests/gmp_strval.phpt (revision 9586b152)
1--TEST--
2gmp_strval() tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8var_dump(gmp_strval());
9var_dump(gmp_strval(""));
10var_dump(gmp_strval("", ""));
11var_dump(gmp_strval("", -1));
12var_dump(gmp_strval(-1, ""));
13
14$fp = fopen(__FILE__, "r");
15var_dump(gmp_strval($fp));
16
17$g = gmp_init("9765456");
18var_dump(gmp_strval($g));
19var_dump(gmp_strval($g, -1));
20var_dump(gmp_strval($g, 100000));
21var_dump(gmp_strval($g, 10));
22
23$g = gmp_init("-3373333");
24var_dump(gmp_strval($g));
25var_dump(gmp_strval($g, -1));
26var_dump(gmp_strval($g, 100000));
27var_dump(gmp_strval($g, 10));
28
29var_dump(gmp_strval(array(1,2), array(1,2)));
30var_dump(gmp_strval(new stdclass, new stdclass));
31var_dump(gmp_strval(array(1,2)));
32var_dump(gmp_strval(new stdclass));
33
34echo "Done\n";
35?>
36--EXPECTF--
37Warning: gmp_strval() expects at least 1 parameter, 0 given in %s on line %d
38NULL
39
40Warning: gmp_strval(): Unable to convert variable to GMP - string is not an integer in %s on line %d
41bool(false)
42
43Warning: gmp_strval() expects parameter 2 to be long, string given in %s on line %d
44NULL
45
46Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line %d
47bool(false)
48
49Warning: gmp_strval() expects parameter 2 to be long, string given in %s on line %d
50NULL
51
52Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d
53bool(false)
54string(7) "9765456"
55
56Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line %d
57bool(false)
58
59Warning: gmp_strval(): Bad base for conversion: 100000 (should be between 2 and %d or -2 and -%d) in %s on line %d
60bool(false)
61string(7) "9765456"
62string(8) "-3373333"
63
64Warning: gmp_strval(): Bad base for conversion: -1 (should be between 2 and %d or -2 and -%d) in %s on line %d
65bool(false)
66
67Warning: gmp_strval(): Bad base for conversion: 100000 (should be between 2 and %d or -2 and -%d) in %s on line %d
68bool(false)
69string(8) "-3373333"
70
71Warning: gmp_strval() expects parameter 2 to be long, array given in %s on line %d
72NULL
73
74Warning: gmp_strval() expects parameter 2 to be long, object given in %s on line %d
75NULL
76
77Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d
78bool(false)
79
80Warning: gmp_strval(): Unable to convert variable to GMP - wrong type in %s on line %d
81bool(false)
82Done
83