-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAllTests.py
93 lines (77 loc) · 2.43 KB
/
AllTests.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
import unittest
from helltriangle import HellTriangle
class HellTriangleTestCase(unittest.TestCase):
def test_example(self):
triangle = [[6],[3,5],[9,7,1],[4,6,8,4]]
result = HellTriangle.calculate_longest_path(triangle)
assert result == 26
def test_larger(self):
triangle = [[6],[3,5],[9,7,1],[4,6,8,4],[4,3,2,1,5],[1000,2,3,4,5,6]]
result = HellTriangle.calculate_longest_path(triangle)
assert result == 1026
def test_negative(self):
triangle = [[6],[3,5],[9,7,1],[4,6,-8,4]]
result = HellTriangle.calculate_longest_path(triangle)
assert result == 24
def test_single_element(self):
triangle = [[6]]
result = HellTriangle.calculate_longest_path(triangle)
assert result == 6
def test_invalid1(self):
triangle = [[6],[3,5],[9]]
try:
result = HellTriangle.calculate_longest_path(triangle)
except ValueError:
pass
else:
fail("Expected ValueError")
def test_invalid2(self):
triangle = None
try:
result = HellTriangle.calculate_longest_path(triangle)
except ValueError:
pass
else:
fail("Expected ValueError")
def test_invalid3(self):
triangle = [[6],[3]]
try:
result = HellTriangle.calculate_longest_path(triangle)
except ValueError:
pass
else:
fail("Expected ValueError")
def test_invalid4(self):
triangle = [[6, 7]]
try:
result = HellTriangle.calculate_longest_path(triangle)
except ValueError:
pass
else:
fail("Expected ValueError")
def test_invalid5(self):
triangle = []
try:
result = HellTriangle.calculate_longest_path(triangle)
except ValueError:
pass
else:
fail("Expected ValueError")
def test_invalid6(self):
triangle = [[]]
try:
result = HellTriangle.calculate_longest_path(triangle)
except ValueError:
pass
else:
fail("Expected ValueError")
def test_invalid7(self):
triangle = [1]
try:
result = HellTriangle.calculate_longest_path(triangle)
except ValueError:
pass
else:
fail("Expected ValueError")
if __name__ == "__main__":
unittest.main()