-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathmathmanagertest.py
More file actions
77 lines (59 loc) · 1.93 KB
/
mathmanagertest.py
File metadata and controls
77 lines (59 loc) · 1.93 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import unittest
from mathmanager import mathmanager
class mathmanagertest(unittest.TestCase):
def testAdd(self):
math = mathmanager()
self.assertEqual(math.add(0, 3), 3)
def testSubtract(self):
math = mathmanager()
self.assertEqual(math.subtract(0, 3), -3)
def testMultiply(self):
math = mathmanager()
self.assertEqual(math.multiply(0, 3), 0)
def testInterest(self):
math = mathmanager()
self.assertEqual(round(math.interest(1000, 1)), 3)
#Interest rate
#positive amount, term = 2
def testInterest1(self):
math = mathmanager()
self.assertEqual(math.interest(1000, 2), 3)
#positive amount, term = 3 (invalid)
def testInterest2(self):
math = mathmanager()
self.assertEqual(math.interest(1000, 3), -2)
#negative amount, term = 1
def testInterest3(self):
math = mathmanager()
self.assertEqual(math.interest(-1000, 1), -1)
#add: positive amount, term = 1, 3, 0, -1
# negative amount, term = 2, -1, 0, 3
# zero amount, term = 1, 2, 3, 0, -1
#Tax calculator
#income in first bracket
def testTax(self):
math = mathmanager()
self.assertEqual(math.tax(10000), 0)
#income in second bracket
def testTax1(self):
math = mathmanager()
self.assertEqual(math.tax(15000), 486)
#income in third bracket
def testTax2(self):
math = mathmanager()
self.assertEqual(math.tax(52000), 8232)
#add income in all brackets, negative income, income equals each threashold
#Degree classification calculator
#combination of grades that get a 2:1
def testDegree(self):
math = mathmanager()
self.assertEqual(math.degree(40, 70, 70, 55, 60), "2:1")
#combination of grades that get a third
def testDegree1(self):
math = mathmanager()
self.assertEqual(math.degree(0, 70, 50, 60, 40), "third")
#at least one negative grade
def testDegree2(self):
math = mathmanager()
self.assertEqual(math.degree(-1, 40, 40, 40, 40), -1)
#add at least one grade higher than 100, combination of grades that get a fist, 2:2, fail