No Description

MathTrigTest.php 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <?php
  2. require_once 'testDataFileIterator.php';
  3. class MathTrigTest extends PHPUnit_Framework_TestCase
  4. {
  5. public function setUp()
  6. {
  7. if (!defined('PHPEXCEL_ROOT'))
  8. {
  9. define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
  10. }
  11. require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  12. PHPExcel_Calculation_Functions::setCompatibilityMode(PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL);
  13. }
  14. /**
  15. * @dataProvider providerATAN2
  16. */
  17. public function testATAN2()
  18. {
  19. $args = func_get_args();
  20. $expectedResult = array_pop($args);
  21. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ATAN2'),$args);
  22. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  23. }
  24. public function providerATAN2()
  25. {
  26. return new testDataFileIterator('rawTestData/Calculation/MathTrig/ATAN2.data');
  27. }
  28. /**
  29. * @dataProvider providerCEILING
  30. */
  31. public function testCEILING()
  32. {
  33. $args = func_get_args();
  34. $expectedResult = array_pop($args);
  35. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','CEILING'),$args);
  36. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  37. }
  38. public function providerCEILING()
  39. {
  40. return new testDataFileIterator('rawTestData/Calculation/MathTrig/CEILING.data');
  41. }
  42. /**
  43. * @dataProvider providerCOMBIN
  44. */
  45. public function testCOMBIN()
  46. {
  47. $args = func_get_args();
  48. $expectedResult = array_pop($args);
  49. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','COMBIN'),$args);
  50. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  51. }
  52. public function providerCOMBIN()
  53. {
  54. return new testDataFileIterator('rawTestData/Calculation/MathTrig/COMBIN.data');
  55. }
  56. /**
  57. * @dataProvider providerEVEN
  58. */
  59. public function testEVEN()
  60. {
  61. $args = func_get_args();
  62. $expectedResult = array_pop($args);
  63. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','EVEN'),$args);
  64. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  65. }
  66. public function providerEVEN()
  67. {
  68. return new testDataFileIterator('rawTestData/Calculation/MathTrig/EVEN.data');
  69. }
  70. /**
  71. * @dataProvider providerODD
  72. */
  73. public function testODD()
  74. {
  75. $args = func_get_args();
  76. $expectedResult = array_pop($args);
  77. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ODD'),$args);
  78. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  79. }
  80. public function providerODD()
  81. {
  82. return new testDataFileIterator('rawTestData/Calculation/MathTrig/ODD.data');
  83. }
  84. /**
  85. * @dataProvider providerFACT
  86. */
  87. public function testFACT()
  88. {
  89. $args = func_get_args();
  90. $expectedResult = array_pop($args);
  91. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACT'),$args);
  92. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  93. }
  94. public function providerFACT()
  95. {
  96. return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACT.data');
  97. }
  98. /**
  99. * @dataProvider providerFACTDOUBLE
  100. */
  101. public function testFACTDOUBLE()
  102. {
  103. $args = func_get_args();
  104. $expectedResult = array_pop($args);
  105. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FACTDOUBLE'),$args);
  106. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  107. }
  108. public function providerFACTDOUBLE()
  109. {
  110. return new testDataFileIterator('rawTestData/Calculation/MathTrig/FACTDOUBLE.data');
  111. }
  112. /**
  113. * @dataProvider providerFLOOR
  114. */
  115. public function testFLOOR()
  116. {
  117. $args = func_get_args();
  118. $expectedResult = array_pop($args);
  119. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','FLOOR'),$args);
  120. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  121. }
  122. public function providerFLOOR()
  123. {
  124. return new testDataFileIterator('rawTestData/Calculation/MathTrig/FLOOR.data');
  125. }
  126. /**
  127. * @dataProvider providerGCD
  128. */
  129. public function testGCD()
  130. {
  131. $args = func_get_args();
  132. $expectedResult = array_pop($args);
  133. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','GCD'),$args);
  134. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  135. }
  136. public function providerGCD()
  137. {
  138. return new testDataFileIterator('rawTestData/Calculation/MathTrig/GCD.data');
  139. }
  140. /**
  141. * @dataProvider providerLCM
  142. */
  143. public function testLCM()
  144. {
  145. $args = func_get_args();
  146. $expectedResult = array_pop($args);
  147. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LCM'),$args);
  148. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  149. }
  150. public function providerLCM()
  151. {
  152. return new testDataFileIterator('rawTestData/Calculation/MathTrig/LCM.data');
  153. }
  154. /**
  155. * @dataProvider providerINT
  156. */
  157. public function testINT()
  158. {
  159. $args = func_get_args();
  160. $expectedResult = array_pop($args);
  161. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','INT'),$args);
  162. $this->assertEquals($expectedResult, $result);
  163. }
  164. public function providerINT()
  165. {
  166. return new testDataFileIterator('rawTestData/Calculation/MathTrig/INT.data');
  167. }
  168. /**
  169. * @dataProvider providerSIGN
  170. */
  171. public function testSIGN()
  172. {
  173. $args = func_get_args();
  174. $expectedResult = array_pop($args);
  175. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SIGN'),$args);
  176. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  177. }
  178. public function providerSIGN()
  179. {
  180. return new testDataFileIterator('rawTestData/Calculation/MathTrig/SIGN.data');
  181. }
  182. /**
  183. * @dataProvider providerPOWER
  184. */
  185. public function testPOWER()
  186. {
  187. $args = func_get_args();
  188. $expectedResult = array_pop($args);
  189. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','POWER'),$args);
  190. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  191. }
  192. public function providerPOWER()
  193. {
  194. return new testDataFileIterator('rawTestData/Calculation/MathTrig/POWER.data');
  195. }
  196. /**
  197. * @dataProvider providerLOG
  198. */
  199. public function testLOG()
  200. {
  201. $args = func_get_args();
  202. $expectedResult = array_pop($args);
  203. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','LOG_BASE'),$args);
  204. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  205. }
  206. public function providerLOG()
  207. {
  208. return new testDataFileIterator('rawTestData/Calculation/MathTrig/LOG.data');
  209. }
  210. /**
  211. * @dataProvider providerMOD
  212. */
  213. public function testMOD()
  214. {
  215. $args = func_get_args();
  216. $expectedResult = array_pop($args);
  217. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MOD'),$args);
  218. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  219. }
  220. public function providerMOD()
  221. {
  222. return new testDataFileIterator('rawTestData/Calculation/MathTrig/MOD.data');
  223. }
  224. /**
  225. * @dataProvider providerMDETERM
  226. */
  227. public function testMDETERM()
  228. {
  229. $args = func_get_args();
  230. $expectedResult = array_pop($args);
  231. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MDETERM'),$args);
  232. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  233. }
  234. public function providerMDETERM()
  235. {
  236. return new testDataFileIterator('rawTestData/Calculation/MathTrig/MDETERM.data');
  237. }
  238. /**
  239. * @dataProvider providerMINVERSE
  240. */
  241. public function testMINVERSE()
  242. {
  243. $args = func_get_args();
  244. $expectedResult = array_pop($args);
  245. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MINVERSE'),$args);
  246. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  247. }
  248. public function providerMINVERSE()
  249. {
  250. return new testDataFileIterator('rawTestData/Calculation/MathTrig/MINVERSE.data');
  251. }
  252. /**
  253. * @dataProvider providerMMULT
  254. */
  255. public function testMMULT()
  256. {
  257. $args = func_get_args();
  258. $expectedResult = array_pop($args);
  259. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MMULT'),$args);
  260. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  261. }
  262. public function providerMMULT()
  263. {
  264. return new testDataFileIterator('rawTestData/Calculation/MathTrig/MMULT.data');
  265. }
  266. /**
  267. * @dataProvider providerMULTINOMIAL
  268. */
  269. public function testMULTINOMIAL()
  270. {
  271. $args = func_get_args();
  272. $expectedResult = array_pop($args);
  273. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MULTINOMIAL'),$args);
  274. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  275. }
  276. public function providerMULTINOMIAL()
  277. {
  278. return new testDataFileIterator('rawTestData/Calculation/MathTrig/MULTINOMIAL.data');
  279. }
  280. /**
  281. * @dataProvider providerMROUND
  282. */
  283. public function testMROUND()
  284. {
  285. $args = func_get_args();
  286. $expectedResult = array_pop($args);
  287. PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
  288. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','MROUND'),$args);
  289. PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_ARRAY);
  290. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  291. }
  292. public function providerMROUND()
  293. {
  294. return new testDataFileIterator('rawTestData/Calculation/MathTrig/MROUND.data');
  295. }
  296. /**
  297. * @dataProvider providerPRODUCT
  298. */
  299. public function testPRODUCT()
  300. {
  301. $args = func_get_args();
  302. $expectedResult = array_pop($args);
  303. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','PRODUCT'),$args);
  304. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  305. }
  306. public function providerPRODUCT()
  307. {
  308. return new testDataFileIterator('rawTestData/Calculation/MathTrig/PRODUCT.data');
  309. }
  310. /**
  311. * @dataProvider providerQUOTIENT
  312. */
  313. public function testQUOTIENT()
  314. {
  315. $args = func_get_args();
  316. $expectedResult = array_pop($args);
  317. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','QUOTIENT'),$args);
  318. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  319. }
  320. public function providerQUOTIENT()
  321. {
  322. return new testDataFileIterator('rawTestData/Calculation/MathTrig/QUOTIENT.data');
  323. }
  324. /**
  325. * @dataProvider providerROUNDUP
  326. */
  327. public function testROUNDUP()
  328. {
  329. $args = func_get_args();
  330. $expectedResult = array_pop($args);
  331. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDUP'),$args);
  332. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  333. }
  334. public function providerROUNDUP()
  335. {
  336. return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDUP.data');
  337. }
  338. /**
  339. * @dataProvider providerROUNDDOWN
  340. */
  341. public function testROUNDDOWN()
  342. {
  343. $args = func_get_args();
  344. $expectedResult = array_pop($args);
  345. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROUNDDOWN'),$args);
  346. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  347. }
  348. public function providerROUNDDOWN()
  349. {
  350. return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROUNDDOWN.data');
  351. }
  352. /**
  353. * @dataProvider providerSERIESSUM
  354. */
  355. public function testSERIESSUM()
  356. {
  357. $args = func_get_args();
  358. $expectedResult = array_pop($args);
  359. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SERIESSUM'),$args);
  360. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  361. }
  362. public function providerSERIESSUM()
  363. {
  364. return new testDataFileIterator('rawTestData/Calculation/MathTrig/SERIESSUM.data');
  365. }
  366. /**
  367. * @dataProvider providerSUMSQ
  368. */
  369. public function testSUMSQ()
  370. {
  371. $args = func_get_args();
  372. $expectedResult = array_pop($args);
  373. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SUMSQ'),$args);
  374. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  375. }
  376. public function providerSUMSQ()
  377. {
  378. return new testDataFileIterator('rawTestData/Calculation/MathTrig/SUMSQ.data');
  379. }
  380. /**
  381. * @dataProvider providerTRUNC
  382. */
  383. public function testTRUNC()
  384. {
  385. $args = func_get_args();
  386. $expectedResult = array_pop($args);
  387. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','TRUNC'),$args);
  388. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  389. }
  390. public function providerTRUNC()
  391. {
  392. return new testDataFileIterator('rawTestData/Calculation/MathTrig/TRUNC.data');
  393. }
  394. /**
  395. * @dataProvider providerROMAN
  396. */
  397. public function testROMAN()
  398. {
  399. $args = func_get_args();
  400. $expectedResult = array_pop($args);
  401. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','ROMAN'),$args);
  402. $this->assertEquals($expectedResult, $result);
  403. }
  404. public function providerROMAN()
  405. {
  406. return new testDataFileIterator('rawTestData/Calculation/MathTrig/ROMAN.data');
  407. }
  408. /**
  409. * @dataProvider providerSQRTPI
  410. */
  411. public function testSQRTPI()
  412. {
  413. $args = func_get_args();
  414. $expectedResult = array_pop($args);
  415. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig','SQRTPI'),$args);
  416. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  417. }
  418. public function providerSQRTPI()
  419. {
  420. return new testDataFileIterator('rawTestData/Calculation/MathTrig/SQRTPI.data');
  421. }
  422. /**
  423. * @dataProvider providerSUMIF
  424. */
  425. public function testSUMIF()
  426. {
  427. $args = func_get_args();
  428. $expectedResult = array_pop($args);
  429. $result = call_user_func_array(array('PHPExcel_Calculation_MathTrig', 'SUMIF'), $args);
  430. $this->assertEquals($expectedResult, $result, NULL, 1E-12);
  431. }
  432. public function providerSUMIF()
  433. {
  434. return array(
  435. array(
  436. array(
  437. array(1),
  438. array(5),
  439. array(10),
  440. ),
  441. '>=5',
  442. 15,
  443. ),
  444. array(
  445. array(
  446. array('text'),
  447. array(2),
  448. ),
  449. '=text',
  450. array(
  451. array(10),
  452. array(100),
  453. ),
  454. 10,
  455. ),
  456. array(
  457. array(
  458. array('"text with quotes"'),
  459. array(2),
  460. ),
  461. '="text with quotes"',
  462. array(
  463. array(10),
  464. array(100),
  465. ),
  466. 10,
  467. ),
  468. array(
  469. array(
  470. array('"text with quotes"'),
  471. array(''),
  472. ),
  473. '>"', // Compare to the single characater " (double quote)
  474. array(
  475. array(10),
  476. array(100),
  477. ),
  478. 10
  479. ),
  480. array(
  481. array(
  482. array(''),
  483. array('anything'),
  484. ),
  485. '>"', // Compare to the single characater " (double quote)
  486. array(
  487. array(10),
  488. array(100),
  489. ),
  490. 100
  491. ),
  492. );
  493. }
  494. }