diff options
author | Michael Hamann <michael@content-space.de> | 2013-07-30 18:46:02 +0200 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2013-07-30 18:55:18 +0200 |
commit | 483b6238a3599595a678f995b2c7c9e9f07a7ce7 (patch) | |
tree | 4f88535a4bc42abc8f667f6a3be8482a213c527e /_test | |
parent | 27058a053ea6ffa90fee7aaf26f81ab1109d6df3 (diff) | |
download | rpg-483b6238a3599595a678f995b2c7c9e9f07a7ce7.tar.gz rpg-483b6238a3599595a678f995b2c7c9e9f07a7ce7.tar.bz2 |
Add truly random numbers and use them in places where randomness matters
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/inc/auth_random.test.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/_test/tests/inc/auth_random.test.php b/_test/tests/inc/auth_random.test.php new file mode 100644 index 000000000..f380eba53 --- /dev/null +++ b/_test/tests/inc/auth_random.test.php @@ -0,0 +1,20 @@ +<?php + +/** + * Tests the random generator functions + */ +class auth_random_test extends DokuWikiTest { + function testRandomRange() { + $rand = auth_random(300, 2000); + $this->assertTrue($rand <= 2000, 'The generated number was above the limit'); + $this->assertTrue($rand >= 300, 'The generate number was too low'); + } + + function testLargeRandoms() { + $min = (1 << 30); + $max = $min + (1 << 33) + 17; + $rand = auth_random($min, $max); + $this->assertTrue($rand >= $min, 'The generated number was too low'); + $this->assertTrue($rand <= $max, 'The generated number was too high'); + } +} |