summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-12-18 10:15:01 +1100
committerDamien George <damien@micropython.org>2024-12-18 11:01:23 +1100
commitd10cda66dcff1b760ebc550c7f9352220fe4163f (patch)
treedd82ca746d92c18924c5a0147a448eada35ea71d
parent8970ede7cccee57032b547b8a97539b64e61102a (diff)
downloadmicropython-d10cda66dcff1b760ebc550c7f9352220fe4163f.tar.gz
micropython-d10cda66dcff1b760ebc550c7f9352220fe4163f.zip
tests/extmod: Add test for uctypes.addressof function.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--tests/extmod/uctypes_addressof.py16
-rw-r--r--tests/extmod/uctypes_addressof.py.exp9
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/extmod/uctypes_addressof.py b/tests/extmod/uctypes_addressof.py
new file mode 100644
index 0000000000..c83089d0f7
--- /dev/null
+++ b/tests/extmod/uctypes_addressof.py
@@ -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)
diff --git a/tests/extmod/uctypes_addressof.py.exp b/tests/extmod/uctypes_addressof.py.exp
new file mode 100644
index 0000000000..5b48569d01
--- /dev/null
+++ b/tests/extmod/uctypes_addressof.py.exp
@@ -0,0 +1,9 @@
+1
+2
+4
+8
+16
+32
+64
+128
+True