示例#1
0
    def test_subtraction1(self):
        '''A subtraction operation should be valid

        2-1 = 1
        '''
        # a = 2, b = 1, operator = subtraction
        self.fake_numbers = [2, 1, 1]

        eq = Equation(10, self.fakeRandom)

        self.assertTrue(eq.a is 2 and  eq.b is 1 and eq.operator is 1)
        self.assertTrue(eq.validate(1)) 
示例#2
0
    def test_addition(self):
        '''An addition operation should be valid

        1 + 2 = 3
        '''
        # a = 1, b = 2, operator = addition
        self.fake_numbers = [1, 2, 0] 

        eq = Equation(10, self.fakeRandom)

        self.assertTrue(eq.a is 1 and  eq.b is 2 and eq.operator is 0)
        self.assertTrue(eq.validate(3)) 
示例#3
0
    def test_subtraction2(self):
        '''Subtraction should always be positive

        When the first random number generated is smaller than the second
        during a subtraction, the results should remain positive by swapping
        the two operands.
        ''' 
        # a = 1, b = 2, operator = subtraction
        self.fake_numbers = [2, 1, 1] 

        eq = Equation(10, self.fakeRandom)

        self.assertTrue(eq.a is 2 and  eq.b is 1 and eq.operator is 1)
        self.assertTrue(eq.validate(1))