1*1c6adce8SGreg Roach<?php 2*1c6adce8SGreg Roach 3*1c6adce8SGreg Roach/** 4*1c6adce8SGreg Roach * webtrees: online genealogy 5*1c6adce8SGreg Roach * Copyright (C) 2021 webtrees development team 6*1c6adce8SGreg Roach * This program is free software: you can redistribute it and/or modify 7*1c6adce8SGreg Roach * it under the terms of the GNU General Public License as published by 8*1c6adce8SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9*1c6adce8SGreg Roach * (at your option) any later version. 10*1c6adce8SGreg Roach * This program is distributed in the hope that it will be useful, 11*1c6adce8SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*1c6adce8SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*1c6adce8SGreg Roach * GNU General Public License for more details. 14*1c6adce8SGreg Roach * You should have received a copy of the GNU General Public License 15*1c6adce8SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16*1c6adce8SGreg Roach */ 17*1c6adce8SGreg Roach 18*1c6adce8SGreg Roachdeclare(strict_types=1); 19*1c6adce8SGreg Roach 20*1c6adce8SGreg Roachnamespace Fisharebest\Webtrees\Tests\Encodings; 21*1c6adce8SGreg Roach 22*1c6adce8SGreg Roachuse Fisharebest\Webtrees\Encodings\MacRoman; 23*1c6adce8SGreg Roachuse PHPUnit\Framework\TestCase; 24*1c6adce8SGreg Roach 25*1c6adce8SGreg Roach/** 26*1c6adce8SGreg Roach * Tests for class MacRoman. 27*1c6adce8SGreg Roach */ 28*1c6adce8SGreg Roachclass MacRomanTest extends TestCase 29*1c6adce8SGreg Roach{ 30*1c6adce8SGreg Roach /** 31*1c6adce8SGreg Roach * @covers \Fisharebest\Webtrees\Encodings\AbstractEncoding 32*1c6adce8SGreg Roach * @covers \Fisharebest\Webtrees\Encodings\MacRoman 33*1c6adce8SGreg Roach * 34*1c6adce8SGreg Roach * @return void 35*1c6adce8SGreg Roach */ 36*1c6adce8SGreg Roach public function testToUtf8HexStrings(): void 37*1c6adce8SGreg Roach { 38*1c6adce8SGreg Roach $encoding = new MacRoman(); 39*1c6adce8SGreg Roach 40*1c6adce8SGreg Roach self::assertSame("\x00\x01\x02\x03\x04\x05\x06\x07", $encoding->toUtf8("\x00\x01\x02\x03\x04\x05\x06\x07")); 41*1c6adce8SGreg Roach self::assertSame("\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F", $encoding->toUtf8("\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F")); 42*1c6adce8SGreg Roach self::assertSame("\x10\x11\x12\x13\x14\x15\x16\x17", $encoding->toUtf8("\x10\x11\x12\x13\x14\x15\x16\x17")); 43*1c6adce8SGreg Roach self::assertSame("\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F", $encoding->toUtf8("\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F")); 44*1c6adce8SGreg Roach self::assertSame("\x20\x21\x22\x23\x24\x25\x26\x27", $encoding->toUtf8("\x20\x21\x22\x23\x24\x25\x26\x27")); 45*1c6adce8SGreg Roach self::assertSame("\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F", $encoding->toUtf8("\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F")); 46*1c6adce8SGreg Roach self::assertSame("\x30\x31\x32\x33\x34\x35\x36\x37", $encoding->toUtf8("\x30\x31\x32\x33\x34\x35\x36\x37")); 47*1c6adce8SGreg Roach self::assertSame("\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F", $encoding->toUtf8("\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F")); 48*1c6adce8SGreg Roach self::assertSame("\x40\x41\x42\x43\x44\x45\x46\x47", $encoding->toUtf8("\x40\x41\x42\x43\x44\x45\x46\x47")); 49*1c6adce8SGreg Roach self::assertSame("\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F", $encoding->toUtf8("\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F")); 50*1c6adce8SGreg Roach self::assertSame("\x50\x51\x52\x53\x54\x55\x56\x57", $encoding->toUtf8("\x50\x51\x52\x53\x54\x55\x56\x57")); 51*1c6adce8SGreg Roach self::assertSame("\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F", $encoding->toUtf8("\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F")); 52*1c6adce8SGreg Roach self::assertSame("\x60\x61\x62\x63\x64\x65\x66\x67", $encoding->toUtf8("\x60\x61\x62\x63\x64\x65\x66\x67")); 53*1c6adce8SGreg Roach self::assertSame("\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F", $encoding->toUtf8("\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F")); 54*1c6adce8SGreg Roach self::assertSame("\x70\x71\x72\x73\x74\x75\x76\x77", $encoding->toUtf8("\x70\x71\x72\x73\x74\x75\x76\x77")); 55*1c6adce8SGreg Roach self::assertSame("\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F", $encoding->toUtf8("\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F")); 56*1c6adce8SGreg Roach self::assertSame( 57*1c6adce8SGreg Roach "\xC3\x84\xC3\x85\xC3\x87\xC3\x89\xC3\x91\xC3\x96\xC3\x9C\xC3\xA1", 58*1c6adce8SGreg Roach $encoding->toUtf8("\x80\x81\x82\x83\x84\x85\x86\x87") 59*1c6adce8SGreg Roach ); 60*1c6adce8SGreg Roach self::assertSame( 61*1c6adce8SGreg Roach "\xC3\xA0\xC3\xA2\xC3\xA4\xC3\xA3\xC3\xA5\xC3\xA7\xC3\xA9\xC3\xA8", 62*1c6adce8SGreg Roach $encoding->toUtf8("\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F") 63*1c6adce8SGreg Roach ); 64*1c6adce8SGreg Roach self::assertSame( 65*1c6adce8SGreg Roach "\xE2\x80\xA0\xC2\xB0\xC2\xA2\xC2\xA3\xC2\xA7\xE2\x80\xA2\xC2\xB6\xC3\x9F", 66*1c6adce8SGreg Roach $encoding->toUtf8("\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7") 67*1c6adce8SGreg Roach ); 68*1c6adce8SGreg Roach self::assertSame( 69*1c6adce8SGreg Roach "\xC2\xAE\xC2\xA9\xE2\x84\xA2\xC2\xB4\xC2\xA8\xE2\x89\xA0\xC3\x86\xC3\x98", 70*1c6adce8SGreg Roach $encoding->toUtf8("\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF") 71*1c6adce8SGreg Roach ); 72*1c6adce8SGreg Roach self::assertSame( 73*1c6adce8SGreg Roach "\xE2\x88\x9E\xC2\xB1\xE2\x89\xA4\xE2\x89\xA5\xC2\xA5\xC2\xB5\xE2\x88\x82\xE2\x88\x91", 74*1c6adce8SGreg Roach $encoding->toUtf8("\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7") 75*1c6adce8SGreg Roach ); 76*1c6adce8SGreg Roach self::assertSame( 77*1c6adce8SGreg Roach "\xE2\x88\x8F\xCF\x80\xE2\x88\xAB\xC2\xAA\xC2\xBA\xCE\xA9\xC3\xA6\xC3\xB8", 78*1c6adce8SGreg Roach $encoding->toUtf8("\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF") 79*1c6adce8SGreg Roach ); 80*1c6adce8SGreg Roach self::assertSame( 81*1c6adce8SGreg Roach "\xC2\xBF\xC2\xA1\xC2\xAC\xE2\x88\x9A\xC6\x92\xE2\x89\x88\xE2\x88\x86\xC2\xAB", 82*1c6adce8SGreg Roach $encoding->toUtf8("\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7") 83*1c6adce8SGreg Roach ); 84*1c6adce8SGreg Roach self::assertSame( 85*1c6adce8SGreg Roach "\xC2\xBB\xE2\x80\xA6\xC2\xA0\xC3\x80\xC3\x83\xC3\x95\xC5\x92\xC5\x93", 86*1c6adce8SGreg Roach $encoding->toUtf8("\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF") 87*1c6adce8SGreg Roach ); 88*1c6adce8SGreg Roach self::assertSame( 89*1c6adce8SGreg Roach "\xE2\x80\x93\xE2\x80\x94\xE2\x80\x9C\xE2\x80\x9D\xE2\x80\x98\xE2\x80\x99\xC3\xB7\xE2\x97\x8A", 90*1c6adce8SGreg Roach $encoding->toUtf8("\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7") 91*1c6adce8SGreg Roach ); 92*1c6adce8SGreg Roach self::assertSame( 93*1c6adce8SGreg Roach "\xC3\xBF\xC5\xB8\xE2\x81\x84\xE2\x82\xAC\xE2\x80\xB9\xE2\x80\xBA\xEF\xAC\x81\xEF\xAC\x82", 94*1c6adce8SGreg Roach $encoding->toUtf8("\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF") 95*1c6adce8SGreg Roach ); 96*1c6adce8SGreg Roach } 97*1c6adce8SGreg Roach 98*1c6adce8SGreg Roach /** 99*1c6adce8SGreg Roach * @covers \Fisharebest\Webtrees\Encodings\AbstractEncoding 100*1c6adce8SGreg Roach * @covers \Fisharebest\Webtrees\Encodings\MacRoman 101*1c6adce8SGreg Roach * 102*1c6adce8SGreg Roach * @return void 103*1c6adce8SGreg Roach */ 104*1c6adce8SGreg Roach public function testToUtf8StringLiterals(): void 105*1c6adce8SGreg Roach { 106*1c6adce8SGreg Roach $encoding = new MacRoman(); 107*1c6adce8SGreg Roach 108*1c6adce8SGreg Roach self::assertSame(' !"#$%&\'', $encoding->toUtf8("\x20\x21\x22\x23\x24\x25\x26\x27")); 109*1c6adce8SGreg Roach self::assertSame('()*+,-./', $encoding->toUtf8("\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F")); 110*1c6adce8SGreg Roach self::assertSame('01234567', $encoding->toUtf8("\x30\x31\x32\x33\x34\x35\x36\x37")); 111*1c6adce8SGreg Roach self::assertSame('89:;<=>?', $encoding->toUtf8("\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F")); 112*1c6adce8SGreg Roach self::assertSame('@ABCDEFG', $encoding->toUtf8("\x40\x41\x42\x43\x44\x45\x46\x47")); 113*1c6adce8SGreg Roach self::assertSame('HIJKLMNO', $encoding->toUtf8("\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F")); 114*1c6adce8SGreg Roach self::assertSame('PQRSTUVW', $encoding->toUtf8("\x50\x51\x52\x53\x54\x55\x56\x57")); 115*1c6adce8SGreg Roach self::assertSame('XYZ[\\]^_', $encoding->toUtf8("\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F")); 116*1c6adce8SGreg Roach self::assertSame('`abcdefg', $encoding->toUtf8("\x60\x61\x62\x63\x64\x65\x66\x67")); 117*1c6adce8SGreg Roach self::assertSame('hijklmno', $encoding->toUtf8("\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F")); 118*1c6adce8SGreg Roach self::assertSame('pqrstuvw', $encoding->toUtf8("\x70\x71\x72\x73\x74\x75\x76\x77")); 119*1c6adce8SGreg Roach self::assertSame("xyz{|}~\x7F", $encoding->toUtf8("\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F")); 120*1c6adce8SGreg Roach self::assertSame('ÄÅÇÉÑÖÜá', $encoding->toUtf8("\x80\x81\x82\x83\x84\x85\x86\x87")); 121*1c6adce8SGreg Roach self::assertSame('àâäãåçéè', $encoding->toUtf8("\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F")); 122*1c6adce8SGreg Roach self::assertSame('êëíìîïñó', $encoding->toUtf8("\x90\x91\x92\x93\x94\x95\x96\x97")); 123*1c6adce8SGreg Roach self::assertSame('òôöõúùûü', $encoding->toUtf8("\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F")); 124*1c6adce8SGreg Roach self::assertSame('†°¢£§•¶ß', $encoding->toUtf8("\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7")); 125*1c6adce8SGreg Roach self::assertSame('®©™´¨≠ÆØ', $encoding->toUtf8("\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF")); 126*1c6adce8SGreg Roach self::assertSame('∞±≤≥¥µ∂∑', $encoding->toUtf8("\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7")); 127*1c6adce8SGreg Roach self::assertSame('∏π∫ªºΩæø', $encoding->toUtf8("\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF")); 128*1c6adce8SGreg Roach self::assertSame('¿¡¬√ƒ≈∆«', $encoding->toUtf8("\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7")); 129*1c6adce8SGreg Roach self::assertSame('»… ÀÃÕŒœ', $encoding->toUtf8("\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF")); 130*1c6adce8SGreg Roach self::assertSame('–—“”‘’÷◊', $encoding->toUtf8("\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7")); 131*1c6adce8SGreg Roach self::assertSame('ÿŸ⁄€‹›fifl', $encoding->toUtf8("\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF")); 132*1c6adce8SGreg Roach } 133*1c6adce8SGreg Roach} 134