aboutsummaryrefslogtreecommitdiffstats
path: root/Test
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2015-01-06 03:04:40 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2015-01-06 03:04:40 +0100
commitfddfd2741d04230e413303be21139a0c0fba5295 (patch)
tree5ccc62f75b82e48ec3c955568e6b6b409cdfcb26 /Test
parent8d88eb36e0ab30496b6318059d385a2408ea7fde (diff)
downloadUstring-fddfd2741d04230e413303be21139a0c0fba5295.zip
Ustring-fddfd2741d04230e413303be21139a0c0fba5295.tar.gz
Ustring-fddfd2741d04230e413303be21139a0c0fba5295.tar.bz2
Test the String::getCharWidth method.
Diffstat (limited to 'Test')
-rw-r--r--Test/Unit/String.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/Test/Unit/String.php b/Test/Unit/String.php
index ccf7e0e..80a7f01 100644
--- a/Test/Unit/String.php
+++ b/Test/Unit/String.php
@@ -744,6 +744,50 @@ 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],
+
+ // 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_from_code ( ) {
$this