trueskill/tests/Numerics/BasicMathTest.php
Jens True 4e7ae9acb9
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Types in tests
2024-02-09 08:06:34 +00:00

33 lines
789 B
PHP

<?php
declare(strict_types=1);
namespace DNW\Skills\Tests\Numerics;
use DNW\Skills\Numerics\BasicMath;
use PHPUnit\Framework\TestCase;
class BasicMathTest extends TestCase
{
public function testSquare(): void
{
$this->assertEquals(1, BasicMath::square(1));
$this->assertEquals(1.44, BasicMath::square(1.2));
$this->assertEquals(4, BasicMath::square(2));
}
public function testSum(): void
{
$arr = [1, 1, 1, 1];
$func_return = function (float $f): float {
return $f;
};
$func_double = function (float $f): float {
return $f * 2;
};
$this->assertEquals(4, BasicMath::sum($arr, $func_return));
$this->assertEquals(8, BasicMath::sum($arr, $func_double));
}
}