tests/extmod: Add test for uctypes.addressof function.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
16
tests/extmod/uctypes_addressof.py
Normal file
16
tests/extmod/uctypes_addressof.py
Normal 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)
|
||||||
9
tests/extmod/uctypes_addressof.py.exp
Normal file
9
tests/extmod/uctypes_addressof.py.exp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
1
|
||||||
|
2
|
||||||
|
4
|
||||||
|
8
|
||||||
|
16
|
||||||
|
32
|
||||||
|
64
|
||||||
|
128
|
||||||
|
True
|
||||||
Reference in New Issue
Block a user