-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy path445. Add Two Numbers II_test.go
81 lines (64 loc) · 1.39 KB
/
445. Add Two Numbers II_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 question445 struct {
para445
ans445
}
// para 是参数
// one 代表第一个参数
type para445 struct {
one []int
another []int
}
// ans 是答案
// one 代表第一个答案
type ans445 struct {
one []int
}
func Test_Problem445(t *testing.T) {
qs := []question445{
{
para445{[]int{}, []int{}},
ans445{[]int{}},
},
{
para445{[]int{1}, []int{1}},
ans445{[]int{2}},
},
{
para445{[]int{1, 2, 3, 4}, []int{1, 2, 3, 4}},
ans445{[]int{2, 4, 6, 8}},
},
{
para445{[]int{1, 2, 3, 4, 5}, []int{1, 2, 3, 4, 5}},
ans445{[]int{2, 4, 6, 9, 0}},
},
{
para445{[]int{1}, []int{9, 9, 9, 9, 9}},
ans445{[]int{1, 0, 0, 0, 0, 0}},
},
{
para445{[]int{9, 9, 9, 9, 9}, []int{1}},
ans445{[]int{1, 0, 0, 0, 0, 0}},
},
{
para445{[]int{2, 4, 3}, []int{5, 6, 4}},
ans445{[]int{8, 0, 7}},
},
{
para445{[]int{1, 8, 3}, []int{7, 1}},
ans445{[]int{2, 5, 4}},
},
// 如需多个测试,可以复制上方元素。
}
fmt.Printf("------------------------Leetcode Problem 445------------------------\n")
for _, q := range qs {
_, p := q.ans445, q.para445
fmt.Printf("【input】:%v 【output】:%v\n", p, structures.List2Ints(addTwoNumbers445(structures.Ints2List(p.one), structures.Ints2List(p.another))))
}
fmt.Printf("\n\n\n")
}