aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/basics/struct1.py6
-rw-r--r--tests/basics/struct2.py4
2 files changed, 10 insertions, 0 deletions
diff --git a/tests/basics/struct1.py b/tests/basics/struct1.py
index 2cf75137b..db34342a1 100644
--- a/tests/basics/struct1.py
+++ b/tests/basics/struct1.py
@@ -69,6 +69,12 @@ print(buf)
struct.pack_into('<bbb', buf, -6, 0x44, 0x45, 0x46)
print(buf)
+# check that we get an error if the buffer is too small
+try:
+ struct.pack_into('I', bytearray(1), 0, 0)
+except:
+ print('struct.error')
+
try:
struct.pack_into('<bbb', buf, 7, 0x41, 0x42, 0x43)
except:
diff --git a/tests/basics/struct2.py b/tests/basics/struct2.py
index e3336c0c7..ceb067776 100644
--- a/tests/basics/struct2.py
+++ b/tests/basics/struct2.py
@@ -30,6 +30,10 @@ try:
struct.unpack('2H', b'\x00\x00')
except:
print('Exception')
+try:
+ struct.pack_into('2I', bytearray(4), 0, 0)
+except:
+ print('Exception')
# check that unknown types raise an exception
try: