-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
206 lines (155 loc) · 5.38 KB
/
test.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import unittest
from calculator import Calculate
class Test(unittest.TestCase):
def test__OO__sum(self):
Solve = "1+2+3+4+5+6"
self.assertEqual(Calculate(Solve), 21)
def test__OO__minus(self):
Solve = "50-10-15-5"
self.assertEqual(Calculate(Solve), 20)
def test__OO__multiply(self):
Solve = "5*5*4"
self.assertEqual(Calculate(Solve), 100)
def test__OO__divide(self):
Solve = "100/2/5/2"
self.assertEqual(Calculate(Solve), 5)
def test__OO__sum_and_minus(self):
Solve = "2+3-2+3+3+4-10"
self.assertEqual(Calculate(Solve), 3)
def test__OO__multiply_and_divide(self):
Solve = "5*5*4/10*2"
self.assertEqual(Calculate(Solve), 20)
def test__OO__sum_and_multiply(self):
Solve = "1+2+3+4+5+6*2+1+2+3*4"
self.assertEqual(Calculate(Solve), 42)
def test__OO__combined_1(self):
Solve = "5*3+5-2/2+14/7*3"
self.assertEqual(Calculate(Solve), 25)
def test__OO__combined_2(self):
Solve = "1+9/3+1*5-100/5"
self.assertEqual(Calculate(Solve), -11)
def test__OO__error_division(self):
Solve = "1+2+3+4+5+6/0"
self.assertEqual(Calculate(Solve), "MATH ERROR")
def test__OO__combined_3(self):
Solve = "(5*3)/5*9+100"
self.assertEqual(Calculate(Solve), 127)
def test__OO__fraction(self):
Solve = "(3/5)*(5/3)"
self.assertEqual(Calculate(Solve), 1.0)
def test__OO__addition_of_two_negative_numbers(self):
Solve = "(-2)+(-2)"
self.assertEqual(Calculate(Solve), -4)
def test__OO__addition_of_one_positive_and_one_negative_number(self):
Solve = "(1)+(-2)"
self.assertEqual(Calculate(Solve), -1)
def test__OO__subtraction_of_two_negative_numbers(self):
Solve = "(-6)-(-2)"
self.assertEqual(Calculate(Solve), -4)
def test__OO__subtraction_of_one_negative_and_one_positive_number(self):
Solve = "(-6)-(2)"
self.assertEqual(Calculate(Solve), -8)
def test__OO__multiplication_of_two_negative_numbers(self):
Solve = "(-6)*(-2)"
self.assertEqual(Calculate(Solve), 12)
def test__OO__multiplication_of_one_negative_and_one_positive_number(self):
Solve = "(-6)*(2)"
self.assertEqual(Calculate(Solve), -12)
def test__OO__division_of_two_negative_numbers(self):
Solve = "(-6)/(-2)"
self.assertEqual(Calculate(Solve), 3)
def test__OO__division_of_one_negative_and_one_positive_number(self):
Solve = "(-6)/(2)"
self.assertEqual(Calculate(Solve), -3)
def test__OO__multiplication_before_addition(self):
Solve = "3+6*2"
self.assertEqual(Calculate(Solve), 15)
def test__OO__parentheses_first(self):
Solve = "(3+6)*2"
self.assertEqual(Calculate(Solve), 18)
def test__OO__multiplication_and_division(self):
Solve = "12/6*3/2"
self.assertEqual(Calculate(Solve), 3)
def test__OO__exponents_of_exponents(self):
Solve = "4^3^2"
self.assertEqual(Calculate(Solve), 262144)
def test__OO__pemdas(self):
Solve = "7+(6*5^2+3)"
self.assertEqual(Calculate(Solve), 160)
def test__OO__sin(self):
Solve = "sin(90)"
self.assertEqual(Calculate(Solve), 0.8939966636005579)
def test__OO__cos(self):
Solve = "cos(90)"
self.assertEqual(Calculate(Solve), -0.4480736161291701)
def test__OO__tan(self):
Solve = "tan(45)"
self.assertEqual(Calculate(Solve), 1.6197751905438615)
def test__OO__asin(self):
Solve = "asin(1)"
self.assertEqual(Calculate(Solve), 1.5707963267948966)
def test__OO__acos(self):
Solve = "acos(1)"
self.assertEqual(Calculate(Solve), 0)
def test__OO__atan(self):
Solve = "atan(1)"
self.assertEqual(Calculate(Solve), 0.7853981633974483)
def test__OO__sinh(self):
Solve = "sinh(90)"
self.assertEqual(Calculate(Solve), 6.102016471589204e+38)
def test__OO__cosh(self):
Solve = "cosh(90)"
self.assertEqual(Calculate(Solve), 6.102016471589204e+38)
def test__OO__tanh(self):
Solve = "tanh(45)"
self.assertEqual(Calculate(Solve), 1)
def test__OO__mod(self):
Solve = "mod(30,8)"
self.assertEqual(Calculate(Solve), 6)
def test__OO__sqrt(self):
Solve = "sqrt(4)"
self.assertEqual(Calculate(Solve), 2)
def test__OO__root(self):
Solve = "root(27,3)"
self.assertEqual(Calculate(Solve), 3)
def test__OO__factorial(self):
Solve = "fact(3)"
self.assertEqual(Calculate(Solve), 6)
def test__OO__log(self):
Solve = "logx(100,10)"
self.assertEqual(Calculate(Solve), 2)
def test__OO__log10(self):
Solve = "log10(100)"
self.assertEqual(Calculate(Solve), 2)
def test__OO__ln2(self):
Solve = "ln(2)"
self.assertEqual(Calculate(Solve), 0.6931471805599453)
def test__OO__abs(self):
Solve = "abs(-2)"
self.assertEqual(Calculate(Solve), 2)
def test__OO__abs1(self):
Solve = "abs(-2)"
self.assertEqual(Calculate(Solve), 2)
def test__OO__abs2(self):
Solve = "abs(5*(-2))"
self.assertEqual(Calculate(Solve), 10)
def test__OO__int1(self):
Solve = "tnc(24.99)"
self.assertEqual(Calculate(Solve), 24)
def test__OO__int2(self):
Solve = "tnc(5*2.5)"
self.assertEqual(Calculate(Solve), 12)
def test__OO__round1(self):
Solve = "rnd(25.99)"
self.assertEqual(Calculate(Solve), 26)
def test__OO__round1(self):
Solve = "rnd(5*2.5)"
self.assertEqual(Calculate(Solve), 12)
def test__OO__permutation(self):
Solve = "P(5,2)"
self.assertEqual(Calculate(Solve), 20)
def test__OO__combination(self):
Solve = "C(5,2)"
self.assertEqual(Calculate(Solve), 10)
if __name__ == "__main__":
unittest.main()