diff --git a/test13.py b/test13.py index 5c49a40..b45b271 100644 --- a/test13.py +++ b/test13.py @@ -1,4 +1,4 @@ -from test12 import BoundedInt +from BoundedInt import BoundedInt class BoundedIntTester: def __init__(self): @@ -11,6 +11,9 @@ class BoundedIntTester: print(f"❌ Test 1 failed, int(bi1) = {int(bi1)}, expected 0xdeadbeef") def test2(self): + """ + Test that addition works for two BoundedInts, and throws an error if the bounds are exceeded. + """ bi2 = BoundedInt(1, min = 0, max = 1) bi3 = BoundedInt(1, min = 0, max = 1) try: @@ -20,6 +23,9 @@ class BoundedIntTester: print(f"✅ Test 2 passed!") def test3(self): + """ + 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) try: @@ -28,7 +34,33 @@ class BoundedIntTester: except ValueError as err: print(f"✅ Test 3 passed!") + def test4(self): + """ + Test that addition works for a BoundedInt and a regular int, and throws an error if the bounds are exceeded. + """ + bi7 = BoundedInt(1, min = 0, max = 1) + bi8 = 2 + try: + bi9 = bi7 + bi8 + print(f"❌ Test 4 failed!") + except ValueError as err: + print(f"✅ Test 4 passed!") + + def test5(self): + """ + Test that subtraction works for a BoundedInt and a regular int, and throws an error if the bounds are exceeded. + """ + bi10 = BoundedInt(1, min = 0, max = 1) + bi11 = 2 + try: + bi12 = bi10 - 11 + print(f"❌ Test 5 failed!") + except ValueError as err: + print(f"✅ Test 5 passed!") + tester = BoundedIntTester() tester.test1() tester.test2() -tester.test3() \ No newline at end of file +tester.test3() +tester.test4() +tester.test5() \ No newline at end of file