- Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path206.reverseList_test.go
39 lines (35 loc) · 736 Bytes
/
206.reverseList_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
package linkedList
import (
"reflect"
"testing"
"Leetcode/algorithms/kit"
)
// run: go test -v base.go 206.*
funcTest_reverseList(t*testing.T) {
cases:= []struct {
namestring
input []int
expected []int
}{
// {
// name: "x1",
// input: []int{},
// expected: []int{},
// },
{
name: "x2",
input: []int{1, 2, 3, 4, 5},
expected: []int{5, 4, 3, 2, 1},
},
}
for_, tt:=rangecases {
t.Run(tt.name, func(t*testing.T) {
head:=kit.Ints2List(tt.input)
output:=reverseListV2(head)
out2ints:=kit.List2Ints(output)
if!reflect.DeepEqual(out2ints, tt.expected) {
t.Errorf("reverseList(%v)=%v, expected=%v", tt.input, out2ints, tt.expected)
}
})
}
}