AcothTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. class AcothTest extends AllSetupTeardown
  5. {
  6. /**
  7. * @dataProvider providerACOTH
  8. *
  9. * @param mixed $expectedResult
  10. * @param mixed $number
  11. */
  12. public function testACOTH($expectedResult, $number): void
  13. {
  14. $this->mightHaveException($expectedResult);
  15. $sheet = $this->getSheet();
  16. $sheet->setCellValue('A2', 1.3);
  17. $sheet->setCellValue('A3', 2.7);
  18. $sheet->setCellValue('A4', -3.8);
  19. $sheet->setCellValue('A5', -10);
  20. $sheet->getCell('A1')->setValue("=ACOTH($number)");
  21. $result = $sheet->getCell('A1')->getCalculatedValue();
  22. self::assertEqualsWithDelta($expectedResult, $result, 1E-9);
  23. }
  24. public function providerACOTH(): array
  25. {
  26. return require 'tests/data/Calculation/MathTrig/ACOTH.php';
  27. }
  28. /**
  29. * @dataProvider providerAcothArray
  30. */
  31. public function testAcothArray(array $expectedResult, string $array): void
  32. {
  33. $calculation = Calculation::getInstance();
  34. $formula = "=ACOTH({$array})";
  35. $result = $calculation->_calculateFormulaValue($formula);
  36. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  37. }
  38. public function providerAcothArray(): array
  39. {
  40. return [
  41. 'row vector' => [[[-0.20273255405408, 0.54930614433406, 0.13413199329734]], '{-5, 2, 7.5}'],
  42. 'column vector' => [[[-0.20273255405408], [0.54930614433406], [0.13413199329734]], '{-5; 2; 7.5}'],
  43. 'matrix' => [[[-0.20273255405408, 0.54930614433406], ['#NUM!', 0.13413199329734]], '{-5, 2; 0, 7.5}'],
  44. ];
  45. }
  46. }