- Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path92.reverseBetween_test.go
45 lines (40 loc) · 904 Bytes
/
92.reverseBetween_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
package linkedList
import (
"reflect"
"testing"
"Leetcode/algorithms/kit"
)
type (
entry92struct {
namestring
inputentry92input
expected []int
}
entry92inputstruct {
ints []int
mint
nint
}
)
// run: go test -v base.go 92.*
funcTest_reverseBetween(t*testing.T) {
cases:= []entry92{
{
name: "x1",
input: entry92input{ints: []int{1, 2, 3, 4, 5}, m: 2, n: 4},
expected: []int{1, 4, 3, 2, 5},
},
{
name: "x2",
input: entry92input{ints: []int{1, 2, 3, 4, 5}, m: 1, n: 5},
expected: []int{5, 4, 3, 2, 1},
},
}
for_, tc:=rangecases {
head:=kit.Ints2List(tc.input.ints)
output:=kit.List2Ints(reverseBetween(head, tc.input.m, tc.input.n))
if!reflect.DeepEqual(output, tc.expected) {
t.Errorf("reverseBetween(%v, %d, %d)=%v, expected=%v", tc.input.ints, tc.input.m, tc.input.n, output, tc.expected)
}
}
}