def decode(low_byte, hi_byte): """Recombine two bytes and return the corresponding integer.""" try: lo = int(low_byte, 16) hi = int(hi_byte, 16) click.echo(alpc.decode(lo, hi)) except ValueError as e: click.secho('Decoding error: {0}'.format(e), fg='red') sys.exit(1)
def test_decode(self): assert alpc.decode(0x00, 0x40) == 0 assert alpc.decode(0x00, 0x00) == -8192 assert alpc.decode(0x7F, 0x7F) == 8191 assert alpc.decode(0x00, 0x50) == 2048 assert alpc.decode(0x05, 0x0A) == -6907 assert alpc.decode(0x00, 0x55) == 2688