ExceptionTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace MathPHP\Tests\Exception;
  3. use MathPHP\Exception;
  4. class ExceptionTest extends \PHPUnit\Framework\TestCase
  5. {
  6. /**
  7. * @test BadDataException
  8. */
  9. public function testBadDataException()
  10. {
  11. // Given
  12. $e = new Exception\BadDataException('message');
  13. // Then
  14. $this->assertInstanceOf(Exception\MathException::class, $e);
  15. }
  16. /**
  17. * @test BadParameterException
  18. */
  19. public function testBadParameterException()
  20. {
  21. // Given
  22. $e = new Exception\BadParameterException('message');
  23. // Then
  24. $this->assertInstanceOf(Exception\MathException::class, $e);
  25. }
  26. /**
  27. * @test DivisionByZeroException
  28. */
  29. public function testDivisionByZeroException()
  30. {
  31. // Given
  32. $e = new Exception\DivisionByZeroException('message');
  33. // Then
  34. $this->assertInstanceOf(Exception\MathException::class, $e);
  35. }
  36. /**
  37. * @test FunctionFailedToConvergeException
  38. */
  39. public function testFunctionFailedToConvergeException()
  40. {
  41. // Given
  42. $e = new Exception\FunctionFailedToConvergeException('message');
  43. // Then
  44. $this->assertInstanceOf(Exception\MathException::class, $e);
  45. }
  46. /**
  47. * @test IncorrectTypeException
  48. */
  49. public function testIncorrectTypeException()
  50. {
  51. // Given
  52. $e = new Exception\IncorrectTypeException('message');
  53. // Then
  54. $this->assertInstanceOf(Exception\MathException::class, $e);
  55. }
  56. /**
  57. * @test MathException
  58. */
  59. public function testMathException()
  60. {
  61. // Given
  62. $e = new Exception\MathException('message');
  63. // Then
  64. $this->assertInstanceOf(\Exception::class, $e);
  65. }
  66. /**
  67. * @test MatrixException
  68. */
  69. public function testMatrixException()
  70. {
  71. // Given
  72. $e = new Exception\MatrixException('message');
  73. // Then
  74. $this->assertInstanceOf(Exception\MathException::class, $e);
  75. }
  76. /**
  77. * @test NanException
  78. */
  79. public function testNanException()
  80. {
  81. // Given
  82. $e = new Exception\NanException('message');
  83. // Then
  84. $this->assertInstanceOf(Exception\MathException::class, $e);
  85. }
  86. /**
  87. * @test OutOfBoundsException
  88. */
  89. public function testOutOfBoundsException()
  90. {
  91. // Given
  92. $e = new Exception\OutOfBoundsException('message');
  93. // Then
  94. $this->assertInstanceOf(Exception\MathException::class, $e);
  95. }
  96. /**
  97. * @test SingularMatrixException
  98. */
  99. public function testSingularMatrixException()
  100. {
  101. // Given
  102. $e = new Exception\SingularMatrixException('message');
  103. // Then
  104. $this->assertInstanceOf(Exception\MatrixException::class, $e);
  105. $this->assertInstanceOf(Exception\MathException::class, $e);
  106. }
  107. /**
  108. * @test VectorException
  109. */
  110. public function testVectorException()
  111. {
  112. // Given
  113. $e = new Exception\VectorException('message');
  114. // Then
  115. $this->assertInstanceOf(Exception\MathException::class, $e);
  116. }
  117. }