summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2013-07-30 18:46:02 +0200
committerChristopher Smith <chris@jalakai.co.uk>2013-08-01 11:11:51 +0200
commitb40098c3d8f4a41b62694ccd1e660c26301d6df0 (patch)
tree45e56c823124a73688f2061947469d1029079ad3 /_test
parentf2bbf30b71b15efa7a918944b4ffc74f8b1747a9 (diff)
downloadrpg-b40098c3d8f4a41b62694ccd1e660c26301d6df0.tar.gz
rpg-b40098c3d8f4a41b62694ccd1e660c26301d6df0.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.php20
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');
+ }
+}