AcotTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. class AcotTest extends AllSetupTeardown
  5. {
  6. /**
  7. * @dataProvider providerACOT
  8. *
  9. * @param mixed $expectedResult
  10. * @param mixed $number
  11. */
  12. public function testACOT($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', -5);
  20. $sheet->getCell('A1')->setValue("=ACOT($number)");
  21. $result = $sheet->getCell('A1')->getCalculatedValue();
  22. self::assertEqualsWithDelta($expectedResult, $result, 1E-9);
  23. }
  24. public function providerACOT(): array
  25. {
  26. return require 'tests/data/Calculation/MathTrig/ACOT.php';
  27. }
  28. /**
  29. * @dataProvider providerAcotArray
  30. */
  31. public function testAcotArray(array $expectedResult, string $array): void
  32. {
  33. $calculation = Calculation::getInstance();
  34. $formula = "=ACOT({$array})";
  35. $result = $calculation->_calculateFormulaValue($formula);
  36. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  37. }
  38. public function providerAcotArray(): array
  39. {
  40. return [
  41. 'row vector' => [[[0.78539816339745, 1.10714871779409, 2.35619449019234]], '{1, 0.5, -1}'],
  42. 'column vector' => [[[0.78539816339745], [1.10714871779409], [2.35619449019234]], '{1; 0.5; -1}'],
  43. 'matrix' => [[[0.78539816339745, 1.10714871779409], [1.57079632679490, 2.35619449019234]], '{1, 0.5; 0, -1}'],
  44. ];
  45. }
  46. }