@@ -12,13 +12,27 @@ function setUp() {
1212
1313 function test_string_length () {
1414 $ this ->assertEquals ( \cli \Colors::length ( 'x ' ), 1 );
15+ $ this ->assertEquals ( \cli \Colors::length ( '日 ' ), 1 );
16+ }
17+
18+ function test_string_width () {
19+ $ this ->assertEquals ( \cli \Colors::width ( 'x ' ), 1 );
20+ $ this ->assertEquals ( \cli \Colors::width ( '日 ' ), 2 ); // Double-width char.
1521 }
1622
1723 function test_encoded_string_length () {
1824
1925 $ this ->assertEquals ( \cli \Colors::length ( 'hello ' ), 5 );
2026 $ this ->assertEquals ( \cli \Colors::length ( 'óra ' ), 3 );
21- $ this ->assertEquals ( \cli \Colors::length ( '日本語 ' ), 6 ); // 3 double-width chars.
27+ $ this ->assertEquals ( \cli \Colors::length ( '日本語 ' ), 3 );
28+
29+ }
30+
31+ function test_encoded_string_width () {
32+
33+ $ this ->assertEquals ( \cli \Colors::width ( 'hello ' ), 5 );
34+ $ this ->assertEquals ( \cli \Colors::width ( 'óra ' ), 3 );
35+ $ this ->assertEquals ( \cli \Colors::width ( '日本語 ' ), 6 ); // 3 double-width chars.
2236
2337 }
2438
@@ -45,6 +59,12 @@ function test_encoded_substr() {
4559
4660 function test_colorized_string_length () {
4761 $ this ->assertEquals ( \cli \Colors::length ( \cli \Colors::colorize ( '%Gx%n ' , true ) ), 1 );
62+ $ this ->assertEquals ( \cli \Colors::length ( \cli \Colors::colorize ( '%G日%n ' , true ) ), 1 );
63+ }
64+
65+ function test_colorized_string_width () {
66+ $ this ->assertEquals ( \cli \Colors::width ( \cli \Colors::colorize ( '%Gx%n ' , true ) ), 1 );
67+ $ this ->assertEquals ( \cli \Colors::width ( \cli \Colors::colorize ( '%G日%n ' , true ) ), 2 ); // Double-width char.
4868 }
4969
5070 function test_colorize_string_is_colored () {
0 commit comments