summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott <scott@paragonie.com>2015-12-31 13:05:52 -0500
committerScott <scott@paragonie.com>2015-12-31 13:05:52 -0500
commit23c7913e450e6d194a53f31b04dee64184b476b2 (patch)
treea7f4fe32a47d2206ffd41277b915b6571cc83666
parentd762ee5b099a29044603cd4649851e81aa66cb47 (diff)
parentf27e710b70ea957b1d081b733441947f24b8c10c (diff)
downloadrandom_compat-23c7913e450e6d194a53f31b04dee64184b476b2.zip
random_compat-23c7913e450e6d194a53f31b04dee64184b476b2.tar.gz
random_compat-23c7913e450e6d194a53f31b04dee64184b476b2.tar.bz2
Merge pull request #84 from nicolas-grekas/atest
Add RandomIntTest::testRandomRange
-rw-r--r--.travis.yml30
-rw-r--r--tests/unit/RandomIntTest.php11
2 files changed, 24 insertions, 17 deletions
diff --git a/.travis.yml b/.travis.yml
index 43ec127..eee4a11 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,26 +1,22 @@
language: php
-php:
-
-- "7.0"
-- "5.6"
-- "5.5"
-- "5.4"
-- "5.3"
-- "hhvm"
-
-
sudo: false
+php:
+ - "7.0"
+ - "5.6"
+ - "5.5"
+ - "5.4"
+ - "5.3"
+ - "hhvm"
+
matrix:
fast_finish: true
allow_failures:
- - php: "hhvm"
+ - php: "hhvm"
install:
+ - composer self-update
+ - composer update
-- composer install
-- composer self-update
-- composer update
-- chmod +x ./phpunit.sh
-
-script: ./phpunit.sh travis
+script:
+ - ./phpunit.sh
diff --git a/tests/unit/RandomIntTest.php b/tests/unit/RandomIntTest.php
index f9fc3c3..6b94a99 100644
--- a/tests/unit/RandomIntTest.php
+++ b/tests/unit/RandomIntTest.php
@@ -49,4 +49,15 @@ class RandomIntTest extends PHPUnit_Framework_TestCase
$this->assertTrue($ex instanceof Exception);
}
}
+
+ public function testRandomRange()
+ {
+ $try = 64;
+ $maxLen = strlen(~PHP_INT_MAX);
+ do {
+ $rand = random_int(~PHP_INT_MAX, PHP_INT_MAX);
+ } while (strlen($rand) !== $maxLen && $try--);
+
+ $this->assertGreaterThan(0, $try);
+ }
}