def testUnpackingBytes(self): s = CBS(80) t = s.unpack('bytes:1') self.assertEqual(t[0], b'\x00') a, b, c = s.unpack('bytes:1, bytes, bytes:2') self.assertEqual(a, b'\x00') self.assertEqual(b, b'\x00' * 7) self.assertEqual(c, b'\x00' * 2)
def testUnpackingBytes(self): s = CBS(80) t = s.unpack("bytes:1") self.assertEqual(t[0], b"\x00") a, b, c = s.unpack("bytes:1, bytes, bytes:2") self.assertEqual(a, b"\x00") self.assertEqual(b, b"\x00" * 7) self.assertEqual(c, b"\x00" * 2)
def testReading(self): s = CBS(uie=333) a = s.read('uie') self.assertEqual(a, 333) s = CBS('uie=12, sie=-9, sie=9, uie=1000000') u = s.unpack('uie, 2*sie, uie') self.assertEqual(u, [12, -9, 9, 1000000])
def testUnpackingBytesWithKeywords(self): s = CBS('0x55' * 10) t = s.unpack('pad:a, bytes:b, bytes, pad:a', a=4, b=6) self.assertEqual(t, [b'\x55' * 6, b'\x55' * 3])
def testUnpackingBytesWithKeywords(self): s = CBS("0x55" * 10) t = s.unpack("pad:a, bytes:b, bytes, pad:a", a=4, b=6) self.assertEqual(t, [b"\x55" * 6, b"\x55" * 3])