From bdd48e67ee54163f195628ba6de476ca7984d327 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 7 Mar 2017 08:39:47 +0100 Subject: [PATCH] tests/uctypes_array_assign_native_le: Split off intbig part. --- .../extmod/uctypes_array_assign_native_le.py | 10 ----- .../uctypes_array_assign_native_le.py.exp | 2 - .../uctypes_array_assign_native_le_intbig.py | 43 +++++++++++++++++++ ...types_array_assign_native_le_intbig.py.exp | 2 + 4 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 tests/extmod/uctypes_array_assign_native_le_intbig.py create mode 100644 tests/extmod/uctypes_array_assign_native_le_intbig.py.exp diff --git a/tests/extmod/uctypes_array_assign_native_le.py b/tests/extmod/uctypes_array_assign_native_le.py index 474b7e0f2d..f0ecc0dad4 100644 --- a/tests/extmod/uctypes_array_assign_native_le.py +++ b/tests/extmod/uctypes_array_assign_native_le.py @@ -70,16 +70,6 @@ S.arr10[0] = 0x11223344 print(hex(S.arr10[0])) assert hex(S.arr10[0]) == "0x11223344" -# assign int64 -S.arr11[0] = 0x11223344 -print(hex(S.arr11[0])) -assert hex(S.arr11[0]) == "0x11223344" - -# assign uint64 -S.arr12[0] = 0x11223344 -print(hex(S.arr12[0])) -assert hex(S.arr12[0]) == "0x11223344" - # index out of range try: print(S.arr8[2]) diff --git a/tests/extmod/uctypes_array_assign_native_le.py.exp b/tests/extmod/uctypes_array_assign_native_le.py.exp index 4efcdec668..9d67b1c777 100644 --- a/tests/extmod/uctypes_array_assign_native_le.py.exp +++ b/tests/extmod/uctypes_array_assign_native_le.py.exp @@ -6,8 +6,6 @@ True 0x11 0x1122 0x11223344 -0x11223344 -0x11223344 IndexError TypeError TypeError diff --git a/tests/extmod/uctypes_array_assign_native_le_intbig.py b/tests/extmod/uctypes_array_assign_native_le_intbig.py new file mode 100644 index 0000000000..f29a3b66e9 --- /dev/null +++ b/tests/extmod/uctypes_array_assign_native_le_intbig.py @@ -0,0 +1,43 @@ +import sys +try: + import uctypes +except ImportError: + print("SKIP") + sys.exit() + +if sys.byteorder != "little": + print("SKIP") + sys.exit() + +desc = { + # arr is array at offset 0, of UINT8 elements, array size is 2 + "arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2), + # arr2 is array at offset 0, size 2, of structures defined recursively + "arr2": (uctypes.ARRAY | 0, 2, {"b": uctypes.UINT8 | 0}), + "arr3": (uctypes.ARRAY | 2, uctypes.UINT16 | 2), + + # aligned + "arr5": (uctypes.ARRAY | 0, uctypes.UINT32 | 1), + "arr7": (uctypes.ARRAY | 0, 1, {"l": uctypes.UINT32 | 0}), + + "arr8": (uctypes.ARRAY | 0, uctypes.INT8 | 1), + "arr9": (uctypes.ARRAY | 0, uctypes.INT16 | 1), + "arr10": (uctypes.ARRAY | 0, uctypes.INT32 | 1), + "arr11": (uctypes.ARRAY | 0, uctypes.INT64 | 1), + "arr12": (uctypes.ARRAY | 0, uctypes.UINT64| 1), + "arr13": (uctypes.ARRAY | 1, 1, {"l": {}}), +} + +data = bytearray(8) + +S = uctypes.struct(uctypes.addressof(data), desc) + +# assign int64 +S.arr11[0] = 0x11223344 +print(hex(S.arr11[0])) +assert hex(S.arr11[0]) == "0x11223344" + +# assign uint64 +S.arr12[0] = 0x11223344 +print(hex(S.arr12[0])) +assert hex(S.arr12[0]) == "0x11223344" diff --git a/tests/extmod/uctypes_array_assign_native_le_intbig.py.exp b/tests/extmod/uctypes_array_assign_native_le_intbig.py.exp new file mode 100644 index 0000000000..0394e9ae11 --- /dev/null +++ b/tests/extmod/uctypes_array_assign_native_le_intbig.py.exp @@ -0,0 +1,2 @@ +0x11223344 +0x11223344