xref: /PHP-8.2/ext/gmp/tests/gmp_setbit_long.phpt (revision e9f783fc)
1--TEST--
2gmp_setbit() with large index
3--EXTENSIONS--
4gmp
5--SKIPIF--
6<?php if (getenv("TRAVIS") === "true") die("skip not suitable for Travis-CI"); ?>
7<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
8<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?>
9<?php
10    /* This test requires about 8G RAM which likely not to be present on an arbitrary CI. */
11    if (!file_exists("/proc/meminfo")) {
12        die("skip cannot determine free memory amount.");
13    }
14    $s = file_get_contents("/proc/meminfo");
15    $free = 0;
16    if (preg_match(",MemFree:\s+(\d+)\s+kB,", $s, $m)) {
17        /* Got amount in kb. */
18        $free = $m[1]/1024/1024;
19    }
20    if ($free < 8) {
21        die("skip not enough free RAM.");
22    }
23?>
24--FILE--
25<?php
26
27$n = gmp_init("227200");
28for($a = 1<<30; $a > 0 && $a < 0x8000000000; $a <<= 2) {
29    $i = $a - 1;
30    printf("%X\n", $i);
31    try {
32        gmp_setbit($n, $i, 1);
33    } catch (\ValueError $e) {
34        echo $e->getMessage() . \PHP_EOL;
35    }
36}
37echo "Done\n";
38?>
39--EXPECTF--
403FFFFFFF
41FFFFFFFF
423FFFFFFFF
43FFFFFFFFF
443FFFFFFFFF
45gmp_setbit(): Argument #2 ($index) must be less than %d * %d
46Done
47