Skip to content

Commit bdd48e6

Browse files
committed
tests/uctypes_array_assign_native_le: Split off intbig part.
1 parent e73a0b9 commit bdd48e6

4 files changed

Lines changed: 45 additions & 12 deletions

tests/extmod/uctypes_array_assign_native_le.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,6 @@
7070
print(hex(S.arr10[0]))
7171
assert hex(S.arr10[0]) == "0x11223344"
7272

73-
# assign int64
74-
S.arr11[0] = 0x11223344
75-
print(hex(S.arr11[0]))
76-
assert hex(S.arr11[0]) == "0x11223344"
77-
78-
# assign uint64
79-
S.arr12[0] = 0x11223344
80-
print(hex(S.arr12[0]))
81-
assert hex(S.arr12[0]) == "0x11223344"
82-
8373
# index out of range
8474
try:
8575
print(S.arr8[2])

tests/extmod/uctypes_array_assign_native_le.py.exp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ True
66
0x11
77
0x1122
88
0x11223344
9-
0x11223344
10-
0x11223344
119
IndexError
1210
TypeError
1311
TypeError
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import sys
2+
try:
3+
import uctypes
4+
except ImportError:
5+
print("SKIP")
6+
sys.exit()
7+
8+
if sys.byteorder != "little":
9+
print("SKIP")
10+
sys.exit()
11+
12+
desc = {
13+
# arr is array at offset 0, of UINT8 elements, array size is 2
14+
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
15+
# arr2 is array at offset 0, size 2, of structures defined recursively
16+
"arr2": (uctypes.ARRAY | 0, 2, {"b": uctypes.UINT8 | 0}),
17+
"arr3": (uctypes.ARRAY | 2, uctypes.UINT16 | 2),
18+
19+
# aligned
20+
"arr5": (uctypes.ARRAY | 0, uctypes.UINT32 | 1),
21+
"arr7": (uctypes.ARRAY | 0, 1, {"l": uctypes.UINT32 | 0}),
22+
23+
"arr8": (uctypes.ARRAY | 0, uctypes.INT8 | 1),
24+
"arr9": (uctypes.ARRAY | 0, uctypes.INT16 | 1),
25+
"arr10": (uctypes.ARRAY | 0, uctypes.INT32 | 1),
26+
"arr11": (uctypes.ARRAY | 0, uctypes.INT64 | 1),
27+
"arr12": (uctypes.ARRAY | 0, uctypes.UINT64| 1),
28+
"arr13": (uctypes.ARRAY | 1, 1, {"l": {}}),
29+
}
30+
31+
data = bytearray(8)
32+
33+
S = uctypes.struct(uctypes.addressof(data), desc)
34+
35+
# assign int64
36+
S.arr11[0] = 0x11223344
37+
print(hex(S.arr11[0]))
38+
assert hex(S.arr11[0]) == "0x11223344"
39+
40+
# assign uint64
41+
S.arr12[0] = 0x11223344
42+
print(hex(S.arr12[0]))
43+
assert hex(S.arr12[0]) == "0x11223344"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0x11223344
2+
0x11223344

0 commit comments

Comments
 (0)