def test_method_parses_delim_within_brackets(self): result = calculator.Add('//[-]\n1-2-3') self.assertEqual(result, 6)
def test_multiple_delims_in_same_input_are_supported(self): result = calculator.Add("1\n2,3") self.assertEqual(result, 6)
def test_method_parses_delim_specified_explicitly(self): result = calculator.Add('//;\n1;2') self.assertEqual(result, 3)
def test_numbers_greater_than_1000_are_ignored(self): result = calculator.Add("2,1001") self.assertEqual(result, 2)
def test_newlines_delim_is_supported(self): result = calculator.Add("2\n3\n\n4") self.assertEqual(result, 9)
def test_method_takes_0_numbers(self): result = calculator.Add("") self.assertEqual(result, 0)
def testAddTests(self): self.assertEqual(calculator.Add(3, 6), 9)
def test_emptyString(self): self.assertEqual(calculator.Add(""), 0)
def test_lengthOneString(self): self.assertEqual(calculator.Add("3"), 3)
def test_customDelimeter(self): self.assertEqual(calculator.Add("//;\n5;2;3;2;1"), 13)
def test_negativeNumbers(self): calculator.Add("//;\n5;-2;0")
def test_stringWithNewLines(self): self.assertEqual(calculator.Add("5\n2,3,2\n1"), 13)
def test_lengthFiveString(self): self.assertEqual(calculator.Add("1,1,3,4,6"), 15)
def test_lengthTwoString(self): self.assertEqual(calculator.Add("1,4"), 5)
def test_method_parses_multiple_delims_within_brackets(self): result = calculator.Add('//[-][%]\n1-2%3') self.assertEqual(result, 6)
import calculator x = float(input("Enter first number: ")) y = float(input("Enter second number: ")) while True: print("Select one of the operations \n1.Addition \n2.Subtract \n3.Multiplication \n4.Division \n5.Mod \n6.Exit") select = int(input(" ")) if(select == 1): print(calculator.Add(x, y)) elif(select == 2): print(calculator.Sub(x, y)) elif(select == 3): print(calculator.Mul(x, y)) elif(select == 4): print(calculator.Div(x, y)) elif(select == 5): print(calculator.Mod(x, y)) elif(select == 6): break else: print("Invalid input")
def test_method_throws_exception_with_negative_numbers(self): with self.assertRaises(NegativeNumberException): calculator.Add('1,-1,2')
def test_method_takes_1_number(self): result = calculator.Add("1") self.assertEqual(result, 1)
def add_Func(self): res = calculator.Add(20, 8) self.assertEqual(28, res)
def test_sum(self): self.assertEqual(5, calculator.Add(3,2)) self.assertEqual(5, calculator.Add(3.5,1.5))