8000 tests/extmod: Add test for uctypes.addressof function. · 32bitmicro/micropython@d10cda6 · GitHub
[go: up one dir, main page]

Skip to content

Commit d10cda6

Browse files
committed
tests/extmod: Add test for uctypes.addressof function.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 8970ede commit d10cda6

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/extmod/uctypes_addressof.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Test uctypes.addressof().
2+
3+
try:
4+
from sys import maxsize
5+
import uctypes
6+
except ImportError:
7+
print("SKIP")
8+
raise SystemExit
9+
10+
# Test small addresses.
11+
for i in range(8):
12+
print(uctypes.addressof(uctypes.bytearray_at(1 << i, 8)))
13+
14+
# Test address that is bigger than the greatest small-int but still within the address range.
15+
large_addr = maxsize + 1
16+
print(uctypes.addressof(uctypes.bytearray_at(large_addr, 8)) == large_addr)

tests/extmod/uctypes_addressof.py.exp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
1
2+
2
3+
4
4+
8
5+
16
6+
32
7+
64
8+
128
9+
True

0 commit comments

Comments
 (0)
0