186
186
'N\x90\x1d\x1ewhich is meant to differ from\n\x91:\x13',
189
def test_make_delta_with_large_copies(self):
190
# We want to have a copy that is larger than 64kB, which forces us to
191
# issue multiple copy instructions.
192
big_text = _text3 * 1220
193
delta = self.make_delta(big_text, big_text)
195
'\xdc\x86\x0a' # Encoding the length of the uncompressed text
196
'\x80' # Copy 64kB, starting at byte 0
197
'\x84\x01' # and another 64kB starting at 64kB
198
'\xb4\x02\x5c\x83', # And the bit of tail.
199
None, # Both implementations should be identical
189
202
def test_apply_delta_is_typesafe(self):
190
203
self.apply_delta(_text1, 'M\x90M')
191
204
self.assertRaises(TypeError, self.apply_delta, object(), 'M\x90M')
358
371
self.assertEqual((exp_offset, exp_length, exp_newpos), out)
360
373
def test_encode_no_length(self):
361
self.assertEncode('\x80', 0, None)
362
self.assertEncode('\x81\x01', 1, None)
363
self.assertEncode('\x81\x0a', 10, None)
364
self.assertEncode('\x81\xff', 255, None)
365
self.assertEncode('\x82\x01', 256, None)
366
self.assertEncode('\x83\x01\x01', 257, None)
367
self.assertEncode('\x8F\xff\xff\xff\xff', 0xFFFFFFFF, None)
368
self.assertEncode('\x8E\xff\xff\xff', 0xFFFFFF00, None)
369
self.assertEncode('\x8D\xff\xff\xff', 0xFFFF00FF, None)
370
self.assertEncode('\x8B\xff\xff\xff', 0xFF00FFFF, None)
371
self.assertEncode('\x87\xff\xff\xff', 0x00FFFFFF, None)
372
self.assertEncode('\x8F\x04\x03\x02\x01', 0x01020304, None)
374
self.assertEncode('\x80', 0, 64*1024)
375
self.assertEncode('\x81\x01', 1, 64*1024)
376
self.assertEncode('\x81\x0a', 10, 64*1024)
377
self.assertEncode('\x81\xff', 255, 64*1024)
378
self.assertEncode('\x82\x01', 256, 64*1024)
379
self.assertEncode('\x83\x01\x01', 257, 64*1024)
380
self.assertEncode('\x8F\xff\xff\xff\xff', 0xFFFFFFFF, 64*1024)
381
self.assertEncode('\x8E\xff\xff\xff', 0xFFFFFF00, 64*1024)
382
self.assertEncode('\x8D\xff\xff\xff', 0xFFFF00FF, 64*1024)
383
self.assertEncode('\x8B\xff\xff\xff', 0xFF00FFFF, 64*1024)
384
self.assertEncode('\x87\xff\xff\xff', 0x00FFFFFF, 64*1024)
385
self.assertEncode('\x8F\x04\x03\x02\x01', 0x01020304, 64*1024)
374
387
def test_encode_no_offset(self):
375
388
self.assertEncode('\x90\x01', 0, 1)