def test_modulus(self): expect = 7 actual = calc.calc_iteration(calc.to_postfix('29%11'), None) self.assertEqual(expect, actual)
def test_modulo_by_zero(self): with self.assertRaises(calc.CalcError): calc.calc_iteration(calc.to_postfix('3 % 0'), None)
def test_division(self): expect = 6 actual = calc.calc_iteration(calc.to_postfix('24/4'), None) self.assertEqual(expect, actual)
def test_division_by_zero(self): with self.assertRaises(calc.CalcError): calc.calc_iteration(calc.to_postfix('3 / 0'), None)
def test_subtraction(self): expect = 3 actual = calc.calc_iteration(calc.to_postfix('25-22'), None) self.assertEqual(expect, actual)
def test_multiplication(self): expect = 5 actual = calc.calc_iteration(calc.to_postfix('2.5*2'), None) self.assertEqual(expect, actual)
def test_comparison(self): expect = True actual = calc.calc_iteration(calc.to_postfix('2+3*5>=10+12/2'), None) self.assertEqual(expect, actual)
def test_addition(self): expect = 8.05 actual = calc.calc_iteration(calc.to_postfix('3.5+.5+2.75+1.3'), None) self.assertEqual(expect, actual)
def test_calc_iteration(self): expect = (1, 8) actual = (calc.calc_iteration(['sin', 'pi', '2', '/', ')'], None), calc.calc_iteration(['pow', '2', ',', '3', ')'], None)) self.assertEqual(expect, actual)
def test_abs(self): expect = 6 actual = calc.calc_iteration(calc.to_postfix('abs(-6)'), None) self.assertEqual(expect, actual)
def test_round(self): expect = 8 actual = calc.calc_iteration(calc.to_postfix('round(7.51)'), None) self.assertEqual(expect, actual)
def test_power(self): expect = 8 actual = calc.calc_iteration(calc.to_postfix('2^3'), None) self.assertEqual(expect, actual)
def test_floor_division(self): expect = 4 actual = calc.calc_iteration(calc.to_postfix('9//2'), None) self.assertEqual(expect, actual)