30 lines
772 B
PHP
30 lines
772 B
PHP
|
<?php
|
||
|
|
||
|
namespace Lubiana\Aoc\Y2023\D05;
|
||
|
|
||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
|
||
|
class MapTest extends TestCase
|
||
|
{
|
||
|
#[DataProvider('inputProvider')]
|
||
|
public function testMapCreate(string $input, string $name, bool $isMap): void
|
||
|
{
|
||
|
$inputIsMap = Map::isMapString($input);
|
||
|
$this->assertEquals($isMap, $inputIsMap);
|
||
|
|
||
|
if ($isMap === true) {
|
||
|
$this->assertEquals($name, Map::fromString($input)->name);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static function inputProvider(): \Generator
|
||
|
{
|
||
|
yield ['seed-to-soil map:', 'seed-to-soil', true];
|
||
|
yield ['a map:', 'a', true];
|
||
|
yield [' a map: ', 'a', true];
|
||
|
yield ['a', '', false];
|
||
|
yield ['map: a', '', false];
|
||
|
}
|
||
|
}
|