forked from PHPOffice/PhpSpreadsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More unit tests for statistical functions, including a bugfix to LARG…
…E() (PHPOffice#1601) * More unit tests for statistical functions, including a bugfix to LARGE() that was identified in testing
- Loading branch information
Mark Baker
authored
Jul 29, 2020
1 parent
a203c3a
commit 9683e5b
Showing
23 changed files
with
478 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class LargeTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerLARGE | ||
* | ||
* @param mixed $expectedResult | ||
* @param mixed $values | ||
* @param mixed $position | ||
*/ | ||
public function testLARGE($expectedResult, $values, $position): void | ||
{ | ||
$result = Statistical::LARGE($values, $position); | ||
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); | ||
} | ||
|
||
public function providerLARGE() | ||
{ | ||
return require 'tests/data/Calculation/Statistical/LARGE.php'; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class LinEstTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerLINEST | ||
* | ||
* @param mixed $expectedResult | ||
* @param mixed $xValues | ||
* @param mixed $yValues | ||
* @param mixed $const | ||
* @param mixed $stats | ||
*/ | ||
public function testLINEST($expectedResult, $yValues, $xValues, $const, $stats): void | ||
{ | ||
$result = Statistical::LINEST($yValues, $xValues, $const, $stats); | ||
|
||
$elements = count($expectedResult); | ||
for ($element = 0; $element < $elements; ++$element) { | ||
self::assertEqualsWithDelta($expectedResult[$element], $result[$element], 1E-12); | ||
} | ||
} | ||
|
||
public function providerLINEST() | ||
{ | ||
return require 'tests/data/Calculation/Statistical/LINEST.php'; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class LogEstTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerLOGEST | ||
* | ||
* @param mixed $expectedResult | ||
* @param mixed $xValues | ||
* @param mixed $yValues | ||
* @param mixed $const | ||
* @param mixed $stats | ||
*/ | ||
public function testLOGEST($expectedResult, $yValues, $xValues, $const, $stats): void | ||
{ | ||
$result = Statistical::LOGEST($yValues, $xValues, $const, $stats); | ||
|
||
$elements = count($expectedResult); | ||
for ($element = 0; $element < $elements; ++$element) { | ||
self::assertEqualsWithDelta($expectedResult[$element], $result[$element], 1E-12); | ||
} | ||
} | ||
|
||
public function providerLOGEST() | ||
{ | ||
return require 'tests/data/Calculation/Statistical/LOGEST.php'; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class LogInvTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerLOGINV | ||
* | ||
* @param mixed $expectedResult | ||
*/ | ||
public function testLOGINV($expectedResult, ...$args): void | ||
{ | ||
$result = Statistical::LOGINV(...$args); | ||
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); | ||
} | ||
|
||
public function providerLOGINV(): array | ||
{ | ||
return require 'tests/data/Calculation/Statistical/LOGINV.php'; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Statistical; | ||
|
||
use PhpOffice\PhpSpreadsheet\Calculation\Statistical; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class MaxATest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider providerMAXA | ||
* | ||
* @param mixed $expectedResult | ||
*/ | ||
public function testMAXA($expectedResult, ...$args): void | ||
{ | ||
$result = Statistical::MAXA(...$args); | ||
self::assertEqualsWithDelta($expectedResult, $result, 1E-12); | ||
} | ||
|
||
public function providerMAXA(): array | ||
{ | ||
return require 'tests/data/Calculation/Statistical/MAXA.php'; | ||
} | ||
} |
Oops, something went wrong.