From 1cef508aa32b619e2b18cc27ff61b76a0842af2a Mon Sep 17 00:00:00 2001 From: Breno Baptista Date: Thu, 24 Jun 2021 21:43:25 -0300 Subject: [PATCH] Added tests for problem 617 --- .../617. Merge Two Binary Trees_test.go | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 leetcode/0617.Merge-Two-Binary-Trees/617. Merge Two Binary Trees_test.go diff --git a/leetcode/0617.Merge-Two-Binary-Trees/617. Merge Two Binary Trees_test.go b/leetcode/0617.Merge-Two-Binary-Trees/617. Merge Two Binary Trees_test.go new file mode 100644 index 00000000..249bd5d8 --- /dev/null +++ b/leetcode/0617.Merge-Two-Binary-Trees/617. Merge Two Binary Trees_test.go @@ -0,0 +1,63 @@ +package leetcode + +import ( + "fmt" + "testing" + + "github.com/halfrost/LeetCode-Go/structures" +) + +type question617 struct { + para617 + ans617 +} + +// para 是参数 +// one 代表第一个参数 +type para617 struct { + one []int + another []int +} + +// ans 是答案 +// one 代表第一个答案 +type ans617 struct { + one []int +} + +func Test_Problem617(t *testing.T) { + + qs := []question617{ + + { + para617{[]int{}, []int{}}, + ans617{[]int{}}, + }, + + { + para617{[]int{}, []int{1}}, + ans617{[]int{1}}, + }, + + { + para617{[]int{1, 3, 2, 5}, []int{2, 1, 3, structures.NULL, 4, structures.NULL, 7}}, + ans617{[]int{3, 4, 5, 5, 4, structures.NULL, 7}}, + }, + + { + para617{[]int{1}, []int{1, 2}}, + ans617{[]int{2, 2}}, + }, + } + + fmt.Printf("------------------------Leetcode Problem 617------------------------\n") + + for _, q := range qs { + _, p := q.ans617, q.para617 + fmt.Printf("【input】:%v ", p) + root1 := structures.Ints2TreeNode(p.one) + root2 := structures.Ints2TreeNode(p.another) + fmt.Printf("【output】:%v \n", mergeTrees(root1, root2)) + } + fmt.Printf("\n\n\n") +}