diff options
author | Scott <scott@paragonie.com> | 2015-10-15 17:24:07 -0400 |
---|---|---|
committer | Scott <scott@paragonie.com> | 2015-10-15 17:24:07 -0400 |
commit | e0460f53d0bada56d3fc18f1d9c4ec23e390682d (patch) | |
tree | 1cbb23574ad278bec912a119dd37a73c3023ef94 /tests | |
parent | 5bf38c690cbaee341a96d77aa96747dfd60fd44c (diff) | |
download | random_compat-e0460f53d0bada56d3fc18f1d9c4ec23e390682d.zip random_compat-e0460f53d0bada56d3fc18f1d9c4ec23e390682d.tar.gz random_compat-e0460f53d0bada56d3fc18f1d9c4ec23e390682d.tar.bz2 |
Even more assertions and edge cases.
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) { |