summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-12-08 22:25:45 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-12-08 22:25:45 (GMT)
commit53a9dd776e62f6bc3b1884f3aa82e49a78bd83a8 (patch)
treeb62f83eb883c6ffceb9c0fff6083c4f914c832a2 /Lib/test/test_codecs.py
parent84cc06288d88cb12b382bf3e4695f8538ab498ff (diff)
downloadcpython-53a9dd776e62f6bc3b1884f3aa82e49a78bd83a8.zip
cpython-53a9dd776e62f6bc3b1884f3aa82e49a78bd83a8.tar.gz
cpython-53a9dd776e62f6bc3b1884f3aa82e49a78bd83a8.tar.bz2
Issue #10546: UTF-16-LE and UTF-16-BE *do* support non-BMP characters
Fix the doc and add tests.
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index bc29e06..8287a5b 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -544,6 +544,12 @@ class UTF16LETest(ReadTest):
self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,
b"\xff", "strict", True)
+ def test_nonbmp(self):
+ self.assertEqual("\U00010203".encode(self.encoding),
+ b'\x00\xd8\x03\xde')
+ self.assertEqual(b'\x00\xd8\x03\xde'.decode(self.encoding),
+ "\U00010203")
+
class UTF16BETest(ReadTest):
encoding = "utf-16-be"
@@ -566,6 +572,12 @@ class UTF16BETest(ReadTest):
self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,
b"\xff", "strict", True)
+ def test_nonbmp(self):
+ self.assertEqual("\U00010203".encode(self.encoding),
+ b'\xd8\x00\xde\x03')
+ self.assertEqual(b'\xd8\x00\xde\x03'.decode(self.encoding),
+ "\U00010203")
+
class UTF8Test(ReadTest):
encoding = "utf-8"