Beispiel #1
0
 def test_bad_lenghts(self):
     with self.assertRaises(RDBValueError):
         ret = unpack_lzf(BytesIO(b'\x00'), 1, 1)
     with self.assertRaises(RDBValueError):
         ret = unpack_lzf(BytesIO(b'\x00'), 0, 1)
     with self.assertRaises(ValueError):
         unpack_lzf(BytesIO(b'\x01'), 1, 1)
Beispiel #2
0
    def test_simple(self):
        data = BytesIO(b'\x04ABCDE')

        ret = unpack_lzf(data, 6, 5)
        self.assertEqual(b'ABCDE', ret)
Beispiel #3
0
 def test_longer_backref(self):
     data = (b'\x01AB'
             b'\xE0\x01\x00')    # backref: len 7+1+2; back 2-0-1
     ret = unpack_lzf(BytesIO(data), 6, 12)
     self.assertEqual(b'ABBBBBBBBBBB', ret)
Beispiel #4
0
 def test_simple_backref(self):
     data = (b'\x01AB'    # simple
             b'\x60\x01') # backref: len 3+2; back 2-1-1
     ret = unpack_lzf(BytesIO(data), 5, 7)
     self.assertEqual(b'ABABABA', ret)
Beispiel #5
0
 def test_empty(self):
     data = BytesIO(b'\x00')
     ret = unpack_lzf(data, 0, 0)
     self.assertEqual(b'', ret)