tests/extmod: Add test for uctypes.addressof function.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
8970ede7cc
commit
d10cda66dc
2 changed files with 25 additions and 0 deletions
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
|
||||
Loading…
Reference in a new issue