# HG changeset patch # User Atul Varma # Date 1250320803 25200 # Node ID d2891ca1b89ce31e46ad2f61b37c8b042902a21a # Parent 97d1faf02460b46d8f75f654f93e0157f1091928 Added tests involving unicode with embedded NUL characters. diff -r 97d1faf02460 -r d2891ca1b89c test_pymonkey.py --- a/test_pymonkey.py Sat Aug 15 00:10:29 2009 -0700 +++ b/test_pymonkey.py Sat Aug 15 00:20:03 2009 -0700 @@ -238,6 +238,13 @@ self.assertEqual(funcArgs[1][0], 1) self.assertEqual(funcArgs[1][1], u'foo') + def testJsWrappedPythonFunctionReturnsUnicodeWithEmbeddedNULs(self): + def hai2u(cx, this, args): + return args[0] + u"o hai" + self.assertEqual(self._evalJsWrappedPyFunc(hai2u, + 'hai2u("blah\x00 ")'), + u"blah\x00 o hai") + def testJsWrappedPythonFunctionReturnsUnicode(self): def hai2u(cx, this, args): return u"o hai" @@ -426,6 +433,10 @@ retval = self._evaljs("") self.assertTrue(retval is pymonkey.undefined) + def testEvaludateReturnsUnicodeWithEmbeddedNULs(self): + retval = self._evaljs("'\x00hi'") + self.assertEqual(retval, u'\x00hi') + def testEvaluateReturnsSMPUnicode(self): # This is 'LINEAR B SYLLABLE B008 A', in the supplementary # multilingual plane (SMP).