xref: /PHP-8.4/ext/gmp/tests/gmp_init.phpt (revision 4719ef25)
1--TEST--
2gmp_init() basic tests
3--EXTENSIONS--
4gmp
5--FILE--
6<?php
7
8var_dump(gmp_init("98765678"));
9var_dump(gmp_strval(gmp_init("98765678")));
10try {
11    var_dump(gmp_init(1,-1));
12} catch (\ValueError $e) {
13    echo $e->getMessage() . \PHP_EOL;
14}
15
16try {
17    var_dump(gmp_init("",36));
18} catch (\ValueError $e) {
19    echo $e->getMessage() . \PHP_EOL;
20}
21try {
22    var_dump(gmp_init("foo",3));
23} catch (\ValueError $e) {
24    echo $e->getMessage() . \PHP_EOL;
25}
26try {
27    var_dump(gmp_strval(gmp_init("993247326237679187178",3)));
28} catch (\ValueError $e) {
29    echo $e->getMessage() . \PHP_EOL;
30}
31
32echo "Done\n";
33?>
34--EXPECT--
35object(GMP)#1 (1) {
36  ["num"]=>
37  string(8) "98765678"
38}
39string(8) "98765678"
40gmp_init(): Argument #2 ($base) must be 0 or between 2 and 62
41gmp_init(): Argument #1 ($num) is not an integer string
42gmp_init(): Argument #1 ($num) is not an integer string
43gmp_init(): Argument #1 ($num) is not an integer string
44Done
45