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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy