Additional statistical unit tests for non-happy path (#1594)

* Additional statistical unit tests for non-happy path
This commit is contained in:
Mark Baker 2020-07-25 21:58:08 +02:00 committed by GitHub
parent 57213deb64
commit fe121e8f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 157 additions and 1 deletions

View File

@ -17,8 +17,10 @@ class CorrelTest extends TestCase
* @dataProvider providerCORREL * @dataProvider providerCORREL
* *
* @param mixed $expectedResult * @param mixed $expectedResult
* @param mixed $xargs
* @param mixed $yargs
*/ */
public function testCORREL($expectedResult, array $xargs, array $yargs): void public function testCORREL($expectedResult, $xargs, $yargs): void
{ {
$result = Statistical::CORREL($xargs, $yargs); $result = Statistical::CORREL($xargs, $yargs);
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); self::assertEqualsWithDelta($expectedResult, $result, 1E-12);

View File

@ -0,0 +1,25 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical;
use PhpOffice\PhpSpreadsheet\Calculation\Statistical;
use PHPUnit\Framework\TestCase;
class KurtTest extends TestCase
{
/**
* @dataProvider providerKURT
*
* @param mixed $expectedResult
*/
public function testKURT($expectedResult, ...$values): void
{
$result = Statistical::KURT(...$values);
self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
}
public function providerKURT()
{
return require 'tests/data/Calculation/Statistical/KURT.php';
}
}

View File

@ -21,4 +21,12 @@ return [
0.685470581054, 0.685470581054,
2, 8, 10, 1, 3, 2, 8, 10, 1, 3,
], ],
[
'#VALUE!',
2, 'NAN', 10, 1, 3,
],
[
'#NUM!',
2, -8, 10, 1, 3,
],
]; ];

View File

@ -21,4 +21,12 @@ return [
0.303225844664, 0.303225844664,
0.2, 4, 5, 0, 1, 0.2, 4, 5, 0, 1,
], ],
[
'#VALUE!',
0.2, 'NAN', 5, 0, 1,
],
[
'#NUM!',
0.2, -4, 5, 0, 1,
],
]; ];

View File

@ -45,4 +45,16 @@ return [
0.999105034804, 0.999105034804,
65, 100, 0.5, true, 65, 100, 0.5, true,
], ],
[
'#VALUE!',
'NAN', 100, 0.5, true,
],
[
'#NUM!',
-5, 100, 0.5, true,
],
[
'#NUM!',
5, 100, 1.5, true,
],
]; ];

View File

@ -33,4 +33,8 @@ return [
0.046011705689, 0.046011705689,
8, 3, 8, 3,
], ],
[
'#VALUE!',
'NAN', 3,
],
]; ];

View File

@ -33,4 +33,8 @@ return [
4.108344935632, 4.108344935632,
0.25, 3, 0.25, 3,
], ],
[
'#VALUE!',
0.25, 'NAN',
],
]; ];

View File

@ -13,4 +13,16 @@ return [
0.013719747903, 0.013719747903,
0.05, 0.07, 100, 0.05, 0.07, 100,
], ],
[
'#VALUE!',
'NAN', 0.07, 100,
],
[
'#NUM!',
1.05, 0.07, 100,
],
[
'#NUM!',
0.05, -0.07, 100,
],
]; ];

View File

@ -11,4 +11,19 @@ return [
[2, 10, 7, 17, 14, 16, 8, 12, 11, 15, 18, 3, 4, 1, 6, 5, 13, 19, 20, 9], [2, 10, 7, 17, 14, 16, 8, 12, 11, 15, 18, 3, 4, 1, 6, 5, 13, 19, 20, 9],
[22.9, 45.78, 33.49, 49.77, 40.94, 36.18, 21.05, 50.57, 31.32, 53.76, 55.66, 27.61, 11.15, 10.11, 37.9, 31.08, 45.48, 63.83, 63.6, 27.01], [22.9, 45.78, 33.49, 49.77, 40.94, 36.18, 21.05, 50.57, 31.32, 53.76, 55.66, 27.61, 11.15, 10.11, 37.9, 31.08, 45.48, 63.83, 63.6, 27.01],
], ],
[
'#VALUE!',
3,
9,
],
[
'#N/A',
[],
[],
],
[
'#DIV/0!',
[3],
[9],
],
]; ];

View File

@ -9,4 +9,12 @@ return [
0.393469340287, 0.393469340287,
0.5, 1, true, 0.5, 1, true,
], ],
[
'#VALUE!',
0.5, 'NAN', true,
],
[
'#NUM!',
-0.5, 1, true,
],
]; ];

View File

@ -13,4 +13,12 @@ return [
1.098612288668, 1.098612288668,
0.8, 0.8,
], ],
[
'#VALUE!',
'NAN',
],
[
'#NUM!',
-2,
],
]; ];

View File

@ -17,4 +17,8 @@ return [
0.992631520201, 0.992631520201,
2.8, 2.8,
], ],
[
'#VALUE!',
'NAN',
],
]; ];

View File

@ -9,4 +9,12 @@ return [
0.576809918873, 0.576809918873,
6, 3, 2, true, 6, 3, 2, true,
], ],
[
'#VALUE!',
6, 'NAN', 2, true,
],
[
'#NUM!',
-6, 3, 2, true,
],
]; ];

View File

@ -5,4 +5,12 @@ return [
5.348120627447, 5.348120627447,
0.5, 3, 2, 0.5, 3, 2,
], ],
[
'#VALUE!',
'NAN', 3, 2,
],
[
'#NUM!',
-0.5, 3, 2,
],
]; ];

View File

@ -5,4 +5,12 @@ return [
2.453736570842, 2.453736570842,
4.5, 4.5,
], ],
[
'#VALUE!',
'NAN',
],
[
'#NUM!',
-4.5,
],
]; ];

View File

@ -0,0 +1,12 @@
<?php
return[
[
-0.1517996372084,
[3, 4, 5, 2, 3, 4, 5, 6, 4, 7],
],
[
0.532657874050135,
[4, 5, 4, 4, 4, 4, 4, 2, 3, 5, 5, 3],
],
];

View File

@ -11,4 +11,14 @@ return [
[3, 7.9, 8, 9.2, 12, 10.5, 15, 15.5, 17], [3, 7.9, 8, 9.2, 12, 10.5, 15, 15.5, 17],
[1, 2, 3, 4, 4.5, 5, 6, 7, 8], [1, 2, 3, 4, 4.5, 5, 6, 7, 8],
], ],
[
'#N/A',
[],
[],
],
[
'#DIV/0!',
[2],
[1],
],
]; ];