55
66class TestUtils (TestCase ):
77 def test_str_width (self ):
8- characters = ['a' , '1' , '_' , '!' , '\x1a ' , '\u263A ' , '\uffb9 ' ]
8+ characters = [
9+ 'a' ,
10+ '1' ,
11+ '_' ,
12+ '!' ,
13+ '\x1a ' ,
14+ '\u263A ' ,
15+ '\uffb9 ' ,
16+ '\N{LATIN SMALL LETTER E WITH ACUTE} ' , # é
17+ '\N{LATIN SMALL LETTER E WITH CEDILLA} ' , # ȩ
18+ '\u00ad ' ,
19+ ]
920 for c in characters :
1021 self .assertEqual (str_width (c ), 1 )
1122
23+ zero_width_characters = [
24+ '\N{COMBINING ACUTE ACCENT} ' ,
25+ '\N{ZERO WIDTH JOINER} ' ,
26+ ]
27+ for c in zero_width_characters :
28+ with self .subTest (character = c ):
29+ self .assertEqual (str_width (c ), 0 )
30+
1231 characters = [chr (99989 ), chr (99999 )]
1332 for c in characters :
1433 self .assertEqual (str_width (c ), 2 )
@@ -25,6 +44,8 @@ def test_wlen(self):
2544
2645 self .assertEqual (wlen ('hello' ), 5 )
2746 self .assertEqual (wlen ('hello' + '\x1a ' ), 7 )
47+ self .assertEqual (wlen ('e\N{COMBINING ACUTE ACCENT} ' ), 1 )
48+ self .assertEqual (wlen ('a\N{ZERO WIDTH JOINER} b' ), 2 )
2849
2950 def test_prev_next_window (self ):
3051 def gen_normal ():
0 commit comments