aoc/tests/Lubiana/Aoc/Y2023/D05/MapTest.php

30 lines
772 B
PHP
Raw Normal View History

2023-12-10 11:49:11 +00:00
<?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];
}
}