-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add required extension: ext-gmp * update the PHP version * remove checking PHP 5.6 * add allow_failure for hhvm and 5.6 * remove hhvm and php 5.6 * add the isPrimeNumber method. * modify the test prime number method
- Loading branch information
1 parent
7bf5273
commit d6dc1b3
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace PHP\Math\BigIntegerTest; | ||
|
||
use PHP\Math\BigInteger\BigInteger; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
class BigIntegerPrimeNumberTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testIsPrimeNumberWithouttPrimeNumber() | ||
{ | ||
// Arrange | ||
$bigInteger = new BigInteger('6'); | ||
|
||
// Act | ||
$withoutPrimeNumber = $bigInteger->isPrimeNumber(); | ||
|
||
// Assert | ||
$this::assertFalse($withoutPrimeNumber); | ||
} | ||
|
||
public function testIsPrimeNumberWithPrimeNumber() | ||
{ | ||
// Arrange | ||
$bigInteger = new BigInteger('11'); | ||
|
||
// Act | ||
$withPrimeNumber = $bigInteger->isPrimeNumber(); | ||
|
||
// Assert | ||
$this::assertTrue($withPrimeNumber); | ||
} | ||
|
||
public function testIsPrimeNumberWithoutProbabilePrimeNumber() | ||
{ | ||
// Arrange | ||
$bigInteger = new BigInteger('1111111111111111111'); | ||
|
||
// Act | ||
$probabilePrimeNumber = $bigInteger->isPrimeNumber(); | ||
|
||
// Assert | ||
$this::assertTrue($probabilePrimeNumber); | ||
} | ||
|
||
/** | ||
* @expectedException InvalidArgumentException | ||
*/ | ||
public function testIsPrimeNumberProvidedProbabilityNumberIsLessThan5() | ||
{ | ||
// Arrange | ||
$bigInteger = new BigInteger('1111111111111111111'); | ||
|
||
// Act | ||
$probabilePrimeNumber = $bigInteger->isPrimeNumber(-1.0); | ||
|
||
// Assert | ||
// ... | ||
} | ||
|
||
/** | ||
* @expectedException InvalidArgumentException | ||
*/ | ||
public function testIsPrimeNumberProvidedProbabilityNumberIsGreaterThan10() | ||
{ | ||
// Arrange | ||
$bigInteger = new BigInteger('1111111111111111111'); | ||
|
||
// Act | ||
$probabilePrimeNumber = $bigInteger->isPrimeNumber(2.0); | ||
|
||
// Assert | ||
// ... | ||
} | ||
} |