562 lines
14 KiB
PHP
562 lines
14 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace PhpSpreadsheetTests\Calculation;
|
||
|
|
||
|
use PhpSpreadsheet\Calculation;
|
||
|
use PhpSpreadsheet\Calculation\Functions;
|
||
|
use PhpSpreadsheet\Calculation\MathTrig;
|
||
|
|
||
|
class MathTrigTest extends \PHPUnit_Framework_TestCase
|
||
|
{
|
||
|
public function setUp()
|
||
|
{
|
||
|
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerATAN2
|
||
|
*/
|
||
|
public function testATAN2()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'ATAN2'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerATAN2()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/ATAN2.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerCEILING
|
||
|
*/
|
||
|
public function testCEILING()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'CEILING'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerCEILING()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/CEILING.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerCOMBIN
|
||
|
*/
|
||
|
public function testCOMBIN()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'COMBIN'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerCOMBIN()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/COMBIN.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerEVEN
|
||
|
*/
|
||
|
public function testEVEN()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'EVEN'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerEVEN()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/EVEN.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerODD
|
||
|
*/
|
||
|
public function testODD()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'ODD'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerODD()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/ODD.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerFACT
|
||
|
*/
|
||
|
public function testFACT()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'FACT'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerFACT()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/FACT.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerFACTDOUBLE
|
||
|
*/
|
||
|
public function testFACTDOUBLE()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'FACTDOUBLE'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerFACTDOUBLE()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/FACTDOUBLE.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerFLOOR
|
||
|
*/
|
||
|
public function testFLOOR()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'FLOOR'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerFLOOR()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/FLOOR.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerGCD
|
||
|
*/
|
||
|
public function testGCD()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'GCD'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerGCD()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/GCD.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerLCM
|
||
|
*/
|
||
|
public function testLCM()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'LCM'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerLCM()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/LCM.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerINT
|
||
|
*/
|
||
|
public function testINT()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'INT'], $args);
|
||
|
$this->assertEquals($expectedResult, $result);
|
||
|
}
|
||
|
|
||
|
public function providerINT()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/INT.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerSIGN
|
||
|
*/
|
||
|
public function testSIGN()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'SIGN'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerSIGN()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/SIGN.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerPOWER
|
||
|
*/
|
||
|
public function testPOWER()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'POWER'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerPOWER()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/POWER.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerLOG
|
||
|
*/
|
||
|
public function testLOG()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'logBase'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerLOG()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/LOG.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerMOD
|
||
|
*/
|
||
|
public function testMOD()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'MOD'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerMOD()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/MOD.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerMDETERM
|
||
|
*/
|
||
|
public function testMDETERM()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'MDETERM'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerMDETERM()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/MDETERM.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerMINVERSE
|
||
|
* @group fail19
|
||
|
*/
|
||
|
public function testMINVERSE()
|
||
|
{
|
||
|
$this->markTestIncomplete('TODO: This test should be fixed');
|
||
|
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'MINVERSE'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerMINVERSE()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/MINVERSE.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerMMULT
|
||
|
* @group fail19
|
||
|
*/
|
||
|
public function testMMULT()
|
||
|
{
|
||
|
$this->markTestIncomplete('TODO: This test should be fixed');
|
||
|
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'MMULT'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerMMULT()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/MMULT.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerMULTINOMIAL
|
||
|
*/
|
||
|
public function testMULTINOMIAL()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'MULTINOMIAL'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerMULTINOMIAL()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/MULTINOMIAL.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerMROUND
|
||
|
*/
|
||
|
public function testMROUND()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
|
||
|
$result = call_user_func_array([MathTrig::class, 'MROUND'], $args);
|
||
|
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerMROUND()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/MROUND.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerPRODUCT
|
||
|
*/
|
||
|
public function testPRODUCT()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'PRODUCT'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerPRODUCT()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/PRODUCT.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerQUOTIENT
|
||
|
*/
|
||
|
public function testQUOTIENT()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'QUOTIENT'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerQUOTIENT()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/QUOTIENT.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerROUNDUP
|
||
|
*/
|
||
|
public function testROUNDUP()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'ROUNDUP'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerROUNDUP()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/ROUNDUP.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerROUNDDOWN
|
||
|
*/
|
||
|
public function testROUNDDOWN()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'ROUNDDOWN'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerROUNDDOWN()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/ROUNDDOWN.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerSERIESSUM
|
||
|
*/
|
||
|
public function testSERIESSUM()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'SERIESSUM'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerSERIESSUM()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/SERIESSUM.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerSUMSQ
|
||
|
*/
|
||
|
public function testSUMSQ()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'SUMSQ'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerSUMSQ()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/SUMSQ.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerTRUNC
|
||
|
*/
|
||
|
public function testTRUNC()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'TRUNC'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerTRUNC()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/TRUNC.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerROMAN
|
||
|
*/
|
||
|
public function testROMAN()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'ROMAN'], $args);
|
||
|
$this->assertEquals($expectedResult, $result);
|
||
|
}
|
||
|
|
||
|
public function providerROMAN()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/ROMAN.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerSQRTPI
|
||
|
*/
|
||
|
public function testSQRTPI()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'SQRTPI'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerSQRTPI()
|
||
|
{
|
||
|
return require 'data/Calculation/MathTrig/SQRTPI.php';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @dataProvider providerSUMIF
|
||
|
*/
|
||
|
public function testSUMIF()
|
||
|
{
|
||
|
$args = func_get_args();
|
||
|
$expectedResult = array_pop($args);
|
||
|
$result = call_user_func_array([MathTrig::class, 'SUMIF'], $args);
|
||
|
$this->assertEquals($expectedResult, $result, null, 1E-12);
|
||
|
}
|
||
|
|
||
|
public function providerSUMIF()
|
||
|
{
|
||
|
return [
|
||
|
[
|
||
|
[
|
||
|
[1],
|
||
|
[5],
|
||
|
[10],
|
||
|
],
|
||
|
'>=5',
|
||
|
15,
|
||
|
],
|
||
|
[
|
||
|
[
|
||
|
['text'],
|
||
|
[2],
|
||
|
],
|
||
|
'=text',
|
||
|
[
|
||
|
[10],
|
||
|
[100],
|
||
|
],
|
||
|
10,
|
||
|
],
|
||
|
[
|
||
|
[
|
||
|
['"text with quotes"'],
|
||
|
[2],
|
||
|
],
|
||
|
'="text with quotes"',
|
||
|
[
|
||
|
[10],
|
||
|
[100],
|
||
|
],
|
||
|
10,
|
||
|
],
|
||
|
[
|
||
|
[
|
||
|
['"text with quotes"'],
|
||
|
[''],
|
||
|
],
|
||
|
'>"', // Compare to the single characater " (double quote)
|
||
|
[
|
||
|
[10],
|
||
|
[100],
|
||
|
],
|
||
|
10,
|
||
|
],
|
||
|
[
|
||
|
[
|
||
|
[''],
|
||
|
['anything'],
|
||
|
],
|
||
|
'>"', // Compare to the single characater " (double quote)
|
||
|
[
|
||
|
[10],
|
||
|
[100],
|
||
|
],
|
||
|
100,
|
||
|
],
|
||
|
];
|
||
|
}
|
||
|
}
|