Changed tests to handle the case where the BoundedInt constructor does bounds checks upon initialization.

This commit is contained in:
cheezedoodle2
2023-04-03 10:28:10 -07:00
parent 22cda0e692
commit 71b9966e36
+3 -2
View File
@@ -3,8 +3,9 @@ from BoundedInt import BoundedInt
class BoundedIntTester:
def __init__(self):
pass
def test1(self):
bi1 = BoundedInt(0xdeadbeef, max = 0, min = 10)
bi1 = BoundedInt(0xdeadbeef, min = (0xdeadbeef-1), max = (0xdeadbeef+1))
if int(bi1) == 0xdeadbeef:
print(f"✅ Test 1 passed!")
else:
@@ -27,7 +28,7 @@ class BoundedIntTester:
Test that addition works for two BoundedInts, and throws an error if the bounds are exceeded.
"""
bi4 = BoundedInt(1, min = 0, max = 1)
bi5 = BoundedInt(2, min = 0, max = 1)
bi5 = BoundedInt(2, min = 0, max = 2)
try:
bi6 = bi4 - bi5 # 1 - 2 = (-1), which is less than min = 0
print(f"❌ Test 3 failed!")