diff options
| author | Nils Adermann <naderman@naderman.de> | 2011-06-05 03:22:09 +0200 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2011-06-05 03:22:09 +0200 |
| commit | 893d0ae96f4fba26a10b909d39abe952601bca41 (patch) | |
| tree | dc9a81f1ee6f492c7c70cbf5aa02c75a5761e0fa /tests | |
| parent | ffc137986fa9ba91ebc4bc203c7081409d46c44c (diff) | |
| parent | 18daf6345f64e59f651c43a3150d9e139ac2a4cc (diff) | |
| download | forums-893d0ae96f4fba26a10b909d39abe952601bca41.tar forums-893d0ae96f4fba26a10b909d39abe952601bca41.tar.gz forums-893d0ae96f4fba26a10b909d39abe952601bca41.tar.bz2 forums-893d0ae96f4fba26a10b909d39abe952601bca41.tar.xz forums-893d0ae96f4fba26a10b909d39abe952601bca41.zip | |
Merge branch 'ticket/bantu/10042' into develop-olympus
* ticket/bantu/10042:
[ticket/10042] GD CAPTCHA: Call phpbb_mt_rand() where required.
[ticket/10042] GD CAPTCHA: Round offset to the next pixel.
[ticket/10042] Add mt_rand() wrapper which allows swapping $min and $max.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/random/mt_rand.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/random/mt_rand.php b/tests/random/mt_rand.php new file mode 100644 index 0000000000..d6502c4e80 --- /dev/null +++ b/tests/random/mt_rand.php @@ -0,0 +1,46 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_random_mt_rand_test extends phpbb_test_case +{ + public function test_max_equals_min() + { + $result = phpbb_mt_rand(42, 42); + $this->assertEquals(42, $result); + } + + public function test_max_equals_min_negative() + { + $result = phpbb_mt_rand(-42, -42); + $this->assertEquals(-42, $result); + } + + public function test_max_greater_min() + { + $result = phpbb_mt_rand(3, 4); + $this->assertGreaterThanOrEqual(3, $result); + $this->assertLessThanOrEqual(4, $result); + } + + public function test_min_greater_max() + { + $result = phpbb_mt_rand(4, 3); + $this->assertGreaterThanOrEqual(3, $result); + $this->assertLessThanOrEqual(4, $result); + } + + public function test_min_greater_max_negative() + { + $result = phpbb_mt_rand(-3, -4); + $this->assertGreaterThanOrEqual(-4, $result); + $this->assertLessThanOrEqual(-3, $result); + } +} |
