Browse Source

extmod: Add test which demonstrates LITTLE_ENDIAN packing failure

pull/1704/head
Dave Hylands 9 years ago
committed by Paul Sokolovsky
parent
commit
5a4a2b1db3
  1. 5
      tests/extmod/uctypes_sizeof.py
  2. 1
      tests/extmod/uctypes_sizeof.py.exp

5
tests/extmod/uctypes_sizeof.py

@ -6,6 +6,7 @@ desc = {
# 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),
"arr4": (uctypes.ARRAY | 0, 2, {"b": uctypes.UINT8 | 0, "w": uctypes.UINT16 | 1})
}
data = bytearray(b"01234567")
@ -24,3 +25,7 @@ try:
print(uctypes.sizeof(S.arr3[0]))
except TypeError:
print("TypeError")
print(uctypes.sizeof(S.arr4))
assert uctypes.sizeof(S.arr4) == 6

1
tests/extmod/uctypes_sizeof.py.exp

@ -2,3 +2,4 @@
2
4
TypeError
6

Loading…
Cancel
Save