diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/RandomBytesTest.php | 13 | ||||
-rw-r--r-- | tests/unit/RandomIntTest.php | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/tests/unit/RandomBytesTest.php b/tests/unit/RandomBytesTest.php index 94d154a..0b3c3eb 100644 --- a/tests/unit/RandomBytesTest.php +++ b/tests/unit/RandomBytesTest.php @@ -37,5 +37,16 @@ class RandomBytesTest extends PHPUnit_Framework_TestCase } catch (Exception $ex) { $this->assertTrue(true); } + + try { + $x = random_bytes(PHP_INT_MAX + 1000000000); + $this->assertTrue(false); + } catch (TypeError $ex) { + $this->assertTrue(true); + } catch (Error $ex) { + $this->assertTrue(true); + } catch (Exception $ex) { + $this->assertTrue(true); + } } -}
\ No newline at end of file +} diff --git a/tests/unit/RandomIntTest.php b/tests/unit/RandomIntTest.php index 55a3306..6a2ab9a 100644 --- a/tests/unit/RandomIntTest.php +++ b/tests/unit/RandomIntTest.php @@ -35,8 +35,10 @@ class RandomIntTest extends PHPUnit_Framework_TestCase $this->assertTrue($integers[9] === -4); try { - $i = random_int("9223372036854775808","9223372036854775807"); + $i = random_int("9223372036854775808", "9223372036854775807"); $this->assertFalse(is_int($i)); + $i = random_int("-9223372036854775808", "9223372036854775807"); + $this->assertFalse(true); } catch (Error $ex) { $this->assertTrue($ex instanceof Error); } catch (Exception $ex) { |