summaryrefslogtreecommitdiff
path: root/_test/tests/inc/auth_random.test.php
blob: f380eba537fec7fc1c00e4b9aec8e056e791e0c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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');
    }
}