xref: /webtrees/tests/app/Encodings/UTF8Test.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
11c6adce8SGreg Roach<?php
21c6adce8SGreg Roach
31c6adce8SGreg Roach/**
41c6adce8SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
61c6adce8SGreg Roach * This program is free software: you can redistribute it and/or modify
71c6adce8SGreg Roach * it under the terms of the GNU General Public License as published by
81c6adce8SGreg Roach * the Free Software Foundation, either version 3 of the License, or
91c6adce8SGreg Roach * (at your option) any later version.
101c6adce8SGreg Roach * This program is distributed in the hope that it will be useful,
111c6adce8SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
121c6adce8SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131c6adce8SGreg Roach * GNU General Public License for more details.
141c6adce8SGreg Roach * You should have received a copy of the GNU General Public License
151c6adce8SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
161c6adce8SGreg Roach */
171c6adce8SGreg Roach
181c6adce8SGreg Roachdeclare(strict_types=1);
191c6adce8SGreg Roach
201c6adce8SGreg Roachnamespace Fisharebest\Webtrees\Tests\Encodings;
211c6adce8SGreg Roach
22*202c018bSGreg Roachuse Fisharebest\Webtrees\Encodings\AbstractEncoding;
231c6adce8SGreg Roachuse Fisharebest\Webtrees\Encodings\UTF8;
24*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
251c6adce8SGreg Roachuse PHPUnit\Framework\TestCase;
261c6adce8SGreg Roach
2710e06497SGreg Roachuse function chr;
2810e06497SGreg Roach
29*202c018bSGreg Roach#[CoversClass(AbstractEncoding::class)]
30*202c018bSGreg Roach#[CoversClass(UTF8::class)]
311c6adce8SGreg Roachclass UTF8Test extends TestCase
321c6adce8SGreg Roach{
331c6adce8SGreg Roach    public function testToUtf8(): void
341c6adce8SGreg Roach    {
351c6adce8SGreg Roach        $encoding = new UTF8();
361c6adce8SGreg Roach
371c6adce8SGreg Roach        for ($i = 0; $i < 128; ++$i) {
381c6adce8SGreg Roach            $char = chr($i);
391c6adce8SGreg Roach            self::assertSame($char, $encoding->toUtf8($char));
401c6adce8SGreg Roach        }
411c6adce8SGreg Roach    }
421c6adce8SGreg Roach
431c6adce8SGreg Roach    public function testFromUtf8(): void
441c6adce8SGreg Roach    {
451c6adce8SGreg Roach        $encoding = new UTF8();
461c6adce8SGreg Roach
471c6adce8SGreg Roach        for ($i = 0; $i < 128; ++$i) {
481c6adce8SGreg Roach            $char = chr($i);
491c6adce8SGreg Roach            self::assertSame($char, $encoding->fromUtf8($char));
501c6adce8SGreg Roach        }
511c6adce8SGreg Roach    }
521c6adce8SGreg Roach}
53