diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-02 11:11:27 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-02 11:11:27 (GMT) |
commit | 5593d8aeb4bcc904ff58e8e3eb8b799a0aabc302 (patch) | |
tree | ad617343c26a37551383247908d741ab31234842 /Lib/test/test_unicode.py | |
parent | 1c24bd02520a647415de5c220834d7bec265a8d0 (diff) | |
download | cpython-5593d8aeb4bcc904ff58e8e3eb8b799a0aabc302.zip cpython-5593d8aeb4bcc904ff58e8e3eb8b799a0aabc302.tar.gz cpython-5593d8aeb4bcc904ff58e8e3eb8b799a0aabc302.tar.bz2 |
Issue #8670: PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() replace
UTF-16 surrogate pairs by single non-BMP characters for 16 bits Py_UNICODE
and 32 bits wchar_t (eg. Linux in narrow build).
Diffstat (limited to 'Lib/test/test_unicode.py')
-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 2ac79fb..285b7af 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1419,6 +1419,17 @@ class UnicodeTest(string_tests.CommonTest, self.assertEquals(size, 7) self.assertEquals(wchar, 'abc\0def\0') + nonbmp = chr(0x10ffff) + if sizeof(c_wchar) == 2: + buflen = 3 + nchar = 2 + else: # sizeof(c_wchar) == 4 + buflen = 2 + nchar = 1 + wchar, size = test_aswidechar(nonbmp, buflen) + self.assertEquals(size, nchar) + self.assertEquals(wchar, nonbmp + '\0') + # Test PyUnicode_AsWideCharString() def test_aswidecharstring(self): from _testcapi import test_aswidecharstring @@ -1432,6 +1443,15 @@ class UnicodeTest(string_tests.CommonTest, self.assertEquals(size, 7) self.assertEquals(wchar, 'abc\0def\0') + nonbmp = chr(0x10ffff) + if sizeof(c_wchar) == 2: + nchar = 2 + else: # sizeof(c_wchar) == 4 + nchar = 1 + wchar, size = test_aswidecharstring(nonbmp) + self.assertEquals(size, nchar) + self.assertEquals(wchar, nonbmp + '\0') + def test_main(): support.run_unittest(__name__) |