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