tests/extmod: Add test for uctypes.addressof function.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2024-12-18 10:15:01 +11:00
parent 8970ede7cc
commit d10cda66dc
2 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,16 @@
# Test uctypes.addressof().
try:
from sys import maxsize
import uctypes
except ImportError:
print("SKIP")
raise SystemExit
# Test small addresses.
for i in range(8):
print(uctypes.addressof(uctypes.bytearray_at(1 << i, 8)))
# Test address that is bigger than the greatest small-int but still within the address range.
large_addr = maxsize + 1
print(uctypes.addressof(uctypes.bytearray_at(large_addr, 8)) == large_addr)

View file

@ -0,0 +1,9 @@
1
2
4
8
16
32
64
128
True