-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest_squarer.py
45 lines (32 loc) · 964 Bytes
/
test_squarer.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
# test.py
from squarer import Squarer
class SquarerTest(object):
@staticmethod
def test_positive_numbers():
squares = {
1: 1,
2: 4,
3: 9,
12: 144,
100: 10000,
}
for num, square in squares.items():
result = Squarer.calc(num)
if result != square:
print("Squared {} and got {} but expected {}".format(num, result, square))
@staticmethod
def test_negative_numbers():
squares = {
-1: 1,
-2: 4,
-3: 9,
-12: 144,
-100: 10000,
}
for num, square in squares.items():
result = Squarer.calc(num)
if result != square:
print("Squared {} and got {} but expected {}".format(num, result, square))
if __name__ == "__main__":
SquarerTest.test_positive_numbers()
SquarerTest.test_negative_numbers()