generated from jric11/baseProject
Initial commit
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ArabicTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Arabic Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class ArabicTest extends TestCase
|
||||
{
|
||||
public function testDiacritic(): void
|
||||
{
|
||||
$this->assertEquals(6, \count(\Com\Tecnick\Unicode\Data\Arabic::DIACRITIC));
|
||||
// SHADDA (U+0651) + SUPERSCRIPT ALEF (U+0670)
|
||||
$this->assertEquals(0xFC63, \Com\Tecnick\Unicode\Data\Arabic::DIACRITIC[0x0670] ?? null);
|
||||
}
|
||||
|
||||
public function testlaa(): void
|
||||
{
|
||||
$this->assertEquals(4, \count(\Com\Tecnick\Unicode\Data\Arabic::LAA));
|
||||
}
|
||||
|
||||
public function testSubstitute(): void
|
||||
{
|
||||
$this->assertEquals(76, \count(\Com\Tecnick\Unicode\Data\Arabic::SUBSTITUTE));
|
||||
|
||||
foreach (\Com\Tecnick\Unicode\Data\Arabic::SUBSTITUTE as $ord => $forms) {
|
||||
$this->assertCount(4, $forms, \sprintf('U+%04X', $ord));
|
||||
}
|
||||
|
||||
// TEH MARBUTA (U+0629) has no initial or medial form: they repeat the isolated and final ones.
|
||||
$this->assertEquals(
|
||||
[0xFE93, 0xFE94, 0xFE93, 0xFE94],
|
||||
\Com\Tecnick\Unicode\Data\Arabic::SUBSTITUTE[0x0629] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
public function testJoining(): void
|
||||
{
|
||||
$this->assertEquals('D', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0628)); // BEH
|
||||
$this->assertEquals('R', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0627)); // ALEF
|
||||
$this->assertEquals('C', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0640)); // TATWEEL
|
||||
$this->assertEquals('C', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x200D)); // ZWJ
|
||||
$this->assertEquals('U', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x200C)); // ZWNJ
|
||||
$this->assertEquals('U', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0621)); // HAMZA
|
||||
$this->assertEquals('T', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x064E)); // FATHA
|
||||
$this->assertEquals('U', \Com\Tecnick\Unicode\Data\Arabic::getJoiningType(0x0041)); // LATIN CAPITAL A
|
||||
}
|
||||
|
||||
public function testEnd(): void
|
||||
{
|
||||
// Characters that never join to the following one.
|
||||
foreach ([0x0621, 0x0627, 0x0629, 0x0648, 0x0671, 0x0691, 0x06C7, 0x06D2] as $ord) {
|
||||
$this->assertContains($ord, \Com\Tecnick\Unicode\Data\Arabic::END, \sprintf('U+%04X', $ord));
|
||||
}
|
||||
|
||||
// Dual-joining and join-causing characters.
|
||||
foreach ([0x0628, 0x0644, 0x0640] as $ord) {
|
||||
$this->assertNotContains($ord, \Com\Tecnick\Unicode\Data\Arabic::END, \sprintf('U+%04X', $ord));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BidiClassTest.php
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Com\Tecnick\Unicode\Data\BidiClass;
|
||||
use Com\Tecnick\Unicode\Data\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* BidiClass enum test
|
||||
*
|
||||
* @since 2026-07-17
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class BidiClassTest extends TestCase
|
||||
{
|
||||
public function testCasesMatchTypeGroups(): void
|
||||
{
|
||||
$values = \array_map(static fn(BidiClass $case): string => $case->value, BidiClass::cases());
|
||||
$expected = \array_merge(\array_keys(Type::STRONG), \array_keys(Type::WEAK), \array_keys(Type::NEUTRAL));
|
||||
$this->assertSame($expected, $values);
|
||||
}
|
||||
|
||||
public function testFromLooseCanonical(): void
|
||||
{
|
||||
$this->assertSame(BidiClass::L, BidiClass::fromLoose('L'));
|
||||
$this->assertSame(BidiClass::NSM, BidiClass::fromLoose('NSM'));
|
||||
$this->assertSame(BidiClass::ON, BidiClass::fromLoose('ON'));
|
||||
}
|
||||
|
||||
public function testFromLoosePassesThroughEnumInstance(): void
|
||||
{
|
||||
$this->assertSame(BidiClass::AL, BidiClass::fromLoose(BidiClass::AL));
|
||||
}
|
||||
|
||||
public function testFromLooseRoundTrip(): void
|
||||
{
|
||||
foreach (BidiClass::cases() as $case) {
|
||||
$this->assertSame($case, BidiClass::fromLoose($case->value));
|
||||
}
|
||||
}
|
||||
|
||||
public function testFromLooseUnknownThrows(): void
|
||||
{
|
||||
$this->expectException(\ValueError::class);
|
||||
BidiClass::fromLoose('ZZ');
|
||||
}
|
||||
|
||||
public function testFromLooseRejectsExplicitFormattingCode(): void
|
||||
{
|
||||
// LRE is a valid UNI value but an explicit formatting code, not a BidiClass.
|
||||
$this->expectException(\ValueError::class);
|
||||
BidiClass::fromLoose('LRE');
|
||||
}
|
||||
|
||||
public function testCategoryHelpers(): void
|
||||
{
|
||||
$this->assertTrue(BidiClass::R->isStrong());
|
||||
$this->assertFalse(BidiClass::R->isWeak());
|
||||
$this->assertFalse(BidiClass::R->isNeutral());
|
||||
|
||||
$this->assertTrue(BidiClass::EN->isWeak());
|
||||
$this->assertFalse(BidiClass::EN->isStrong());
|
||||
|
||||
$this->assertTrue(BidiClass::WS->isNeutral());
|
||||
$this->assertFalse(BidiClass::WS->isStrong());
|
||||
}
|
||||
|
||||
public function testEveryCaseHasExactlyOneCategory(): void
|
||||
{
|
||||
foreach (BidiClass::cases() as $case) {
|
||||
$count = (int) $case->isStrong() + (int) $case->isWeak() + (int) $case->isNeutral();
|
||||
$this->assertSame(1, $count, 'BidiClass ' . $case->value . ' must belong to exactly one category');
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetBidiClassForMappedCodePoint(): void
|
||||
{
|
||||
$this->assertSame(BidiClass::L, Type::getBidiClass(65)); // 'A'
|
||||
$this->assertSame(BidiClass::WS, Type::getBidiClass(32)); // space
|
||||
$this->assertSame(BidiClass::B, Type::getBidiClass(10)); // line feed
|
||||
}
|
||||
|
||||
public function testGetBidiClassIsNullForExplicitFormattingCode(): void
|
||||
{
|
||||
$this->assertNull(Type::getBidiClass(8234)); // LRE
|
||||
$this->assertNull(Type::getBidiClass(0x2066)); // LRI
|
||||
}
|
||||
|
||||
public function testGetBidiClassForUnlistedCodePoint(): void
|
||||
{
|
||||
$this->assertSame(BidiClass::L, Type::getBidiClass(0x4E00)); // CJK ideograph
|
||||
$this->assertSame(BidiClass::AL, Type::getBidiClass(0x074B)); // unassigned in the Syriac block
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* BracketTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Bracket Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class BracketTest extends TestCase
|
||||
{
|
||||
public function testOpenClose(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
\Com\Tecnick\Unicode\Data\Bracket::OPEN,
|
||||
\array_flip(\Com\Tecnick\Unicode\Data\Bracket::CLOSE),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ConstantTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Constant Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class ConstantTest extends TestCase
|
||||
{
|
||||
public function testConstants(): void
|
||||
{
|
||||
$reflectionClass = new \ReflectionClass('\\' . \Com\Tecnick\Unicode\Data\Constant::class);
|
||||
$this->assertEquals(18, \count($reflectionClass->getConstants()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EncodingTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Encoding Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class EncodingTest extends TestCase
|
||||
{
|
||||
public function testMap(): void
|
||||
{
|
||||
$map = \Com\Tecnick\Unicode\Data\Encoding::MAP;
|
||||
$this->assertEquals(22, \count($map));
|
||||
$this->assertArrayHasKey('iso-8859-1', $map);
|
||||
$isoMap = $map['iso-8859-1'] ?? [];
|
||||
$this->assertEquals(256, \count($isoMap));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* IdentityTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Identity Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class IdentityTest extends TestCase
|
||||
{
|
||||
public function testConstants(): void
|
||||
{
|
||||
$this->assertEquals('a3f30375025e8570745ff463479522b6', \md5(\Com\Tecnick\Unicode\Data\Identity::CIDHMAP));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LatinTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Latin Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class LatinTest extends TestCase
|
||||
{
|
||||
public function testMap(): void
|
||||
{
|
||||
$this->assertEquals(27, \count(\Com\Tecnick\Unicode\Data\Latin::SUBSTITUTE));
|
||||
}
|
||||
|
||||
public function testKnownSubstitutions(): void
|
||||
{
|
||||
$map = \Com\Tecnick\Unicode\Data\Latin::SUBSTITUTE;
|
||||
$this->assertSame(128, $map[8364] ?? null); // Euro
|
||||
$this->assertSame(153, $map[8482] ?? null); // trademark
|
||||
$this->assertSame(156, $map[339] ?? null); // oe
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MirrorTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Mirror Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class MirrorTest extends TestCase
|
||||
{
|
||||
public function testMap(): void
|
||||
{
|
||||
$this->assertEquals(428, \count(\Com\Tecnick\Unicode\Data\Mirror::UNI));
|
||||
}
|
||||
|
||||
public function testSymmetry(): void
|
||||
{
|
||||
$map = \Com\Tecnick\Unicode\Data\Mirror::UNI;
|
||||
foreach ($map as $from => $to) {
|
||||
$this->assertArrayHasKey($to, $map);
|
||||
$this->assertSame($from, $map[$to] ?? null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PatternTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Pattern Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class PatternTest extends TestCase
|
||||
{
|
||||
public function testPatterns(): void
|
||||
{
|
||||
$str = 'hello world';
|
||||
$this->assertEquals(0, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str));
|
||||
$this->assertEquals(0, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::RTL, $str));
|
||||
|
||||
$str = 'مرحبا بالعالم';
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str));
|
||||
|
||||
$str = 'שלום עולם';
|
||||
$this->assertEquals(0, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str));
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::RTL, $str));
|
||||
|
||||
$str = (string) \json_decode('"\u2067"'); // RLI
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::RTL, $str));
|
||||
|
||||
$str = (string) \json_decode('"\u202B"'); // RLE
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::RTL, $str));
|
||||
|
||||
$str = (string) \json_decode('"\u202E"'); // RLO
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::RTL, $str));
|
||||
|
||||
$str = (string) \json_decode('"\u061C"'); // ARABIC LETTER MARK
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str));
|
||||
|
||||
$str = (string) \json_decode('"\u08A1"'); // Arabic Extended-A
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str));
|
||||
|
||||
$str = (string) \json_decode('"\u0870"'); // Arabic Extended-B
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str));
|
||||
|
||||
$str = (string) \json_decode('"\uD83A\uDD00"'); // ADLAM CAPITAL LETTER ALIF
|
||||
$this->assertEquals(0, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::ARABIC, $str));
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::RTL, $str));
|
||||
|
||||
$str = (string) \json_decode('"\u0800"'); // SAMARITAN LETTER ALAF
|
||||
$this->assertEquals(1, \preg_match(\Com\Tecnick\Unicode\Data\Pattern::RTL, $str));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TypeTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*
|
||||
* This file is part of tc-lib-unicode-data software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Type Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package UnicodeData
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD
|
||||
* @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
|
||||
* @link https://github.com/tecnickcom/tc-lib-unicode-data
|
||||
*/
|
||||
class TypeTest extends TestCase
|
||||
{
|
||||
public function testStrong(): void
|
||||
{
|
||||
$this->assertEquals(3, \count(\Com\Tecnick\Unicode\Data\Type::STRONG));
|
||||
}
|
||||
|
||||
public function testWeak(): void
|
||||
{
|
||||
$this->assertEquals(7, \count(\Com\Tecnick\Unicode\Data\Type::WEAK));
|
||||
}
|
||||
|
||||
public function testNeutral(): void
|
||||
{
|
||||
$this->assertEquals(4, \count(\Com\Tecnick\Unicode\Data\Type::NEUTRAL));
|
||||
}
|
||||
|
||||
public function testExplicitFormatting(): void
|
||||
{
|
||||
$this->assertEquals(9, \count(\Com\Tecnick\Unicode\Data\Type::EXPLICIT_FORMATTING));
|
||||
}
|
||||
|
||||
public function testUnicodeVersion(): void
|
||||
{
|
||||
$this->assertEquals('17.0.0', \Com\Tecnick\Unicode\Data\Type::UNICODE_VERSION);
|
||||
}
|
||||
|
||||
public function testUni(): void
|
||||
{
|
||||
$this->assertEquals(16_377, \count(\Com\Tecnick\Unicode\Data\Type::UNI));
|
||||
$this->assertArrayNotHasKey(0x0041, \Com\Tecnick\Unicode\Data\Type::UNI);
|
||||
}
|
||||
|
||||
public function testGetType(): void
|
||||
{
|
||||
$expected = [
|
||||
0x0041 => 'L', // LATIN CAPITAL LETTER A (not listed, default L)
|
||||
0x4E00 => 'L', // CJK UNIFIED IDEOGRAPH-4E00 (not listed, default L)
|
||||
0x0020 => 'WS', // SPACE
|
||||
0x05D0 => 'R', // HEBREW LETTER ALEF
|
||||
0x05EF => 'R', // HEBREW YOD TRIANGLE
|
||||
0x061C => 'AL', // ARABIC LETTER MARK
|
||||
0x0660 => 'AN', // ARABIC-INDIC DIGIT ZERO
|
||||
0x08A1 => 'AL', // ARABIC LETTER BEH WITH HAMZA ABOVE (Arabic Extended-A)
|
||||
0x0870 => 'AL', // ARABIC LETTER ALEF WITH ATTACHED FATHA (Arabic Extended-B)
|
||||
0x0800 => 'R', // SAMARITAN LETTER ALAF
|
||||
0x1E900 => 'R', // ADLAM CAPITAL LETTER ALIF
|
||||
0x2066 => 'LRI', // LEFT-TO-RIGHT ISOLATE
|
||||
0x2069 => 'PDI', // POP DIRECTIONAL ISOLATE
|
||||
0x202A => 'LRE', // LEFT-TO-RIGHT EMBEDDING
|
||||
0x05C8 => 'R', // unassigned in the Hebrew block
|
||||
0x074B => 'AL', // unassigned in the Syriac block
|
||||
0x20C2 => 'ET', // unassigned in the Currency Symbols block
|
||||
0x8700A => 'L', // unassigned outside the default ranges
|
||||
];
|
||||
|
||||
foreach ($expected as $ord => $type) {
|
||||
$this->assertEquals($type, \Com\Tecnick\Unicode\Data\Type::getType($ord), \sprintf('U+%04X', $ord));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user