diff options
author | Scott <scott@paragonie.com> | 2015-10-12 15:44:49 -0400 |
---|---|---|
committer | Scott <scott@paragonie.com> | 2015-10-15 13:55:22 -0400 |
commit | 658ce5ce0a22fbf55e4f4d4fb4b4253fcb75a1cc (patch) | |
tree | 8091b05477b1e7f9609843e599cfcaea56e9b148 /tests/unit/RandomIntTest.php | |
parent | 2657b8b3114e83cb72444362c11d02cf2dba22ad (diff) | |
download | random_compat-658ce5ce0a22fbf55e4f4d4fb4b4253fcb75a1cc.zip random_compat-658ce5ce0a22fbf55e4f4d4fb4b4253fcb75a1cc.tar.gz random_compat-658ce5ce0a22fbf55e4f4d4fb4b4253fcb75a1cc.tar.bz2 |
Use \Sodium\randombytes_uniform() for random_int()
Diffstat (limited to 'tests/unit/RandomIntTest.php')
-rw-r--r-- | tests/unit/RandomIntTest.php | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/unit/RandomIntTest.php b/tests/unit/RandomIntTest.php index f8cbdf9..5b5522d 100644 --- a/tests/unit/RandomIntTest.php +++ b/tests/unit/RandomIntTest.php @@ -8,6 +8,7 @@ class RandomIntTest extends PHPUnit_Framework_TestCase public function testOutput() { + $half_neg_max = (~PHP_INT_MAX / 2); $integers = array( random_int(0, 1000), random_int(1001,2000), @@ -16,6 +17,7 @@ class RandomIntTest extends PHPUnit_Framework_TestCase random_int(~PHP_INT_MAX, PHP_INT_MAX), random_int("0", "1"), random_int(0.11111, 0.99999), + random_int($half_neg_max, PHP_INT_MAX), ); $this->assertFalse($integers[0] === $integers[1]); @@ -26,5 +28,6 @@ class RandomIntTest extends PHPUnit_Framework_TestCase $this->assertTrue($integers[4] >= ~PHP_INT_MAX && $integers[4] <= PHP_INT_MAX); $this->assertTrue($integers[5] >= 0 && $integers[5] <= 1); $this->assertTrue($integers[6] === 0); + $this->assertTrue($integers[7] >= $half_neg_max && $integers[7] <= PHP_INT_MAX); } } |