forked from halfrost/LeetCode-Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path21. Merge Two Sorted Lists_test.go
81 lines (64 loc) · 1.48 KB
/
21. Merge Two Sorted Lists_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
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
package leetcode
import (
"fmt"
"testing"
"github.com/halfrost/LeetCode-Go/structures"
)
type question21 struct {
para21
ans21
}
// para 是参数
// one 代表第一个参数
type para21 struct {
one []int
another []int
}
// ans 是答案
// one 代表第一个答案
type ans21 struct {
one []int
}
func Test_Problem21(t *testing.T) {
qs := []question21{
question21{
para21{[]int{}, []int{}},
ans21{[]int{}},
},
question21{
para21{[]int{1}, []int{1}},
ans21{[]int{1, 1}},
},
question21{
para21{[]int{1, 2, 3, 4}, []int{1, 2, 3, 4}},
ans21{[]int{1, 1, 2, 2, 3, 3, 4, 4}},
},
question21{
para21{[]int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5}},
ans21{[]int{1, 1, 2, 2, 3, 3, 4, 4, 5, 5}},
},
question21{
para21{[]int{1}, []int{9, 9, 9, 9, 9}},
ans21{[]int{1, 9, 9, 9, 9, 9}},
},
question21{
para21{[]int{9, 9, 9, 9, 9}, []int{1}},
ans21{[]int{1, 9, 9, 9, 9, 9}},
},
question21{
para21{[]int{2, 3, 4}, []int{4, 5, 6}},
ans21{[]int{2, 3, 4, 4, 5, 6}},
},
question21{
para21{[]int{1, 3, 8}, []int{1, 7}},
ans21{[]int{1, 1, 3, 7, 8}},
},
// 如需多个测试,可以复制上方元素。
}
fmt.Printf("------------------------Leetcode Problem 21------------------------\n")
for _, q := range qs {
_, p := q.ans21, q.para21
fmt.Printf("【input】:%v 【output】:%v\n", p, structures.List2Ints(mergeTwoLists(structures.Ints2List(p.one), structures.Ints2List(p.another))))
}
fmt.Printf("\n\n\n")
}