def test_uints_string(self): s = Serializer.uints(3, string=True) a = ((0, 255, "foo"), (256, (1<<64)-1, "")) b = ("\x00\x01\xff\x01\x03foo", ("\x02\x01\x00\x08\xff\xff\xff\xff\xff\xff\xff\xff\x00")) c = ((0, 255, "foo"), (256, (1<<64)-1, "")) for x, y, z in zip(a, b, c): self.assertEqual(s.encode(x), y) self.assertEqual(s.decode(y), z)
def test_uints(self): s = Serializer.uints(2) a = ((0, 255), (256, (1<<64)-1)) b = ("\x00\x01\xff", ("\x02\x01\x00\x08\xff\xff\xff\xff\xff\xff\xff\xff")) c = ((0, 255), (256, (1<<64)-1)) for x, y, z in zip(a, b, c): self.assertEqual(s.encode(x), y) self.assertEqual(s.decode(y), z)
def test_uints_string(self): s = Serializer.uints(3, string=True) a = ((0, 255, "foo"), (256, (1 << 64) - 1, "")) b = (b"\x00\x01\xff\x01\x03foo", b"\x02\x01\x00\x08\xff\xff\xff\xff\xff\xff\xff\xff\x00") c = ((0, 255, "foo"), (256, (1 << 64) - 1, "")) for x, y, z in zip(a, b, c): self.assertEqual(s.encode(x), y) self.assertEqual(s.decode(y), z)
def test_uints(self): s = Serializer.uints(2) a = ((0, 255), (256, (1 << 64) - 1)) b = (b"\x00\x01\xff", b"\x02\x01\x00\x08\xff\xff\xff\xff\xff\xff\xff\xff") c = ((0, 255), (256, (1 << 64) - 1)) for x, y, z in zip(a, b, c): self.assertEqual(s.encode(x), y) self.assertEqual(s.decode(y), z)