summaryrefslogtreecommitdiff
path: root/tests/basics/int_bytes.py
diff options
context:
space:
mode:
authorMatt Wozniski <godlygeek+git@gmail.com>2019-05-09 03:19:29 -0400
committerMatt Wozniski <godlygeek+git@gmail.com>2019-05-09 03:22:24 -0400
commite041df73bb7bf424bcf571f25e3459359c4f36ed (patch)
treef70962c41b51ee7bee03af3e37960ec7ab18f63e /tests/basics/int_bytes.py
parent9ce042ad07cabbba27f4db90f9c95d0b057b9f51 (diff)
Add tests for overflows converting ints to bytes
Diffstat (limited to 'tests/basics/int_bytes.py')
-rw-r--r--tests/basics/int_bytes.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/basics/int_bytes.py b/tests/basics/int_bytes.py
index 059c16d3f..8c0c9a82f 100644
--- a/tests/basics/int_bytes.py
+++ b/tests/basics/int_bytes.py
@@ -17,3 +17,15 @@ try:
(1).to_bytes(-1, "little")
except ValueError:
print("ValueError")
+
+# too small buffer should raise an error
+try:
+ (256).to_bytes(1, "little")
+except OverflowError:
+ print("OverflowError")
+
+# negative numbers should raise an error
+try:
+ (-256).to_bytes(2, "little")
+except OverflowError:
+ print("OverflowError")