AsinTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. class AsinTest extends AllSetupTeardown
  5. {
  6. /**
  7. * @dataProvider providerAsin
  8. *
  9. * @param mixed $expectedResult
  10. */
  11. public function testAsin($expectedResult, string $formula): void
  12. {
  13. $this->mightHaveException($expectedResult);
  14. $sheet = $this->getSheet();
  15. $sheet->getCell('A2')->setValue(0.5);
  16. $sheet->getCell('A1')->setValue("=ASIN($formula)");
  17. $result = $sheet->getCell('A1')->getCalculatedValue();
  18. self::assertEqualsWithDelta($expectedResult, $result, 1E-6);
  19. }
  20. public function providerAsin(): array
  21. {
  22. return require 'tests/data/Calculation/MathTrig/ASIN.php';
  23. }
  24. /**
  25. * @dataProvider providerAsinArray
  26. */
  27. public function testAsinArray(array $expectedResult, string $array): void
  28. {
  29. $calculation = Calculation::getInstance();
  30. $formula = "=ASIN({$array})";
  31. $result = $calculation->_calculateFormulaValue($formula);
  32. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  33. }
  34. public function providerAsinArray(): array
  35. {
  36. return [
  37. 'row vector' => [[[1.57079632679490, 0.52359877559830, -1.57079632679490]], '{1, 0.5, -1}'],
  38. 'column vector' => [[[1.57079632679490], [0.52359877559830], [-1.57079632679490]], '{1; 0.5; -1}'],
  39. 'matrix' => [[[1.57079632679490, 0.52359877559830], [0.0, -1.57079632679490]], '{1, 0.5; 0, -1}'],
  40. ];
  41. }
  42. }