diff options
| author | Dave Hylands <dhylands@gmail.com> | 2016-01-03 10:38:36 -0800 |
|---|---|---|
| committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-01-10 23:31:26 +0200 |
| commit | 66d0c1052a4623ef91afe4c7b883b7f37a68fa2b (patch) | |
| tree | 1a0751eedf4e3ed60e78fd6803b842dccd5d9427 /tests | |
| parent | 8175877ad64a631e9ce0f9a5b66782d58ea5f48d (diff) | |
extmod: Fix uctypes size calculation for bitfields
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/extmod/uctypes_sizeof.py | 9 | ||||
| -rw-r--r-- | tests/extmod/uctypes_sizeof.py.exp | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/tests/extmod/uctypes_sizeof.py b/tests/extmod/uctypes_sizeof.py index 93de2abb0..fcfd8ecd7 100644 --- a/tests/extmod/uctypes_sizeof.py +++ b/tests/extmod/uctypes_sizeof.py @@ -6,7 +6,11 @@ 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}) + "arr4": (uctypes.ARRAY | 0, 2, {"b": uctypes.UINT8 | 0, "w": uctypes.UINT16 | 1}), + "sub": (0, { + 'b1': uctypes.BFUINT8 | 0 | 4 << uctypes.BF_POS | 4 << uctypes.BF_LEN, + 'b2': uctypes.BFUINT8 | 0 | 0 << uctypes.BF_POS | 4 << uctypes.BF_LEN, + }), } data = bytearray(b"01234567") @@ -29,3 +33,6 @@ except TypeError: print(uctypes.sizeof(S.arr4)) assert uctypes.sizeof(S.arr4) == 6 +print(uctypes.sizeof(S.sub)) +assert uctypes.sizeof(S.sub) == 1 + diff --git a/tests/extmod/uctypes_sizeof.py.exp b/tests/extmod/uctypes_sizeof.py.exp index b0e3a0ac6..fb74def60 100644 --- a/tests/extmod/uctypes_sizeof.py.exp +++ b/tests/extmod/uctypes_sizeof.py.exp @@ -3,3 +3,4 @@ 4 TypeError 6 +1 |
