PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/MathTrigTest.php

505 lines
12 KiB
PHP
Raw Normal View History

2012-07-31 20:56:11 +00:00
<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation;
2012-07-31 20:56:11 +00:00
use PhpOffice\PhpSpreadsheet\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
use PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
use PHPUnit_Framework_TestCase;
class MathTrigTest extends PHPUnit_Framework_TestCase
2012-07-31 20:56:11 +00:00
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerATAN2
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testATAN2($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::ATAN2(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerATAN2()
{
return require 'data/Calculation/MathTrig/ATAN2.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCEILING
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testCEILING($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::CEILING(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerCEILING()
{
return require 'data/Calculation/MathTrig/CEILING.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerCOMBIN
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testCOMBIN($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::COMBIN(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerCOMBIN()
{
return require 'data/Calculation/MathTrig/COMBIN.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerEVEN
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testEVEN($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::EVEN(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerEVEN()
{
return require 'data/Calculation/MathTrig/EVEN.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerODD
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testODD($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::ODD(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerODD()
{
return require 'data/Calculation/MathTrig/ODD.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFACT
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testFACT($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::FACT(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerFACT()
{
return require 'data/Calculation/MathTrig/FACT.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFACTDOUBLE
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testFACTDOUBLE($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::FACTDOUBLE(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerFACTDOUBLE()
{
return require 'data/Calculation/MathTrig/FACTDOUBLE.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerFLOOR
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testFLOOR($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::FLOOR(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerFLOOR()
{
return require 'data/Calculation/MathTrig/FLOOR.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerGCD
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testGCD($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::GCD(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerGCD()
{
return require 'data/Calculation/MathTrig/GCD.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerLCM
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testLCM($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::LCM(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerLCM()
{
return require 'data/Calculation/MathTrig/LCM.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerINT
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testINT($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::INT(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerINT()
{
return require 'data/Calculation/MathTrig/INT.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSIGN
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testSIGN($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::SIGN(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerSIGN()
{
return require 'data/Calculation/MathTrig/SIGN.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerPOWER
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testPOWER($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::POWER(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerPOWER()
{
return require 'data/Calculation/MathTrig/POWER.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerLOG
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testLOG($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::logBase(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerLOG()
{
return require 'data/Calculation/MathTrig/LOG.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMOD
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testMOD($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::MOD(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerMOD()
{
return require 'data/Calculation/MathTrig/MOD.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMDETERM
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testMDETERM($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::MDETERM(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerMDETERM()
{
return require 'data/Calculation/MathTrig/MDETERM.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMINVERSE
* @group fail19
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testMINVERSE($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$this->markTestIncomplete('TODO: This test should be fixed');
$result = MathTrig::MINVERSE(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerMINVERSE()
{
return require 'data/Calculation/MathTrig/MINVERSE.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMMULT
* @group fail19
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testMMULT($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$this->markTestIncomplete('TODO: This test should be fixed');
$result = MathTrig::MMULT(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerMMULT()
{
return require 'data/Calculation/MathTrig/MMULT.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMULTINOMIAL
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testMULTINOMIAL($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::MULTINOMIAL(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerMULTINOMIAL()
{
return require 'data/Calculation/MathTrig/MULTINOMIAL.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerMROUND
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testMROUND($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_VALUE);
$result = MathTrig::MROUND(...$args);
Calculation::setArrayReturnType(Calculation::RETURN_ARRAY_AS_ARRAY);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerMROUND()
{
return require 'data/Calculation/MathTrig/MROUND.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerPRODUCT
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testPRODUCT($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::PRODUCT(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerPRODUCT()
{
return require 'data/Calculation/MathTrig/PRODUCT.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerQUOTIENT
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testQUOTIENT($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::QUOTIENT(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerQUOTIENT()
{
return require 'data/Calculation/MathTrig/QUOTIENT.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROUNDUP
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testROUNDUP($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::ROUNDUP(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerROUNDUP()
{
return require 'data/Calculation/MathTrig/ROUNDUP.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROUNDDOWN
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testROUNDDOWN($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::ROUNDDOWN(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerROUNDDOWN()
{
return require 'data/Calculation/MathTrig/ROUNDDOWN.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSERIESSUM
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testSERIESSUM($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::SERIESSUM(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerSERIESSUM()
{
return require 'data/Calculation/MathTrig/SERIESSUM.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSUMSQ
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testSUMSQ($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::SUMSQ(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerSUMSQ()
{
return require 'data/Calculation/MathTrig/SUMSQ.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerTRUNC
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testTRUNC($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::TRUNC(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerTRUNC()
{
return require 'data/Calculation/MathTrig/TRUNC.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerROMAN
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testROMAN($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::ROMAN(...$args);
self::assertEquals($expectedResult, $result);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerROMAN()
{
return require 'data/Calculation/MathTrig/ROMAN.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
/**
* @dataProvider providerSQRTPI
*
* @param mixed $expectedResult
2012-07-31 20:56:11 +00:00
*/
public function testSQRTPI($expectedResult, ...$args)
2015-05-17 13:00:02 +00:00
{
$result = MathTrig::SQRTPI(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
public function providerSQRTPI()
{
return require 'data/Calculation/MathTrig/SQRTPI.php';
}
/**
* @dataProvider providerSUMIF
*
* @param mixed $expectedResult
*/
public function testSUMIF($expectedResult, ...$args)
{
$result = MathTrig::SUMIF(...$args);
self::assertEquals($expectedResult, $result, null, 1E-12);
}
public function providerSUMIF()
{
return require 'data/Calculation/MathTrig/SUMIF.php';
2015-05-17 13:00:02 +00:00
}
2012-07-31 20:56:11 +00:00
}