Skip to content

Commit

Permalink
Update test_school_algorithms.py
Browse files Browse the repository at this point in the history
Part of the Add more tests in test_school_algorithms.py #4 issue
  • Loading branch information
Sammygarch committed Jan 9, 2022
1 parent 505fe91 commit 57d273e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test_school_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def test_if_not_int_or_float_raise(self):
def test_if_not_int_or_float_raise_with_int(self):
try:
_if_not_int_or_float_raise(5)
_if_not_int_or_float_raise(-4)
_if_not_int_or_float_raise(5, 6)
_if_not_int_or_float_raise(5, 6, -4)
_if_not_int_or_float_raise(5, 5, 4, 3)

except ValueError:
Expand All @@ -38,6 +41,11 @@ def test_if_not_int_or_float_raise_with_int(self):
def test_if_not_int_or_float_raise_with_float(self):
try:
_if_not_int_or_float_raise(5.0)
_if_not_int_or_float_raise(4.5)
_if_not_int_or_float_raise(-5.0)
_if_not_int_or_float_raise(5.7, -6.0)
_if_not_int_or_float_raise(5.0, 6.3, -5.9)
_if_not_int_or_float_raise(-5.0, -6.3, -5.9, 7.3)
_if_not_int_or_float_raise(5.0, 3.5, 7.1)

except ValueError:
Expand All @@ -46,20 +54,26 @@ def test_if_not_int_or_float_raise_with_float(self):
def test_if_not_int_or_float_raise_with_float_and_int(self):
try:
_if_not_int_or_float_raise(4, 5.0)
_if_not_int_or_float_raise(4, 7.3, 5.0)
_if_not_int_or_float_raise(4.5, 5.0, -6)
_if_not_int_or_float_raise(4.0, 5)
_if_not_int_or_float_raise(5.0, 6, -5.9)

except ValueError:
assert False, f"'_if_not_int_or_float_raise' raised an exception with a float"

class TestPhysicsAlgos(unittest.TestCase):
def test_power_calc(self):
self.assertEqual(power_calc(4, 2), 2.0)
self.assertEqual(power_calc(7, -4), -1.75)

def test_energy_calc(self):
self.assertEqual(energy_calc(4, 2), 8)
self.assertEqual(energy_calc(4, -2), -8)

def test_time_calc(self):
self.assertEqual(time_calc(2, 4), 2.0)
self.assertEqual(time_calc(2, -4), -2.0)

class TestMathsAlgos(unittest.TestCase):
def test_pythag_hypot(self):
Expand Down

0 comments on commit 57d273e

Please sign in to comment.