From: Ben Darnell Date: Sun, 27 Oct 2013 02:42:26 +0000 (-0400) Subject: Add more tests for the cython websocket mask function X-Git-Tag: v3.2.0b1~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0500ad6e203cc6640a2f77abda41173a9d2e3efd;p=thirdparty%2Ftornado.git Add more tests for the cython websocket mask function --- diff --git a/tornado/test/websocket_test.py b/tornado/test/websocket_test.py index 66c48e576..28375cd69 100644 --- a/tornado/test/websocket_test.py +++ b/tornado/test/websocket_test.py @@ -125,6 +125,15 @@ class MaskFunctionMixin(object): self.assertEqual(self.mask(b'abcd', b'b'), b'\x03') self.assertEqual(self.mask(b'abcd', b'54321'), b'TVPVP') self.assertEqual(self.mask(b'ZXCV', b'98765432'), b'c`t`olpd') + # Include test cases with \x00 bytes (to ensure that the C + # extension isn't depending on null-terminated strings) and + # bytes with the high bit set (to smoke out signedness issues). + self.assertEqual(self.mask(b'\x00\x01\x02\x03', + b'\xff\xfb\xfd\xfc\xfe\xfa'), + b'\xff\xfa\xff\xff\xfe\xfb') + self.assertEqual(self.mask(b'\xff\xfb\xfd\xfc', + b'\x00\x01\x02\x03\x04\x05'), + b'\xff\xfa\xff\xff\xfb\xfe') class PythonMaskFunctionTest(MaskFunctionMixin, unittest.TestCase):