Lines Matching refs:zlib
13 zlib = import_module('zlib')
19 self.assertEqual(zlib.crc32(""), zlib.crc32("", 0))
20 self.assertTrue(zlib.crc32("abc", 0xffffffff))
23 self.assertEqual(zlib.crc32("", 0), 0)
24 self.assertEqual(zlib.crc32("", 1), 1)
25 self.assertEqual(zlib.crc32("", 432), 432)
28 self.assertEqual(zlib.adler32(""), zlib.adler32("", 1))
29 self.assertTrue(zlib.adler32("abc", 0xffffffff))
32 self.assertEqual(zlib.adler32("", 0), 0)
33 self.assertEqual(zlib.adler32("", 1), 1)
34 self.assertEqual(zlib.adler32("", 432), 432)
42 self.assertEqual32(zlib.crc32("penguin", 0), 0x0e5c1a120L)
43 self.assertEqual32(zlib.crc32("penguin", 1), 0x43b6aa94)
44 self.assertEqual32(zlib.adler32("penguin", 0), 0x0bcf02f6)
45 self.assertEqual32(zlib.adler32("penguin", 1), 0x0bd602f7)
47 self.assertEqual(zlib.crc32("penguin"), zlib.crc32("penguin", 0))
48 self.assertEqual(zlib.adler32("penguin"),zlib.adler32("penguin",1))
54 self.assertEqual(zlib.crc32(foo), -1808088941)
55 self.assertEqual(zlib.crc32('spam'), 1138425661)
56 self.assertEqual(zlib.adler32(foo+foo), -721416943)
57 self.assertEqual(zlib.adler32('spam'), 72286642)
61 self.assertEqual(binascii.crc32(foo), zlib.crc32(foo))
62 self.assertEqual(binascii.crc32('spam'), zlib.crc32('spam'))
68 self.assertEqual(zlib.crc32('ham', -1), zlib.crc32('ham', 0xffffffffL))
69 self.assertEqual(zlib.crc32('spam', -3141593),
70 zlib.crc32('spam', 0xffd01027L))
71 self.assertEqual(zlib.crc32('spam', -(2**31)),
72 zlib.crc32('spam', (2**31)))
79 # (but -1 is Z_DEFAULT_COMPRESSION and apparently the zlib
81 self.assertRaises(zlib.error, zlib.compress, 'ERROR', 10)
85 self.assertRaises(ValueError, zlib.compressobj, 1, zlib.DEFLATED, 0)
88 zlib.compressobj, 1, zlib.DEFLATED, zlib.MAX_WBITS + 1)
92 self.assertRaises(ValueError, zlib.decompressobj, -1)
96 self.assertRaises(ValueError, zlib.decompressobj().flush, 0)
97 self.assertRaises(ValueError, zlib.decompressobj().flush, -1)
105 # The assumption is that zlib's memory is not big enough to exploit
119 compressed = zlib.compress(data, 1)
135 x = zlib.compress(HAMLET_SCENE)
136 self.assertEqual(zlib.decompress(x), HAMLET_SCENE)
141 x = zlib.compress(data)
142 self.assertEqual(zlib.decompress(x), data)
146 x = zlib.compress(HAMLET_SCENE)
147 self.assertRaisesRegexp(zlib.error,
149 zlib.decompress, x[:-1])
155 compress = lambda s: zlib.compress(s, 1)
160 self.check_big_decompress_buffer(size, zlib.decompress)
168 co = zlib.compressobj()
171 self.assertRaises(zlib.error, co.flush) # second flush should not work
172 dco = zlib.decompressobj()
180 method = zlib.DEFLATED
183 strategy = zlib.Z_FILTERED
184 co = zlib.compressobj(level, method, wbits, memlevel, strategy)
187 dco = zlib.decompressobj(wbits)
195 co = zlib.compressobj()
202 dco = zlib.decompressobj()
211 co = zlib.compressobj()
218 self.assertEqual(data, zlib.decompress(combuf))
220 dco = zlib.decompressobj()
250 co = zlib.compressobj()
256 self.assertEqual(data, zlib.decompress(combuf),
259 dco = zlib.decompressobj()
275 co = zlib.compressobj()
281 self.assertEqual(data, zlib.decompress(combuf),
284 dco = zlib.decompressobj()
309 dco = zlib.decompressobj()
317 dco = zlib.decompressobj()
326 sync_opt = [getattr(zlib, opt) for opt in sync_opt
327 if hasattr(zlib, opt)]
332 obj = zlib.compressobj( level )
337 self.assertEqual(zlib.decompress(''.join([a,b,c,d])),
346 if hasattr(zlib, 'Z_SYNC_FLUSH'):
350 co = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
351 dco = zlib.decompressobj()
370 second = co.flush(zlib.Z_SYNC_FLUSH)
381 co = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
382 self.assertTrue(co.flush()) # Returns a zlib header
383 dco = zlib.decompressobj()
390 self.assertEqual(zlib.decompress(x), 'foo')
391 self.assertRaises(zlib.error, zlib.decompress, x[:-5])
394 dco = zlib.decompressobj()
399 if hasattr(zlib.compressobj(), "copy"):
404 c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
419 self.assertEqual(zlib.decompress(s0),data0+data0)
420 zlib.decompress(s1),data0+data1)
424 c = zlib.compressobj()
429 if hasattr(zlib.decompressobj(), "copy"):
433 comp = zlib.compress(data)
435 d0 = zlib.decompressobj()
453 data = zlib.compress(HAMLET_SCENE)
454 d = zlib.decompressobj()
463 c = zlib.compressobj(1)
469 d = zlib.decompressobj()