summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-10-30 03:48:16 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-10-30 03:50:37 +0200
commit66d08eb4fe7540f89aaab413f87f70b6eade04cf (patch)
tree6977903eb2a2ed1122cb5aee90ee78acd4463915
parent6d287a6a029df0d4b7a2ab8bdd73be77c0c04317 (diff)
downloadmicropython-66d08eb4fe7540f89aaab413f87f70b6eade04cf.tar.gz
micropython-66d08eb4fe7540f89aaab413f87f70b6eade04cf.zip
moductypes: Add test for accessing UINT8 array.
-rw-r--r--tests/extmod/uctypes_bytearray.py15
-rw-r--r--tests/extmod/uctypes_bytearray.py.exp2
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/extmod/uctypes_bytearray.py b/tests/extmod/uctypes_bytearray.py
new file mode 100644
index 0000000000..9f3d7ca8bd
--- /dev/null
+++ b/tests/extmod/uctypes_bytearray.py
@@ -0,0 +1,15 @@
+import uctypes
+
+desc = {
+ "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
+ "arr2": (uctypes.ARRAY | 2, uctypes.INT8 | 2),
+}
+
+data = bytearray(b"01234567")
+
+S = uctypes.struct(desc, uctypes.addressof(data), uctypes.LITTLE_ENDIAN)
+
+# Arrays of UINT8 are accessed as bytearrays
+print(S.arr)
+# But not INT8, because value range is different
+print(type(S.arr2))
diff --git a/tests/extmod/uctypes_bytearray.py.exp b/tests/extmod/uctypes_bytearray.py.exp
new file mode 100644
index 0000000000..294f8a5fa4
--- /dev/null
+++ b/tests/extmod/uctypes_bytearray.py.exp
@@ -0,0 +1,2 @@
+bytearray(b'01')
+<class 'struct'>