diff options
author | Hye-Shik Chang <hyeshik@gmail.com> | 2004-06-02 16:49:17 (GMT) |
---|---|---|
committer | Hye-Shik Chang <hyeshik@gmail.com> | 2004-06-02 16:49:17 (GMT) |
commit | 974ed7cfa50b666c9ab91f7a3f8f26049d387107 (patch) | |
tree | d821c74c26231d988f34764d0fdfe3494036ee95 /Lib | |
parent | b6568b91fdf7de1377dba395c6725a7307b818ee (diff) | |
download | cpython-974ed7cfa50b666c9ab91f7a3f8f26049d387107.zip cpython-974ed7cfa50b666c9ab91f7a3f8f26049d387107.tar.gz cpython-974ed7cfa50b666c9ab91f7a3f8f26049d387107.tar.bz2 |
- SF #962502: Add two more methods for unicode type; width() and
iswide() for east asian width manipulation. (Inspired by David
Goodger, Reviewed by Martin v. Loewis)
- Move _PyUnicode_TypeRecord.flags to the end of the struct so that
no padding is added for UCS-4 builds. (Suggested by Martin v. Loewis)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_unicode.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 5ce2842..e01a461 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -291,6 +291,26 @@ class UnicodeTest( self.assertRaises(TypeError, u"abc".isnumeric, 42) + def test_iswide(self): + self.checkequalnofix(False, u'', 'iswide') + self.checkequalnofix(False, u'\x1f', 'iswide') # Neutral + self.checkequalnofix(False, u'\x20', 'iswide') # Narrow + self.checkequalnofix(True, u'\u2329', 'iswide') # Wide + self.checkequalnofix(False, u'\uff64', 'iswide') # Half + self.checkequalnofix(True, u'\u3000', 'iswide') # Full + self.checkequalnofix(False, u'\u2460', 'iswide') # Ambiguous + self.checkequalnofix(True, u'\ud55c\uae00', 'iswide') + self.checkequalnofix(False, u'\ud55c\u2606\uae00', 'iswide') + + def test_wide(self): + self.assertEqual(u''.width(), 0) + self.assertEqual(u'abcd'.width(), 4) + self.assertEqual(u'\u0187\u01c9'.width(), 2) + self.assertEqual(u'\u2460\u2329'.width(), 3) + self.assertEqual(u'\u2329\u2460'.width(), 3) + self.assertEqual(u'\ud55c\uae00'.width(), 4) + self.assertEqual(u'\ud55c\u2606\uae00'.width(), 5) + def test_contains(self): # Testing Unicode contains method self.assert_('a' in u'abdb') |