mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-27 01:48:26 +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.
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
|
use PhpOffice\PhpSpreadsheet\Calculation\Engineering;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ErfCTest extends TestCase
|
|
{
|
|
const ERF_PRECISION = 1E-12;
|
|
|
|
/**
|
|
* @dataProvider providerERFC
|
|
*
|
|
* @param mixed $lower
|
|
* @param mixed $expectedResult
|
|
*/
|
|
public function testERFC($expectedResult, $lower): void
|
|
{
|
|
$result = Engineering::ERFC($lower);
|
|
self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION);
|
|
}
|
|
|
|
public function providerERFC(): array
|
|
{
|
|
return require 'tests/data/Calculation/Engineering/ERFC.php';
|
|
}
|
|
|
|
/**
|
|
* @dataProvider providerErfCArray
|
|
*/
|
|
public function testErfCArray(array $expectedResult, string $lower): void
|
|
{
|
|
$calculation = Calculation::getInstance();
|
|
|
|
$formula = "=ERFC({$lower})";
|
|
$result = $calculation->_calculateFormulaValue($formula);
|
|
self::assertEqualsWithDelta($expectedResult, $result, self::ERF_PRECISION);
|
|
}
|
|
|
|
public function providerErfCArray(): array
|
|
{
|
|
return [
|
|
'row vector' => [
|
|
[
|
|
[1.9103139782296354, 1.5204998778130465, 1.0, 0.7236736098317631, 0.0004069520174449588],
|
|
],
|
|
'{-1.2, -0.5, 0.0, 0.25, 2.5}',
|
|
],
|
|
];
|
|
}
|
|
}
|