aboutsummaryrefslogtreecommitdiffstats
path: root/Test
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2015-01-07 11:00:06 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2015-01-07 11:00:06 +0100
commitc3e510b9aaf685e9bba2dcddd7ee23850faddfe4 (patch)
tree50d26f9ff978816d83370f96b350cdc67510702d /Test
parentd8d6efcfe9a5e6ce6d384e7ab0f3ed917f43e055 (diff)
parent369111c0f904e25ea4156fdb50775448af1a9785 (diff)
downloadUstring-c3e510b9aaf685e9bba2dcddd7ee23850faddfe4.zip
Ustring-c3e510b9aaf685e9bba2dcddd7ee23850faddfe4.tar.gz
Ustring-c3e510b9aaf685e9bba2dcddd7ee23850faddfe4.tar.bz2
Merge branch 'getCharWidth' into incoming
Diffstat (limited to 'Test')
-rw-r--r--Test/Unit/String.php72
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