35 lines
880 B
PHP
35 lines
880 B
PHP
|
<?php
|
||
|
|
||
|
namespace Lubiana\Aoc\Y2023\D05;
|
||
|
|
||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
|
||
|
class MapEntryTest extends TestCase
|
||
|
{
|
||
|
#[DataProvider('provideValidData')]
|
||
|
public function testFromString(string $input, MapEntry $expected): void
|
||
|
{
|
||
|
$mapEntry = MapEntry::fromString($input);
|
||
|
|
||
|
$this->assertEquals($mapEntry, $expected);
|
||
|
}
|
||
|
|
||
|
#[DataProvider('provideInvalidData')]
|
||
|
public function testInvalidInput(string $input): void
|
||
|
{
|
||
|
$this->expectException(\InvalidArgumentException::class);
|
||
|
MapEntry::fromString($input);
|
||
|
}
|
||
|
|
||
|
public static function provideValidData(): \Generator
|
||
|
{
|
||
|
yield ["1 2 3", new MapEntry(1, 2, 3)];
|
||
|
yield ["11 22 33", new MapEntry(11, 22, 33)];
|
||
|
}
|
||
|
|
||
|
public static function provideInvalidData(): \Generator
|
||
|
{
|
||
|
yield ["1 2 3"];
|
||
|
}
|
||
|
}
|