endtoend-test-psl/tests/Psl/Math/SumTest.php
2020-10-15 11:05:30 +02:00

56 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Math;
use PHPUnit\Framework\TestCase;
use Psl\Iter;
use Psl\Math;
final class SumTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testSum(int $expected, array $numbers): void
{
static::assertSame($expected, Math\sum($numbers));
}
public function provideData(): array
{
return [
[
60,
[
10,
5,
...Iter\range(0, 9),
],
],
[
103,
[
18,
15,
...Iter\to_array(Iter\range(0, 10)),
15,
],
],
[
534,
[
178,
15,
...Iter\range(0, 45, 5),
52,
64,
]
],
];
}
}