trueskill/tests/Numerics/BasicMathTest.php

31 lines
810 B
PHP
Raw Permalink Normal View History

2022-07-05 13:55:47 +00:00
<?php
2024-02-02 14:53:38 +00:00
declare(strict_types=1);
2022-07-05 13:55:47 +00:00
namespace DNW\Skills\Tests\Numerics;
2022-07-05 13:33:34 +00:00
use DNW\Skills\Numerics\BasicMath;
use PHPUnit\Framework\TestCase;
2024-05-14 08:46:43 +00:00
use PHPUnit\Framework\Attributes\CoversClass;
2016-05-24 12:06:43 +00:00
2024-05-14 08:46:43 +00:00
#[CoversClass(BasicMath::class)]
2016-05-24 12:06:43 +00:00
class BasicMathTest extends TestCase
{
2023-08-01 11:26:38 +00:00
public function testSquare(): void
{
2016-05-24 13:12:29 +00:00
$this->assertEquals(1, BasicMath::square(1));
$this->assertEquals(1.44, BasicMath::square(1.2));
$this->assertEquals(4, BasicMath::square(2));
}
2024-02-06 13:45:40 +00:00
public function testSum(): void
{
$arr = [1, 1, 1, 1];
2024-02-21 13:48:37 +00:00
$func_return = static fn(float $f): float => $f;
$func_double = static fn(float $f): float => $f * 2;
2024-02-06 13:45:40 +00:00
$this->assertEquals(4, BasicMath::sum($arr, $func_return));
$this->assertEquals(8, BasicMath::sum($arr, $func_double));
}
2022-07-05 13:55:47 +00:00
}