ExponDistTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
  3. use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
  4. use PhpOffice\PhpSpreadsheet\Calculation\Functions;
  5. use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
  6. use PHPUnit\Framework\TestCase;
  7. class ExponDistTest extends TestCase
  8. {
  9. protected function setUp(): void
  10. {
  11. Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
  12. }
  13. /**
  14. * @dataProvider providerEXPONDIST
  15. *
  16. * @param mixed $expectedResult
  17. */
  18. public function testEXPONDIST($expectedResult, ...$args): void
  19. {
  20. $result = Statistical::EXPONDIST(...$args);
  21. self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
  22. }
  23. public function providerEXPONDIST(): array
  24. {
  25. return require 'tests/data/Calculation/Statistical/EXPONDIST.php';
  26. }
  27. /**
  28. * @dataProvider providerExponDistArray
  29. */
  30. public function testExponDistArray(array $expectedResult, string $values, string $lambdas): void
  31. {
  32. $calculation = Calculation::getInstance();
  33. $formula = "=EXPONDIST({$values}, {$lambdas}, false)";
  34. $result = $calculation->_calculateFormulaValue($formula);
  35. self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14);
  36. }
  37. public function providerExponDistArray(): array
  38. {
  39. return [
  40. 'row/column vectors' => [
  41. [
  42. [1.646434908282079, 0.6693904804452895, 0.2721538598682374],
  43. [1.353352832366127, 0.06737946999085467, 0.003354626279025118],
  44. ],
  45. '{0.2, 0.5, 0.8}',
  46. '{3; 10}',
  47. ],
  48. ];
  49. }
  50. }