Additional statistical unit tests (#1818)

This commit is contained in:
Mark Baker 2021-01-31 16:42:17 +01:00 committed by GitHub
parent 5d309e982c
commit 18abae7245
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 149 additions and 0 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PHPUnit\Framework\TestCase;
class NegBinomDistTest extends TestCase
{
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
}
/**
* @dataProvider providerNEGBINOMDIST
*
* @param mixed $expectedResult
*/
public function testNEGBINOMDIST($expectedResult, ...$args): void
{
$result = Statistical::NEGBINOMDIST(...$args);
self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
}
public function providerNEGBINOMDIST()
{
return require 'tests/data/Calculation/Statistical/NEGBINOMDIST.php';
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PHPUnit\Framework\TestCase;
class PoissonTest extends TestCase
{
protected function setUp(): void
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
}
/**
* @dataProvider providerPOISSON
*
* @param mixed $expectedResult
*/
public function testPOISSON($expectedResult, ...$args): void
{
$result = Statistical::POISSON(...$args);
self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
}
public function providerPOISSON()
{
return require 'tests/data/Calculation/Statistical/POISSON.php';
}
}

View File

@ -16,6 +16,11 @@ return [
-2.5,
2,
],
[
0.0,
0.0,
1,
],
[
'#NUM!',
2.5,

View File

@ -21,6 +21,11 @@ return [
2.5,
-2,
],
[
0.0,
0.0,
1,
],
[
'#DIV/0!',
123.456,

View File

@ -21,6 +21,11 @@ return [
2.5,
-2,
],
[
0.0,
0.0,
1,
],
[
'#DIV/0!',
123.456,

View File

@ -0,0 +1,36 @@
<?php
return [
[
0.05504866037517786,
10, 5, 0.25,
],
[
0.047210693359375,
6, 12, 0.5,
],
[
0.0805901288986206,
12, 12, 0.5,
],
[
0.057564377784729004,
15, 12, 0.5,
],
[
'#VALUE!',
15, 12, 'NaN',
],
[
'#NUM!',
15, 12, -0.25,
],
[
'#NUM!',
-1, 1, 0.25,
],
[
'#NUM!',
1, 0.5, 0.25,
],
];

View File

@ -45,4 +45,12 @@ return [
10068347520,
49, 6,
],
[
'#NUM!',
1, 2,
],
[
'#VALUE!',
49, 'NaN',
],
];

View File

@ -0,0 +1,28 @@
<?php
return [
[
0.12465201948308113,
2, 5, true,
],
[
0.08422433748856833,
2, 5, false,
],
[
0.05191746860849132,
20, 25, false,
],
[
0.24241419769010333,
35, 40, true,
],
[
'#NUM!',
35, -40, true,
],
[
'#VALUE!',
35, 'Nan', true,
],
];