xref: /PHP-8.0/ext/gmp/tests/gmp_scan0.phpt (revision 25198277)
1--TEST--
2gmp_scan0() basic tests
3--SKIPIF--
4<?php if (!extension_loaded("gmp")) print "skip"; ?>
5--FILE--
6<?php
7
8try {
9    var_dump(gmp_scan0("434234", -10));
10} catch (\ValueError $e) {
11    echo $e->getMessage() . \PHP_EOL;
12}
13
14var_dump(gmp_scan0("434234", 1));
15var_dump(gmp_scan0(4096, 0));
16var_dump(gmp_scan0("1000000000", 5));
17var_dump(gmp_scan0("1000000000", 200));
18
19$n = gmp_init("24234527465274");
20var_dump(gmp_scan0($n, 10));
21
22try {
23    var_dump(gmp_scan0(array(), 200));
24} catch (\TypeError $e) {
25    echo $e->getMessage() . \PHP_EOL;
26}
27
28echo "Done\n";
29?>
30--EXPECT--
31gmp_scan0(): Argument #2 ($start) must be greater than or equal to 0
32int(2)
33int(0)
34int(5)
35int(200)
36int(13)
37gmp_scan0(): Argument #1 ($num1) must be of type GMP|string|int, array given
38Done
39