Beispiel #1
0
class TestCalculator(unittest.TestCase):

    def setUp(self):
        self.cal = Calculator(8,4)


    def tearDown(self):
        pass

    def test_add(self):
        result = self.cal.add()
        self.assertEqual(result,12)

    def test_sub(self):
        result = self.cal.sub()
        self.assertEqual(result,4)


    def test_mul(self):
        result = self.cal.mul()
        self.assertEqual(result,32)

    def test_div(self):
        result = self.cal.div()
        self.assertEqual(result,1)
Beispiel #2
0
class CountTest(unittest.TestCase):
    """docstring for CountTest"""

    # 初始化计算器
    def setUp(self):
        self.cal = Calculator(8, 4)

    def tearDown(self):
        pass

    def test_add(self):
        result = self.cal.add()
        self.assertEqual(result, 12)

    def test_sub(self):
        result = self.cal.sub()
        self.assertEqual(result, 4)

    def test_mul(self):
        result = self.cal.mul()
        self.assertEqual(result, 32)

    def test_div(self):
        result = self.cal.div()
        self.assertEqual(result, 2)
Beispiel #3
0
 def test_div(self):
     c = Calculator(8, 3)
     result = c.div()
     self.assertNotEqual(result, 999)