diff options
Diffstat (limited to 'Test')
-rw-r--r-- | Test/Unit/String.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Test/Unit/String.php b/Test/Unit/String.php index f3863b9..32d9001 100644 --- a/Test/Unit/String.php +++ b/Test/Unit/String.php @@ -744,6 +744,78 @@ class String extends Test\Unit\Suite { ->isEqualTo(LUT::RTL); } + public function case_get_char_width ( ) { + + $this + ->given( + $data = [ + // 8-bit control character. + [0x0, 0], + [0x19, -1], + [0x7f, -1], + [0x9f, -1], + + // Regular. + [0xa0, 1], + + // Non-spacing characters mark. + [0x300, 0], // in Mn + [0x488, 0], // in Me + [0x600, 0], // in Cf + [0xad, 1], // in Cf, but the only exception + [0x1160, 0], + [0x11ff, 0], + [0x200b, 0], + + // To test the last return statement. + [0x1100, 2], + [0x2160, 1], + [0x3f60, 2], + [0x303f, 1], + [0x2329, 2], + [0xaed0, 2], + [0x232a, 2], + [0xffa4, 1], + [0xfe10, 2], + [0xfe30, 2], + [0xff00, 2], + [0xf900, 2] + ] + ) + ->when(function ( ) use ( $data ) { + + foreach($data as $datum) { + + list($code, $width) = $datum; + + $this + ->when($result = LUT::getCharWidth(LUT::fromCode($code))) + ->then + ->integer($result) + ->isEqualTo($width); + } + }); + } + + public function case_is_char_printable ( ) { + + $this + ->when($result = LUT::isCharPrintable(LUT::fromCode(0x7f))) + ->then + ->boolean($result) + ->isFalse() + + ->when($result = LUT::isCharPrintable(LUT::fromCode(0xa0))) + ->then + ->boolean($result) + ->isTrue() + + ->when($result = LUT::isCharPrintable(LUT::fromCode(0x1100))) + ->then + ->boolean($result) + ->isTrue(); + } + public function case_from_code ( ) { $this |