def test_multiplying(self): multiplier = Multiplier() for x in range(-5, 10): for y in range(-5, 10): self.assertEqual(x * y, multiplier.calc(x, y))
def test_multiplying(self): """Test multiplier functionality""" multiplier = Multiplier() for i in range(-10, 10): for j in range(-10, 10): self.assertEqual(i * j, multiplier.calc(i, j))
def setUp(self): self.adder = Adder() self.subtracter = Subtracter() self.multiplier = Multiplier() self.divider = Divider() self.calculator = Calculator(self.adder, self.subtracter, self.multiplier, self.divider)
def test_module(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(5) calculator.enter_number(2) calculator.multiply() calculator.enter_number(46) calculator.add() calculator.enter_number(8) calculator.divide() calculator.enter_number(1) result = calculator.subtract() self.assertEqual(6, result) # pulled from the unittest file, testing that there is not # a missing operand with self.assertRaises(InsufficientOperands): calculator.add()
def fill_project(top): ''' this is the example from openmdao.main.test.test_project ''' f = open('multiplier.py', 'w') f.write(multiplier_def) f.close() from multiplier import Multiplier comp1 = top.add('comp1', Multiplier()) comp2 = top.add('comp2', Multiplier()) top.driver.workflow.add(['comp1', 'comp2']) top.comp1.mult = 2.0 top.comp2.mult = 4.0 top.connect('comp1.rval_out', 'comp2.rval_in') top.comp1.rval_in = 5.0
def test_division(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(2) calculator.enter_number(10) result = calculator.divide() self.assertEqual(5, result) del calculator
def test_multiplication(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(10) calculator.enter_number(12) result = calculator.multiply() self.assertEqual(120, result) del calculator
def test_subtraction(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(-2) calculator.enter_number(10) result = calculator.add() self.assertEqual(8, result) del calculator
def test_subtraction_error(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(24) calculator.enter_number(12) result = calculator.subtract() self.assertEqual(12, result) del calculator
def setUp(self): """Setup function to add modules to calculator""" self.adder = Adder() self.subtracter = Subtracter() self.multiplier = Multiplier() self.divider = Divider() self.calculator = Calculator(self.adder, self.subtracter, self.multiplier, self.divider)
def test_module(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(5) calculator.enter_number(2) calculator.multiply() calculator.enter_number(46) calculator.add() calculator.enter_number(8) calculator.divide() calculator.enter_number(1) result = calculator.subtract() self.assertEqual(6, result)
def test_module(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(3) calculator.enter_number(4) self.assertEqual(12, calculator.multiply()) calculator.enter_number(2) self.assertEqual(10, calculator.subtract()) calculator.enter_number(10) self.assertEqual(calculator.add(), 20) calculator.enter_number(5) result = calculator.divide() self.assertEqual(4, result)
def test_module(self): calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(5) calculator.enter_number(2) r1 = calculator.multiply() print('multiplication result:', r1) calculator.enter_number(46) r2 = calculator.add() print('addition result:', r2) calculator.enter_number(8) r3 = calculator.divide() print('division result:', r3) calculator.enter_number(1) result = calculator.subtract() print('result after final step of subtraction:', result) self.assertEqual(6, result)
def test_modules(self): """Function to test each of the modules and function calls""" calculator = Calculator(Adder(), Subtracter(), Multiplier(), Divider()) calculator.enter_number(5) calculator.enter_number(2) calculator.multiply() calculator.enter_number(46) calculator.add() calculator.enter_number(8) calculator.divide() calculator.enter_number(1) result = calculator.subtract() self.assertEqual(6, result)
def test_multiplying(self): multiplier = Multiplier() for i in range(-10, 10): for j in range(-10, 10): self.assertEqual(i * j, multiplier.calc(i, j))
def test_summation_check_passed(self): test = Multiplier([1721, 979, 366, 299, 675, 1456]) self.assertTrue(test.summationCheck()) self.assertEqual(test.result, 1721 * 299)
def test_advent_of_code_input(self): with open('day1/input.txt', 'r') as fh: num_list = [int(line) for line in fh] test = Multiplier(num_list) self.assertEqual(test.result, 436404)
def test_summation_check_failed(self): test = Multiplier([1721, 366, 0, 675]) self.assertFalse(test.summationCheck()) self.assertEqual(test.result, -1)