mirror of
https://github.com/furyfire/trueskill.git
synced 2025-01-16 01:47:39 +00:00
33 lines
789 B
PHP
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));
|
|
}
|
|
}
|