Feature: Labelprint für Kistenetiketten hinzugefügt

This commit is contained in:
2025-10-27 12:14:44 +01:00
parent 43bc416554
commit 14bae6c9ef
1068 changed files with 229014 additions and 1807 deletions

View File

@@ -0,0 +1,306 @@
<?php
/**
* StepITest.php
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*
* This file is part of tc-lib-unicode software library.
*/
namespace Test\Bidi;
use Com\Tecnick\Unicode\Bidi\StepI;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
/**
* Bidi Test
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*/
class StepITest extends TestCase
{
/**
* @param array{
* 'e': int,
* 'edir': string,
* 'end': int,
* 'eos': string,
* 'length': int,
* 'maxlevel': int,
* 'sos': string,
* 'start': int,
* 'item': array<int, array{
* 'char': int,
* 'i': int,
* 'level': int,
* 'otype': string,
* 'pdimatch': int,
* 'pos': int,
* 'type': string,
* 'x': int,
* }>,
* } $seq Isolated Sequence array
*
* @param mixed $expected Expected result
*/
#[DataProvider('stepIDataProvider')]
public function testStepI(array $seq, mixed $expected): void
{
$stepi = new StepI($seq);
$this->assertEquals($expected, $stepi->getSequence());
}
/**
* @return array<int, array<int, array{
* 'e': int,
* 'edir': string,
* 'end': int,
* 'eos': string,
* 'length': int,
* 'maxlevel': int,
* 'sos': string,
* 'start': int,
* 'item': array<int, array{
* 'char': int,
* 'i': int,
* 'level': int,
* 'otype': string,
* 'pdimatch': int,
* 'pos': int,
* 'type': string,
* 'x': int,
* }>,
* }>>
*/
public static function stepIDataProvider(): array
{
return [
[
[
'e' => 0,
'edir' => 'L',
'end' => 3,
'eos' => 'L',
'length' => 4,
'maxlevel' => 0,
'sos' => 'L',
'start' => 0,
'item' => [
[
'char' => 65,
'i' => -1,
'level' => 0,
'otype' => 'L',
'pos' => 0,
'pdimatch' => -1,
'type' => 'L',
'x' => 0,
],
[
'char' => 8207,
'i' => -1,
'level' => 0,
'otype' => 'R',
'pos' => 1,
'pdimatch' => -1,
'type' => 'R',
'x' => 0,
],
[
'char' => 1632,
'i' => -1,
'level' => 0,
'otype' => 'AN',
'pos' => 2,
'pdimatch' => -1,
'type' => 'AN',
'x' => 0,
],
[
'char' => 1776,
'i' => -1,
'level' => 0,
'otype' => 'EN',
'pos' => 3,
'pdimatch' => -1,
'type' => 'EN',
'x' => 0,
],
],
],
[
'e' => 0,
'edir' => 'L',
'end' => 3,
'eos' => 'L',
'length' => 4,
'maxlevel' => 2,
'sos' => 'L',
'start' => 0,
'item' => [
[
'char' => 65,
'i' => -1,
'level' => 0,
'otype' => 'L',
'pos' => 0,
'pdimatch' => -1,
'type' => 'L',
'x' => 0,
],
[
'char' => 8207,
'i' => -1,
'level' => 1,
'otype' => 'R',
'pos' => 1,
'pdimatch' => -1,
'type' => 'R',
'x' => 0,
],
[
'char' => 1632,
'i' => -1,
'level' => 2,
'otype' => 'AN',
'pos' => 2,
'pdimatch' => -1,
'type' => 'AN',
'x' => 0,
],
[
'char' => 1776,
'i' => -1,
'level' => 2,
'otype' => 'EN',
'pos' => 3,
'pdimatch' => -1,
'type' => 'EN',
'x' => 0,
],
],
],
],
[
[
'e' => 1,
'edir' => 'R',
'end' => 3,
'eos' => 'R',
'length' => 4,
'maxlevel' => 0,
'sos' => 'R',
'start' => 0,
'item' => [
[
'char' => 65,
'i' => -1,
'level' => 1,
'otype' => 'L',
'pos' => 0,
'pdimatch' => -1,
'type' => 'L',
'x' => 0,
],
[
'char' => 8207,
'i' => -1,
'level' => 1,
'otype' => 'R',
'pos' => 1,
'pdimatch' => -1,
'type' => 'R',
'x' => 0,
],
[
'char' => 1632,
'i' => -1,
'level' => 1,
'otype' => 'AN',
'pos' => 2,
'pdimatch' => -1,
'type' => 'AN',
'x' => 0,
],
[
'char' => 1776,
'i' => -1,
'level' => 1,
'otype' => 'EN',
'pos' => 3,
'pdimatch' => -1,
'type' => 'EN',
'x' => 0,
],
],
],
[
'e' => 1,
'edir' => 'R',
'end' => 3,
'eos' => 'R',
'length' => 4,
'maxlevel' => 2,
'sos' => 'R',
'start' => 0,
'item' => [
[
'char' => 65,
'i' => -1,
'level' => 2,
'otype' => 'L',
'pos' => 0,
'pdimatch' => -1,
'type' => 'L',
'x' => 0,
],
[
'char' => 8207,
'i' => -1,
'level' => 1,
'otype' => 'R',
'pos' => 1,
'pdimatch' => -1,
'type' => 'R',
'x' => 0,
],
[
'char' => 1632,
'i' => -1,
'level' => 2,
'otype' => 'AN',
'pos' => 2,
'pdimatch' => -1,
'type' => 'AN',
'x' => 0,
],
[
'char' => 1776,
'i' => -1,
'level' => 2,
'otype' => 'EN',
'pos' => 3,
'pdimatch' => -1,
'type' => 'EN',
'x' => 0,
],
],
],
],
];
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,869 @@
<?php
/**
* StepXTest.php
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*
* This file is part of tc-lib-unicode software library.
*/
namespace Test\Bidi;
use Com\Tecnick\Unicode\Bidi\StepX;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
/**
* Bidi Test
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*/
class StepXTest extends TestCase
{
/**
* @param array<int> $ordarr Array of character codes
*/
#[DataProvider('stepXDataProvider')]
public function testStepX(array $ordarr, int $pel, mixed $expected): void
{
$stepx = new StepX($ordarr, $pel);
$this->assertEquals($expected, $stepx->getChrData());
}
/**
* @return array<int, array{
* 0: array<int>,
* 1: int,
* 2: array<int, array{
* 'char': int,
* 'i': int,
* 'level': int,
* 'otype': string,
* 'pdimatch': int,
* 'pos': int,
* 'type': string,
* 'x': int,
* }>,
* }>
*/
public static function stepXDataProvider(): array
{
return [
[
// BD13 Example 1: text1·RLE·text2·PDF·RLE·text3·PDF·text4
[33, 8235, 34, 8236, 8235, 38, 8236, 39],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 5,
'char' => 38,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 7,
'char' => 39,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// BD13 Example 2: text1·RLI·text2·PDI·RLI·text3·PDI·text4
[33, 8295, 34, 8297, 8295, 38, 8297, 39],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 1,
'char' => 8295,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 3,
'char' => 8297,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 4,
'char' => 8295,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 5,
'char' => 38,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 6,
'char' => 8297,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 7,
'char' => 39,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// BD13 Example 3: text1·RLI·text2·LRI·text3·RLE·text4·PDF·text5·PDI·text6·PDI·text7
[33, 8295, 34, 8294, 38, 8235, 39, 8236, 40, 8297, 41, 8297, 42],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 1,
'char' => 8295,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 3,
'char' => 8294,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 4,
'char' => 38,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 6,
'char' => 39,
'i' => -1,
'level' => 3,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 8,
'char' => 40,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 9,
'char' => 8297,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 10,
'char' => 41,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 11,
'char' => 8297,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 12,
'char' => 42,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// X10 Example 1: text1·RLE·text2·LRE·text3·PDF·text4·PDF·RLE·text5·PDF·text6
[33, 8235, 34, 8234, 38, 8236, 39, 8236, 8235, 40, 8236, 41],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 4,
'char' => 38,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 6,
'char' => 39,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 9,
'char' => 40,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 11,
'char' => 41,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// X10 Example 2: text1·RLI·text2·LRI·text3·PDI·text4·PDI·RLI·text5·PDI·text6
[33, 8295, 34, 8294, 38, 8297, 39, 8297, 8295, 40, 8297, 41],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 1,
'char' => 8295,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 3,
'char' => 8294,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 4,
'char' => 38,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 5,
'char' => 8297,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 6,
'char' => 39,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 7,
'char' => 8297,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 8,
'char' => 8295,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 9,
'char' => 40,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 10,
'char' => 8297,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 11,
'char' => 41,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// X10 Example 3: text1·RLE·text2·LRI·text3·RLE·text4·PDI·text5·PDF·text6
[33, 8235, 34, 8294, 38, 8235, 39, 8297, 40, 8236, 41],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 3,
'char' => 8294,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 4,
'char' => 38,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 6,
'char' => 39,
'i' => -1,
'level' => 3,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 7,
'char' => 8297,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 8,
'char' => 40,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 10,
'char' => 41,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// text1·RLO·text2·LRO·text3·RLO·text4·PDF·text5·PDF·text6
[33, 8238, 34, 8237, 38, 8238, 39, 8236, 40, 8236, 41],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'R',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 4,
'char' => 38,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'L',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 6,
'char' => 39,
'i' => -1,
'level' => 3,
'pdimatch' => -1,
'type' => 'R',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 8,
'char' => 40,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'L',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 10,
'char' => 41,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'R',
'otype' => 'ON',
],
],
],
[
// text1·FSI·text2·PDI·text3
[33, 8296, 34, 8297, 38],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 1,
'char' => 8296,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 2,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 3,
'char' => 8297,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 4,
'char' => 38,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// text1·FSI·text2·PDI·text3
[1488, 8296, 1489, 8297, 1490],
1,
[
[
'x' => -1,
'pos' => 0,
'char' => 1488,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'R',
'otype' => 'R',
],
[
'x' => -1,
'pos' => 1,
'char' => 8296,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 2,
'char' => 1489,
'i' => -1,
'level' => 3,
'pdimatch' => -1,
'type' => 'R',
'otype' => 'R',
],
[
'x' => -1,
'pos' => 3,
'char' => 8297,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 4,
'char' => 1490,
'i' => -1,
'level' => 1,
'pdimatch' => -1,
'type' => 'R',
'otype' => 'R',
],
],
],
[
// text1·BN·text2·BN·text3
[33, 1807, 34, 1807, 38],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 2,
'char' => 34,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 4,
'char' => 38,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
[
// Test overflow: text1·130xLRE·LRI·PDF·PDI·PDF·PDI·text2
[
33, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234, 8234,
8234, 8294, 8236, 8297, 8236, 8297, 34,
],
0,
[
[
'x' => -1,
'pos' => 0,
'char' => 33,
'i' => -1,
'level' => 0,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
[
'x' => -1,
'pos' => 121,
'char' => 8294,
'i' => -1,
'level' => 124,
'pdimatch' => -1,
'type' => 'NI',
'otype' => 'NI',
],
[
'x' => -1,
'pos' => 126,
'char' => 34,
'i' => -1,
'level' => 124,
'pdimatch' => -1,
'type' => 'ON',
'otype' => 'ON',
],
],
],
];
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,181 @@
<?php
/**
* BidiTest.php
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*
* This file is part of tc-lib-unicode software library.
*/
namespace Test;
use Com\Tecnick\Unicode\Bidi;
use PHPUnit\Framework\Attributes\DataProvider;
/**
* Bidi Test
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*/
class BidiTest extends TestUtil
{
public function testException(): void
{
$this->bcExpectException('\\' . \Com\Tecnick\Unicode\Exception::class);
new \Com\Tecnick\Unicode\Bidi();
}
/**
* @param ?string $str String to convert (if null it will be generated from $chrarr or $ordarr)
* @param ?array<string> $chrarr Array of UTF-8 chars (if empty it will be generated from $str or $ordarr)
* @param ?array<int> $ordarr Array of UTF-8 codepoints (if empty it will be generated from $str or $chrarr)
* @param string $forcedir If 'R' forces RTL, if 'L' forces LTR
* @param bool $shaping If true enable the shaping algorithm
*/
#[DataProvider('inputDataProvider')]
public function testStr(
?string $str = null,
?array $chrarr = null,
?array $ordarr = null,
string $forcedir = '',
bool $shaping = true
): void {
$bidi = new Bidi($str, $chrarr, $ordarr, $forcedir, $shaping);
$this->assertEquals('test', $bidi->getString());
$this->assertEquals(['t', 'e', 's', 't'], $bidi->getChrArray());
$this->assertEquals([116, 101, 115, 116], $bidi->getOrdArray());
$this->assertEquals([
116 => true,
101 => true,
115 => true,
], $bidi->getCharKeys());
$this->assertEquals(4, $bidi->getNumChars());
}
/**
* @return array<int, array{?string, ?array<string>, ?array<int>, string, bool}>
*/
public static function inputDataProvider(): array
{
return [
['test', null, null, '', true],
[null, ['t', 'e', 's', 't'], null, '', true],
[null, null, [116, 101, 115, 116], '', true],
['test', ['t', 'e', 's', 't'], null, '', true],
['test', null, [116, 101, 115, 116], '', true],
[null, ['t', 'e', 's', 't'], [116, 101, 115, 116], '', true],
['test', ['t', 'e', 's', 't'], [116, 101, 115, 116], '', true],
['test', null, null, 'L', true],
['test', null, null, 'R', true],
];
}
#[DataProvider('bidiStrDataProvider')]
public function testBidiStr(string $str, mixed $expected, string $forcedir = ''): void
{
$bidi = new Bidi($str, null, null, $forcedir, true);
$this->assertEquals($expected, $bidi->getString());
}
/**
* @return array<int, array{string, string, string}>
*/
public static function bidiStrDataProvider(): array
{
return [
[
"\n\nABC\nEFG\n\nHIJ\n\n",
"\n\nABC\nEFG\n\nHIJ\n\n",
'L',
],
[
json_decode('"\u202EABC\u202C"'),
'CBA',
'',
],
[
'left to right',
'right to left',
'R',
],
[
'left to right ',
' right to left',
'R',
],
[
json_decode('"smith (fabrikam \u0600\u0601\u0602) \u05de\u05d6\u05dc"'),
json_decode('"\u05dc\u05d6\u05de (\u0602\u0601\u0600 fabrikam) smith"'),
'R',
],
[
json_decode('"\u0600\u0601\u0602 book(s)"'),
json_decode('"book(s) \u0602\u0601\u0600"'),
'R',
],
[
json_decode('"\u0600\u0601(\u0602\u0603[&ef]!)gh"'),
json_decode('"gh(![ef&]\u0603\u0602)\u0601\u0600"'),
'R',
],
[
'تشكيل اختبار',
'ﺭﺎﺒﺘﺧﺍ ﻞﻴﻜﺸﺗ',
'',
],
[
json_decode('"\u05de\u05d6\u05dc \u05d8\u05d5\u05d1"'),
json_decode('"\u05d1\u05d5\u05d8 \u05dc\u05d6\u05de"'),
'',
],
[
json_decode(
'"\u0644\u0644\u0647 \u0600\u0601\u0602 \uFB50'
. ' \u0651\u064c\u0651\u064d\u0651\u064e\u0651\u064f\u0651\u0650'
. ' \u0644\u0622"'
),
json_decode('"\ufef5\ufedf \ufc62\ufc61\ufc60\ufc5f\ufc5e \ufb50 \u0602\u0601\u0600 \ufdf2"'),
'',
],
[
json_decode('"A\u2067\u05d8\u2069B"'),
json_decode('"A\u2067\u05d8\u2069B"'),
'',
],
[
// RLI + PDI
json_decode(
'"The words \"\u2067\u05de\u05d6\u05dc [mazel] \u05d8\u05d5\u05d1 [tov]\u2069\"'
. ' mean \"Congratulations!\""'
),
'The words "[tov] בוט [mazel] לזמ⁩" mean "Congratulations!"',
'',
],
[
// RLE + PDF
json_decode('"it is called \"\u202bAN INTRODUCTION TO java\u202c\" - $19.95 in hardcover."'),
'it is called "java TO INTRODUCTION AN" - $19.95 in hardcover.',
'',
],
[
// RLI + PDI
json_decode('"it is called \"\u2067AN INTRODUCTION TO java\u2069\" - $19.95 in hardcover."'),
'it is called "java TO INTRODUCTION AN" - $19.95 in hardcover.',
'',
],
];
}
}

View File

@@ -0,0 +1,207 @@
<?php
/**
* ConvertTest.php
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*
* This file is part of tc-lib-unicode software library.
*/
namespace Test;
use Com\Tecnick\Unicode\Data\Latin;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
/**
* Convert Test
*
* @since 2011-05-23
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*/
class ConvertTest extends TestCase
{
protected function getTestObject(): \Com\Tecnick\Unicode\Convert
{
return new \Com\Tecnick\Unicode\Convert();
}
#[DataProvider('chrDataProvider')]
public function testChr(int $ord, mixed $expected): void
{
$convert = $this->getTestObject();
$chr = $convert->chr($ord);
$this->assertEquals($expected, $chr);
}
#[DataProvider('chrDataProvider')]
public function testOrd(mixed $expected, string $chr): void
{
$convert = $this->getTestObject();
$ord = $convert->ord($chr);
$this->assertEquals($expected, $ord);
}
/**
* @return array<int, array{0:int,1:string}>
*/
public static function chrDataProvider(): array
{
return [
[32, ' '],
[48, '0'],
[65, 'A'],
[182, '¶'],
[255, 'ÿ'],
[256, 'Ā'],
[544, 'Ƞ'],
[916, 'Δ'],
[1488, 'א'],
[21488, '台'],
[49436, '서'],
[70039, '𑆗'],
[195101, '𪘀'],
];
}
public function testStrToChrArr(): void
{
$convert = $this->getTestObject();
$res = $convert->strToChrArr('0A¶ÿĀȠΔא台서');
$this->assertEquals(['0', 'A', '¶', 'ÿ', 'Ā', 'Ƞ', 'Δ', 'א', '台', '서'], $res);
}
public function testChrArrToOrdArr(): void
{
$convert = $this->getTestObject();
$res = $convert->chrArrToOrdArr(['0', 'A', '¶', 'ÿ', 'Ā', 'Ƞ', 'Δ', 'א', '台', '서']);
$this->assertEquals([48, 65, 182, 255, 256, 544, 916, 1488, 21488, 49436], $res);
}
public function testOrdArrToChrArr(): void
{
$convert = $this->getTestObject();
$res = $convert->ordArrToChrArr([48, 65, 182, 255, 256, 544, 916, 1488, 21488, 49436]);
$this->assertEquals(['0', 'A', '¶', 'ÿ', 'Ā', 'Ƞ', 'Δ', 'א', '台', '서'], $res);
}
public function testStrToOrdArr(): void
{
$convert = $this->getTestObject();
$res = $convert->strToOrdArr('0A¶ÿĀȠΔא台서');
$this->assertEquals([48, 65, 182, 255, 256, 544, 916, 1488, 21488, 49436], $res);
}
public function testGetSubUniArrStr(): void
{
$convert = $this->getTestObject();
$res = $convert->getSubUniArrStr(['0', 'A', '¶', 'ÿ', 'Ā', 'Ƞ', 'Δ', 'א', '台', '서']);
$this->assertEquals('0A¶ÿĀȠΔא台서', $res);
$res = $convert->getSubUniArrStr(['0', 'A', '¶', 'ÿ', 'Ā', 'Ƞ', 'Δ', 'א', '台', '서'], 2, 8);
$this->assertEquals('¶ÿĀȠΔא', $res);
}
public function testUniArrToLatinArr(): void
{
$convert = $this->getTestObject();
$uniarr = array_keys(Latin::SUBSTITUTE);
$uniarr[] = 65533; // 0xFFFD - character to ignore
$uniarr[] = 123456; // undefined char
$uniarr[] = 65; // ASCII char
$latarr = array_values(Latin::SUBSTITUTE);
$latarr[] = 63;
$latarr[] = 65;
$res = $convert->uniArrToLatinArr($uniarr);
$this->assertEquals($latarr, $res);
}
public function testLatinArrToStr(): void
{
$convert = $this->getTestObject();
$res = $convert->latinArrToStr([48, 57, 65, 90, 97, 122]);
$this->assertEquals('09AZaz', $res);
}
#[DataProvider('strToHexDataProvider')]
public function testStrToHex(string $str, mixed $hex): void
{
$convert = $this->getTestObject();
$res = $convert->strToHex($str);
$this->assertEquals($hex, $res);
}
#[DataProvider('strToHexDataProvider')]
public function testHexToStr(mixed $str, string $hex): void
{
$convert = $this->getTestObject();
$res = $convert->hexToStr($hex);
$this->assertEquals($str, $res);
}
/**
* @return array<int, array<string>>
*/
public static function strToHexDataProvider(): array
{
return [
['', ''],
['A', '41'],
['AB', '4142'],
['ABC', '414243'],
["\n", '0a'],
];
}
#[DataProvider('toUTF16BEDataProvider')]
public function testToUTF16BE(string $str, mixed $exp): void
{
$convert = $this->getTestObject();
$res = $convert->toUTF16BE($str);
$this->assertEquals($exp, $convert->strToHex($res));
}
/**
* @return array<int, array<string>>
*/
public static function toUTF16BEDataProvider(): array
{
return [
['', ''],
['ABC', '004100420043'],
[json_decode('"\u0010\uffff\u00ff\uff00"'), '0010ffff00ffff00'],
];
}
#[DataProvider('toUTF8DataProvider')]
public function testToUTF8(string $str, mixed $exp, ?string $enc = null): void
{
$convert = $this->getTestObject();
$res = $convert->toUTF8($str, $enc);
$this->assertEquals($exp, $res);
}
/**
* @return array<int, array<string>>
*/
public static function toUTF8DataProvider(): array
{
return [
['', ''],
['òèìòù', 'òèìòù'],
['òèìòù', 'òèìòù', 'ISO-8859-1'],
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* TestUtil.php
*
* @since 2020-12-19
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*
* This file is part of tc-lib-color software library.
*/
namespace Test;
use PHPUnit\Framework\TestCase;
/**
* Web Color class test
*
* @since 2020-12-19
* @category Library
* @package Unicode
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-unicode
*/
class TestUtil extends TestCase
{
/**
* @param class-string<\Throwable> $exception
*/
public function bcExpectException($exception): void
{
parent::expectException($exception);
}
}