-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree_test.go
39 lines (36 loc) · 1.31 KB
/
tree_test.go
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
package maths
import "testing"
func TestMaxPath(t *testing.T) {
testCases := []struct {
input *Tree
expectedResult int
}{
{CreateBinaryTree(), 0},
{CreateBinaryTree(1, 2, -3), 3},
{CreateBinaryTree(-1), -1},
{CreateBinaryTree(0), 0},
{CreateBinaryTree(1), 1},
{CreateBinaryTree(1, 2), 3},
{CreateBinaryTree(1, 2, 2), 3},
{CreateBinaryTree(1, 2, 3), 4},
{CreateBinaryTree(1, 2, 3, 4, 5), 8},
{CreateBinaryTree(75, 95, 64, 17, 47, 82, 18, 35, 87, 10), 274},
{CreateBinaryTree(75, 95, 64, 17, 47, 82, 18, 35, 87, 10, 24, 12, 54, 38, 20, 46, 35, 42, 64, 21, 45), 338},
{CreatePyramidTree(1, 2, -3, 4, -5, 6), 7},
{CreatePyramidTree(1, 2, -3), 3},
{CreatePyramidTree(-1), -1},
{CreatePyramidTree(0), 0},
{CreatePyramidTree(1), 1},
{CreatePyramidTree(1, 2), 3},
{CreatePyramidTree(1, 2, 2), 3},
{CreatePyramidTree(1, 2, 3), 4},
{CreatePyramidTree(1, 2, 3, 4, 5, 6), 10},
{CreatePyramidTree(75, 95, 64, 17, 47, 82, 18, 35, 87, 10), 308},
{CreatePyramidTree(75, 95, 64, 17, 47, 82, 18, 35, 87, 10, 24, 12, 54, 38, 20, 46, 35, 42, 64, 21, 45), 426},
}
for _, tC := range testCases {
if actualResult := MaxPath(tC.input); actualResult != tC.expectedResult {
t.Errorf("Input in test: %v. Actual result: %v. Expected result: %v", tC.input, actualResult, tC.expectedResult)
}
}
}