]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add more tests for the cython websocket mask function
authorBen Darnell <ben@bendarnell.com>
Sun, 27 Oct 2013 02:42:26 +0000 (22:42 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 27 Oct 2013 02:42:26 +0000 (22:42 -0400)
tornado/test/websocket_test.py

index 66c48e5763000537c5747d5a2e8bd32d45980c8c..28375cd69ac7d842293740f6e613a492b8ee96f2 100644 (file)
@@ -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):