micropython/tests/basics/int_bytes_intbig.py
Damien George 810133d97d tests/basics: Add tests for int.from_bytes when src has trailing zeros.
The trailing zeros should be truncated from the converted value.
2017-04-25 12:07:02 +10:00

13 lines
321 B
Python

print((2**64).to_bytes(9, "little"))
b = bytes(range(20))
il = int.from_bytes(b, "little")
ib = int.from_bytes(b, "big")
print(il)
print(ib)
print(il.to_bytes(20, "little"))
# check that extra zero bytes don't change the internal int value
print(int.from_bytes(b + bytes(10), "little") == int.from_bytes(b, "little"))