Skip to content

Commit 8c1235b

Browse files
committed
Added tests for problem 543
1 parent dd26b1d commit 8c1235b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package leetcode
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/halfrost/LeetCode-Go/structures"
8+
)
9+
10+
type question543 struct {
11+
para543
12+
ans543
13+
}
14+
15+
// para 是参数
16+
// one 代表第一个参数
17+
type para543 struct {
18+
one []int
19+
}
20+
21+
// ans 是答案
22+
// one 代表第一个答案
23+
type ans543 struct {
24+
one int
25+
}
26+
27+
func Test_Problem543(t *testing.T) {
28+
29+
qs := []question543{
30+
31+
{
32+
para543{[]int{1, 2, 3, 4, 5}},
33+
ans543{3},
34+
},
35+
36+
{
37+
para543{[]int{1, 2}},
38+
ans543{1},
39+
},
40+
41+
{
42+
para543{[]int{4, -7, -3, structures.NULL, structures.NULL, -9, -3, 9, -7, -4, structures.NULL, 6, structures.NULL, -6, -6, structures.NULL, structures.NULL, 0, 6, 5, structures.NULL, 9, structures.NULL, structures.NULL, -1, -4, structures.NULL, structures.NULL, structures.NULL, -2}},
43+
ans543{8},
44+
},
45+
}
46+
47+
fmt.Printf("------------------------Leetcode Problem 543------------------------\n")
48+
49+
for _, q := range qs {
50+
_, p := q.ans543, q.para543
51+
fmt.Printf("【input】:%v ", p)
52+
root := structures.Ints2TreeNode(p.one)
53+
fmt.Printf("【output】:%v \n", diameterOfBinaryTree(root))
54+
}
55+
fmt.Printf("\n\n\n")
56+
}

0 commit comments

Comments
 (0)