mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-10-24 21:10:31 +00:00
1b05dfab8b
And quite a bit more manual changes. The idea is that typing of our tests can be a bit more loose, so we assume PHPDoc is mostly correct. If that happens to be wrong, it should be caught by the tests themselves.
35 lines
961 B
PHP
35 lines
961 B
PHP
<?php
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
|
|
|
|
class GcdTest extends AllSetupTeardown
|
|
{
|
|
/**
|
|
* @dataProvider providerGCD
|
|
*/
|
|
public function testGCD(mixed $expectedResult, mixed ...$args): void
|
|
{
|
|
$this->mightHaveException($expectedResult);
|
|
$sheet = $this->getSheet();
|
|
$row = 0;
|
|
foreach ($args as $arg) {
|
|
++$row;
|
|
if ($arg !== null) {
|
|
$sheet->getCell("A$row")->setValue($arg);
|
|
}
|
|
}
|
|
if ($row < 1) {
|
|
$sheet->getCell('B1')->setValue('=GCD()');
|
|
} else {
|
|
$sheet->getCell('B1')->setValue("=GCD(A1:A$row)");
|
|
}
|
|
$result = $sheet->getCell('B1')->getCalculatedValue();
|
|
self::assertEqualsWithDelta($expectedResult, $result, 1E-12);
|
|
}
|
|
|
|
public static function providerGCD(): array
|
|
{
|
|
return require 'tests/data/Calculation/MathTrig/GCD.php';
|
|
}
|
|
}
|