diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/MathTest.php | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php index db6e486..df073b2 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -11,7 +11,15 @@ namespace NXP\Tests; -use \NXP\MathExecutor; +use NXP\MathExecutor; +use NXP\Exception\DivisionByZeroException; +use NXP\Exception\IncorrectBracketsException; +use NXP\Exception\IncorrectExpressionException; +use NXP\Exception\MathExecutorException; +use NXP\Exception\UnknownFunctionException; +use NXP\Exception\UnknownOperatorException; +use NXP\Exception\UnknownTokenException; +use NXP\Exception\UnknownVariableException; class MathTest extends \PHPUnit_Framework_TestCase { @@ -27,10 +35,25 @@ class MathTest extends \PHPUnit_Framework_TestCase $this->assertEquals($calculator->execute($expression), $phpResult); } + public function testUnknownFunctionException() + { + $calculator = new MathExecutor(); + $this->expectException(UnknownFunctionException::class); + $calculator->execute('1 * fred("wilma") + 3'); + } + + public function testIncorrectExpressionException() + { + $calculator = new MathExecutor(); + $this->expectException(IncorrectExpressionException::class); + $calculator->execute('1 * + '); + } + public function testZeroDivision() { $calculator = new MathExecutor(); - $this->assertEquals($calculator->execute('1 / 0'), 0); + $this->expectException(DivisionByZeroException::class); + $calculator->execute('1 / 0'); } public function testExponentiation() |