mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-02 05:27:44 +00:00
6c1651e995
* Floating-point Equality in Two Tests Merging a change today, Git reported failures that did not occur during "normal" unit testing. The merge still succeeded, but ... The problem was an error comparing float values for equal, and the inequality occurred beyond the 14th decimal digit. Change the tests in question, which incidentally were not part of the merged changed, to use assertEqualsWithDelta. * Egad - 112 More Precision-related Problems Spread across 9 test members.
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Engineering;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ErfTest extends TestCase
|
|
{
|
|
const ERF_PRECISION = 1E-12;
|
|
|
|
/**
|
|
* @dataProvider providerERF
|
|
*
|
|
* @param mixed $lower
|
|
* @param null|mixed $upper
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testERF($expectedResult, $lower, $upper = null): void
|
|
{
|
|
$result = Engineering::ERF($lower, $upper);
|
|
self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION);
|
|
}
|
|
|
|
public function providerERF(): array
|
|
{
|
|
return require 'tests/data/Calculation/Engineering/ERF.php';
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerErfArray
|
|
*/
|
|
public function testErfArray(array $expectedResult, string $lower, string $upper = 'NULL'): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$formula = "=ERF({$lower}, {$upper})";
|
|
$result = $calculation->_calculateFormulaValue($formula);
|
|
self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION);
|
|
}
|
|
|
|
public function providerErfArray(): array
|
|
{
|
|
return [
|
|
'row vector' => [
|
|
[
|
|
[-0.9103139782296353, -0.5204998778130465, 0.0, 0.2763263901682369, 0.999593047982555],
|
|
],
|
|
'{-1.2, -0.5, 0.0, 0.25, 2.5}',
|
|
],
|
|
];
|
|
}
|
|
}
|