diff options
-rw-r--r-- | tests/extmod/uctypes_addressof.py | 16 | ||||
-rw-r--r-- | tests/extmod/uctypes_addressof.py.exp | 9 |
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 |