summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_zlib.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-03-17 18:48:05 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-03-17 18:48:05 (GMT)
commitf48f9d38c02ef914194eeeeb6cdae770e218af00 (patch)
tree66b91bf167ab2d565d9da953376e038b3380796b /Lib/test/test_zlib.py
parent33451d8ab143fb89374673d3aa751910c5b1031e (diff)
downloadcpython-f48f9d38c02ef914194eeeeb6cdae770e218af00.zip
cpython-f48f9d38c02ef914194eeeeb6cdae770e218af00.tar.gz
cpython-f48f9d38c02ef914194eeeeb6cdae770e218af00.tar.bz2
Force zlib.crc32 and zlib.adler32 to return a signed integer on all platforms
regardless of the native sizeof(long) used in the integer object. This somewhat odd behavior of returning a signed is maintained in 2.x for compatibility reasons of always returning an integer rather than a long object. Fixes Issue1202 for Python 2.6
Diffstat (limited to 'Lib/test/test_zlib.py')
-rw-r--r--Lib/test/test_zlib.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 13926e1..7c7ef26 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -38,6 +38,15 @@ class ChecksumTestCase(unittest.TestCase):
self.assertEqual(zlib.crc32("penguin"), zlib.crc32("penguin", 0))
self.assertEqual(zlib.adler32("penguin"),zlib.adler32("penguin",1))
+ def test_abcdefghijklmnop(self):
+ """test issue1202 compliance: signed crc32, adler32 in 2.x"""
+ foo = 'abcdefghijklmnop'
+ # explicitly test signed behavior
+ self.assertEqual(zlib.crc32(foo), -1808088941)
+ self.assertEqual(zlib.crc32('spam'), 1138425661)
+ self.assertEqual(zlib.adler32(foo+foo), -721416943)
+ self.assertEqual(zlib.adler32('spam'), 72286642)
+
class ExceptionTestCase(unittest.TestCase):