-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproblem065_test.go
More file actions
39 lines (34 loc) · 791 Bytes
/
Copy pathproblem065_test.go
File metadata and controls
39 lines (34 loc) · 791 Bytes
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 problem065
import "testing"
type inputType [][]int
type outputType []int
type testCase struct {
input inputType
output outputType
}
func assert(t *testing.T, tCase testCase, f func([][]int) []int) bool {
actual, expected := f(tCase.input), tCase.output
for i, actualElement := range actual {
if actualElement != expected[i] {
t.Logf("actual: %v\nexpected: %v", actual, expected)
t.Fail()
return false
}
}
return true
}
func TestTraverse(t *testing.T) {
for _, tCase := range []testCase{
{
input: inputType{
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20},
},
output: outputType{1, 2, 3, 4, 5, 10, 15, 20, 19, 18, 17, 16, 11, 6, 7, 8, 9, 14, 13, 12},
},
} {
assert(t, tCase, TraverseMatrix)
}
}