1
0
mirror of https://github.com/php/php-src.git synced 2026-04-19 14:01:01 +02:00
Files
archived-php-src/ext/standard/tests/random/random_int.phpt
Nikita Popov 265af40a0a Use unsigned subtraction in php_random_int()
This subtraction may overflow the signed domain, which is UB. Use
an unsigned subtraction instead.
2019-09-03 12:28:18 +02:00

25 lines
410 B
PHP

--TEST--
Test normal operation of random_int()
--FILE--
<?php
var_dump(is_int(random_int(10, 100)));
$x = random_int(10, 100);
var_dump($x >= 10 && $x <= 100);
var_dump(random_int(-1000, -1) < 0);
var_dump(random_int(-1, PHP_INT_MAX) >= -1);
var_dump(is_int(random_int(PHP_INT_MIN, PHP_INT_MAX)));
var_dump(random_int(42,42));
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
int(42)