Example #1
0
    def test_subtracting(self):
        """Test subtracter functionality"""
        subtracter = Subtracter()

        for i in range(-10, 10):
            for j in range(-10, 10):
                self.assertEqual(i - j, subtracter.calc(i, j))
Example #2
0
    def test_subtracting(self):

        subtracter = Subtracter()

        for x in range(-5, 10):
            for y in range(-5, 10):
                self.assertEqual(x - y, subtracter.calc(x, y))
Example #3
0
 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)
Example #4
0
    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()
Example #5
0
    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_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 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
Example #10
0
    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)
Example #12
0
    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)
Example #13
0
    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_subtracting(self):
        subtracter = Subtracter()

        for i in range(-10, 10):
            for j in range(-10, 10):
                self.assertEqual(i - j, subtracter.calc(i, j))