. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Tests\Encodings; use Fisharebest\Webtrees\Encodings\ASCII; use Fisharebest\Webtrees\Encodings\UTF8; use PHPUnit\Framework\TestCase; use function chr; use function iconv; use function range; /** * Tests for class ASCII. */ class ASCIITest extends TestCase { /** * @covers \Fisharebest\Webtrees\Encodings\AbstractEncoding * @covers \Fisharebest\Webtrees\Encodings\ASCII * * @return void */ public function testToUtf8(): void { $encoding = new ASCII(); foreach (range(0, 127) as $code_point) { $character = chr($code_point); $actual = $encoding->toUtf8($character); $expected = iconv(ASCII::NAME, UTF8::NAME, $character); static::assertSame($expected, $actual); } foreach (range(128, 255) as $code_point) { $character = chr($code_point); $actual = $encoding->toUtf8($character); $expected = UTF8::REPLACEMENT_CHARACTER; static::assertSame($expected, $actual); } } }