Skip to content

Commit 1cef508

Browse files
committed
Added tests for problem 617
1 parent 21c05df commit 1cef508

File tree

1 file changed

+63
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)