summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/extmod/uctypes_sizeof.py41
-rw-r--r--tests/extmod/uctypes_sizeof.py.exp8
-rw-r--r--tests/extmod/uctypes_sizeof_od.py6
-rw-r--r--tests/extmod/uctypes_sizeof_od.py.exp1
4 files changed, 48 insertions, 8 deletions
diff --git a/tests/extmod/uctypes_sizeof.py b/tests/extmod/uctypes_sizeof.py
index 6e52232e3..d295cc85b 100644
--- a/tests/extmod/uctypes_sizeof.py
+++ b/tests/extmod/uctypes_sizeof.py
@@ -43,8 +43,47 @@ assert uctypes.sizeof(S.arr4) == 6
print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1
-# invalid descriptor
+# invalid descriptors
try:
print(uctypes.sizeof([]))
except TypeError:
print("TypeError")
+
+try:
+ print(uctypes.sizeof(()))
+except TypeError:
+ print("TypeError")
+
+try:
+ print(uctypes.sizeof(("garbage",)))
+except TypeError:
+ print("TypeError")
+
+try:
+ # PTR * 3 is intended to be an invalid agg_type (STRUCT, PTR, ARRAY are valid ones).
+ print(uctypes.sizeof((uctypes.PTR * 3,)))
+except TypeError:
+ print("TypeError")
+
+try:
+ print(uctypes.sizeof((0, {}, "garbage")))
+except TypeError:
+ print("TypeError")
+
+try:
+ print(uctypes.sizeof((uctypes.PTR | 0,)))
+except TypeError:
+ print("TypeError")
+
+try:
+ print(uctypes.sizeof((uctypes.ARRAY | 0,)))
+except TypeError:
+ print("TypeError")
+
+try:
+ print(uctypes.sizeof((uctypes.ARRAY | 0, 1, {}, "garbage")))
+except TypeError:
+ print("TypeError")
+
+# empty descriptor
+print(uctypes.sizeof({}))
diff --git a/tests/extmod/uctypes_sizeof.py.exp b/tests/extmod/uctypes_sizeof.py.exp
index b35b11aa0..edcc05a44 100644
--- a/tests/extmod/uctypes_sizeof.py.exp
+++ b/tests/extmod/uctypes_sizeof.py.exp
@@ -5,3 +5,11 @@ TypeError
6
1
TypeError
+TypeError
+TypeError
+TypeError
+TypeError
+TypeError
+TypeError
+TypeError
+0
diff --git a/tests/extmod/uctypes_sizeof_od.py b/tests/extmod/uctypes_sizeof_od.py
index 375f05f5e..8aff36363 100644
--- a/tests/extmod/uctypes_sizeof_od.py
+++ b/tests/extmod/uctypes_sizeof_od.py
@@ -45,9 +45,3 @@ assert uctypes.sizeof(S.arr4) == 6
print(uctypes.sizeof(S.sub))
assert uctypes.sizeof(S.sub) == 1
-
-# invalid descriptor
-try:
- print(uctypes.sizeof([]))
-except TypeError:
- print("TypeError")
diff --git a/tests/extmod/uctypes_sizeof_od.py.exp b/tests/extmod/uctypes_sizeof_od.py.exp
index b35b11aa0..fb74def60 100644
--- a/tests/extmod/uctypes_sizeof_od.py.exp
+++ b/tests/extmod/uctypes_sizeof_od.py.exp
@@ -4,4 +4,3 @@
TypeError
6
1
-TypeError