36 lines
703 B
PHP
36 lines
703 B
PHP
|
<?php declare(strict_types=1);
|
||
|
|
||
|
namespace Aviat\Kilo\Tests\Enum;
|
||
|
|
||
|
use Aviat\Kilo\Enum\KeyType;
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
|
||
|
class KeyTypeTest extends TestCase {
|
||
|
public function testSanityCheck(): void
|
||
|
{
|
||
|
for ($i = 1; $i < 27; $i++)
|
||
|
{
|
||
|
$char = chr(0x60 + $i);
|
||
|
$ord = $i;
|
||
|
$expected = chr($ord);
|
||
|
|
||
|
$actual = KeyType::CTRL($char);
|
||
|
|
||
|
$this->assertEquals($expected, $actual, "CTRL + '{$char}' should return chr($ord)");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function testNullOnInvalidChar(): void
|
||
|
{
|
||
|
$this->assertNull(KeyType::CTRL("\t"));
|
||
|
}
|
||
|
|
||
|
public function testSameOutputOnUpperOrLower(): void
|
||
|
{
|
||
|
$lower = KeyType::CTRL('v');
|
||
|
$upper = KeyType::CTRL('V');
|
||
|
|
||
|
$this->assertEquals($lower, $upper);
|
||
|
}
|
||
|
}
|