PhpSpreadsheet/unitTests/Classes/src/Calculation/MathTrigTest.php

555 lines
17 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
2016-03-22 14:35:50 +00:00
namespace PHPExcel\Calculation;
2012-07-31 20:56:11 +00:00
require_once 'testDataFileIterator.php';
2016-03-22 14:35:50 +00:00
class MathTrigTest extends \PHPUnit_Framework_TestCase
2012-07-31 20:56:11 +00:00
{
public function setUp()
{
2016-03-22 14:19:00 +00:00
\PHPExcel\Calculation\Functions::setCompatibilityMode(\PHPExcel\Calculation\Functions::COMPATIBILITY_EXCEL);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerATAN2
*/
2015-05-17 13:00:02 +00:00
public function testATAN2()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','ATAN2'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerATAN2()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/ATAN2.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCEILING
*/
2015-05-17 13:00:02 +00:00
public function testCEILING()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','CEILING'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerCEILING()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/CEILING.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOMBIN
*/
2015-05-17 13:00:02 +00:00
public function testCOMBIN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','COMBIN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerCOMBIN()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/COMBIN.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerEVEN
*/
2015-05-17 13:00:02 +00:00
public function testEVEN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','EVEN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerEVEN()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/EVEN.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerODD
*/
2015-05-17 13:00:02 +00:00
public function testODD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','ODD'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerODD()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/ODD.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFACT
*/
2015-05-17 13:00:02 +00:00
public function testFACT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','FACT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerFACT()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/FACT.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFACTDOUBLE
*/
2015-05-17 13:00:02 +00:00
public function testFACTDOUBLE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','FACTDOUBLE'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerFACTDOUBLE()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/FACTDOUBLE.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFLOOR
*/
2015-05-17 13:00:02 +00:00
public function testFLOOR()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','FLOOR'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerFLOOR()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/FLOOR.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerGCD
*/
2015-05-17 13:00:02 +00:00
public function testGCD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','GCD'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerGCD()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/GCD.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerLCM
*/
2015-05-17 13:00:02 +00:00
public function testLCM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','LCM'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerLCM()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerINT
*/
2015-05-17 13:00:02 +00:00
public function testINT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','INT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
2012-07-31 20:56:11 +00:00
public function providerINT()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/INT.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSIGN
*/
2015-05-17 13:00:02 +00:00
public function testSIGN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','SIGN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSIGN()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerPOWER
*/
2015-05-17 13:00:02 +00:00
public function testPOWER()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','POWER'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerPOWER()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerLOG
*/
2015-05-17 13:00:02 +00:00
public function testLOG()
{
$args = func_get_args();
$expectedResult = array_pop($args);
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','logBase'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerLOG()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMOD
*/
2015-05-17 13:00:02 +00:00
public function testMOD()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','MOD'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMOD()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMDETERM
*/
2015-05-17 13:00:02 +00:00
public function testMDETERM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','MDETERM'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMDETERM()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMINVERSE
*/
2015-05-17 13:00:02 +00:00
public function testMINVERSE()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','MINVERSE'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMINVERSE()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMMULT
*/
2015-05-17 13:00:02 +00:00
public function testMMULT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','MMULT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMMULT()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/MMULT.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMULTINOMIAL
*/
2015-05-17 13:00:02 +00:00
public function testMULTINOMIAL()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','MULTINOMIAL'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMULTINOMIAL()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/MULTINOMIAL.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMROUND
*/
2015-05-17 13:00:02 +00:00
public function testMROUND()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
\PHPExcel\Calculation::setArrayReturnType(\PHPExcel\Calculation::RETURN_ARRAY_AS_VALUE);
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','MROUND'), $args);
\PHPExcel\Calculation::setArrayReturnType(\PHPExcel\Calculation::RETURN_ARRAY_AS_ARRAY);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerMROUND()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerPRODUCT
*/
2015-05-17 13:00:02 +00:00
public function testPRODUCT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','PRODUCT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerPRODUCT()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/PRODUCT.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerQUOTIENT
*/
2015-05-17 13:00:02 +00:00
public function testQUOTIENT()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','QUOTIENT'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerQUOTIENT()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/QUOTIENT.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROUNDUP
*/
2015-05-17 13:00:02 +00:00
public function testROUNDUP()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','ROUNDUP'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerROUNDUP()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROUNDDOWN
*/
2015-05-17 13:00:02 +00:00
public function testROUNDDOWN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','ROUNDDOWN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerROUNDDOWN()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSERIESSUM
*/
2015-05-17 13:00:02 +00:00
public function testSERIESSUM()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','SERIESSUM'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSERIESSUM()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSUMSQ
*/
2015-05-17 13:00:02 +00:00
public function testSUMSQ()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','SUMSQ'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSUMSQ()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/SUMSQ.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerTRUNC
*/
2015-05-17 13:00:02 +00:00
public function testTRUNC()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','TRUNC'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerTRUNC()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/TRUNC.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROMAN
*/
2015-05-17 13:00:02 +00:00
public function testROMAN()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','ROMAN'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result);
}
2012-07-31 20:56:11 +00:00
public function providerROMAN()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data');
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSQRTPI
*/
2015-05-17 13:00:02 +00:00
public function testSQRTPI()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig','SQRTPI'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
2012-07-31 20:56:11 +00:00
public function providerSQRTPI()
{
return new \PhpSpreadhsheet\unitTests\TestDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data');
}
/**
* @dataProvider providerSUMIF
*/
public function testSUMIF()
{
$args = func_get_args();
$expectedResult = array_pop($args);
2016-03-22 14:19:00 +00:00
$result = call_user_func_array(array('\PHPExcel\Calculation\MathTrig', 'SUMIF'), $args);
2015-05-17 13:00:02 +00:00
$this->assertEquals($expectedResult, $result, null, 1E-12);
}
public function providerSUMIF()
{
return array(
array(
array(
array(1),
array(5),
array(10),
),
'>=5',
15,
),
array(
array(
array('text'),
array(2),
),
'=text',
array(
array(10),
array(100),
),
10,
),
array(
array(
array('"text with quotes"'),
array(2),
),
'="text with quotes"',
array(
array(10),
array(100),
),
10,
),
array(
array(
array('"text with quotes"'),
array(''),
),
'>"', // Compare to the single characater " (double quote)
array(
array(10),
array(100),
),
10
),
array(
array(
array(''),
array('anything'),
),
'>"', // Compare to the single characater " (double quote)
array(
array(10),
array(100),
),
100
),
);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
}