php-kilo/tests/Enum/KeyTypeTest.php
Timothy J Warren afd6560db4
Some checks failed
timw4mail/php-kilo/master There was a failure building this commit
Add KeyType::CTRL helper method
2020-02-05 15:20:32 -05:00

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);
}
}