forked from MUICT-SERU/python-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_calculator.py
More file actions
39 lines (28 loc) · 1.05 KB
/
test_calculator.py
File metadata and controls
39 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import unittest
from calculator import Calculator
class TestCalculator(unittest.TestCase):
def setUp(self):
self.calc = Calculator()
def test_add(self):
self.assertEqual(self.calc.add(1, 2), 3)
def test_add2(self):
self.assertEqual(self.calc.add(3, 2), 5)
# Add the following test methods to the TestCalculator class:
def test_substract(self):
self.assertEqual(self.calc.subtract(2,1), 1)
def test_substract2(self):
self.assertEqual(self.calc.subtract(5,3), 2)
def test_multiply(self):
self.assertEqual(self.calc.multiply(2,5), 10)
def test_multiply2(self):
self.assertEqual(self.calc.multiply(5,5), 25)
def test_divide(self):
self.assertEqual(self.calc.divide(10,2), 5)
def test_divide2(self):
self.assertEqual(self.calc.divide(12,2), 6)
def test_modulo(self):
self.assertEqual(self.calc.modulo(5,7), 5)
def test_modulo2(self):
self.assertEqual(self.calc.modulo(10,3), 1)
if __name__ == '__main__':
unittest.main()