diff options
author | Andreas Fischer <bantu@phpbb.com> | 2011-03-05 22:16:50 +0100 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2011-03-05 22:16:50 +0100 |
commit | 5ab4dc298327d3a8d51387959d6905c6bb24fd99 (patch) | |
tree | 6b560d2512e5fbe20d1d9db5203045d276c874f1 /tests/random | |
parent | afae883619eb7d193b413b5599078a6f47ead408 (diff) | |
download | forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar.gz forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar.bz2 forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.tar.xz forums-5ab4dc298327d3a8d51387959d6905c6bb24fd99.zip |
[ticket/10042] Add mt_rand() wrapper which allows swapping $min and $max.
PHPBB3-10042
Diffstat (limited to 'tests/random')
-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); + } +} |