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