@@ -269,6 +269,41 @@ def test_em_dash(self):
269269 "he" , " " , "was" , " " , "gone" ]
270270 self .check_split (text , expect )
271271
272+ def test_unicode_em_dash (self ):
273+ # Test text with Unicode em-dashes
274+ text = "Em-dashes should be written \u2014 thus."
275+ self .check_wrap (text , 25 ,
276+ ["Em-dashes should be" ,
277+ "written \u2014 thus." ])
278+
279+ # Probe the boundaries of the em-dash. Parallels ASCII tests
280+ # but widths - 1 since len('\u2014') = len('--') - 1
281+ self .check_wrap (text , 28 ,
282+ ["Em-dashes should be written" ,
283+ "\u2014 thus." ])
284+ expect = ["Em-dashes should be written \u2014 " ,
285+ "thus." ]
286+ self .check_wrap (text , 29 , expect )
287+ self .check_wrap (text , 34 , expect )
288+ self .check_wrap (text , 35 ,
289+ ["Em-dashes should be written \u2014 thus." ])
290+
291+ # Tests for adjacent glyphs not needed for Unicode em-dash
292+ # because unlike adjacent hypens, not meaningful or common.
293+
294+ # All of the above behaviour could be deduced by probing the
295+ # _split() method. Note mixed real and simulated em-dashes.
296+ text = "Here's an \u2014 em-dash and\u2014 here's another---and another! And--more!"
297+ expect = ["Here's" , " " , "an" , " " , "\u2014 " , " " , "em-" , "dash" , " " ,
298+ "and" , "\u2014 " , "here's" , " " , "another" , "---" ,
299+ "and" , " " , "another!" , " " , "And" , "--" , "more!" ]
300+
301+ self .check_split (text , expect )
302+
303+ text = "and then\u2014 bam!\u2014 he was gone"
304+ expect = ["and" , " " , "then" , "\u2014 " , "bam!" , "\u2014 " ,
305+ "he" , " " , "was" , " " , "gone" ]
306+ self .check_split (text , expect )
272307
273308 def test_unix_options (self ):
274309 # Test that Unix-style command-line options are wrapped correctly.
0 commit comments