def test_big_endian(self): self.assertEqual(_binary.i16be(b'\x00\x00\xff\xff'), 0) self.assertEqual(_binary.i32be(b'\x00\x00\xff\xff'), 65535) self.assertEqual(_binary.o16be(65535), b'\xff\xff') self.assertEqual(_binary.o32be(65535), b'\x00\x00\xff\xff')
def puti16(fp, values): # write network order (big-endian) 16-bit sequence for v in values: if v < 0: v += 65536 fp.write(_binary.o16be(v))
def test_big_endian(self): self.assertEqual(_binary.i16be(b"\x00\x00\xff\xff"), 0) self.assertEqual(_binary.i32be(b"\x00\x00\xff\xff"), 65535) self.assertEqual(_binary.o16be(65535), b"\xff\xff") self.assertEqual(_binary.o32be(65535), b"\x00\x00\xff\xff")
def puti16(fp, values): # write network order (big-endian) 16-bit sequence for v in values: if v < 0: v = v + 65536 fp.write(_binary.o16be(v))
def test_big_endian(): assert _binary.i16be(b"\x00\x00\xff\xff") == 0 assert _binary.i32be(b"\x00\x00\xff\xff") == 65535 assert _binary.o16be(65535) == b"\xff\xff" assert _binary.o32be(65535) == b"\x00\x00\xff\xff"