Skip to content

Commit df1e8c3

Browse files
author
openset
committed
Add: test
1 parent 7d438f4 commit df1e8c3

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Diff for: problems/01-matrix/01_matrix_test.go

+45
Original file line numberDiff line numberDiff line change
@@ -1 +1,46 @@
11
package p_01_matrix
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
type caseType struct {
9+
input [][]int
10+
expected [][]int
11+
}
12+
13+
func TestUpdateMatrix(t *testing.T) {
14+
tests := [...]caseType{
15+
{
16+
input: [][]int{
17+
{0, 0, 0},
18+
{0, 1, 0},
19+
{0, 0, 0},
20+
},
21+
expected: [][]int{
22+
{0, 0, 0},
23+
{0, 1, 0},
24+
{0, 0, 0},
25+
},
26+
},
27+
{
28+
input: [][]int{
29+
{0, 0, 0},
30+
{0, 1, 0},
31+
{1, 1, 1},
32+
},
33+
expected: [][]int{
34+
{0, 0, 0},
35+
{0, 1, 0},
36+
{1, 2, 1},
37+
},
38+
},
39+
}
40+
for _, tc := range tests {
41+
output := updateMatrix(tc.input)
42+
if !reflect.DeepEqual(output, tc.expected) {
43+
t.Fatalf("input: %v, output: %v, expected: %v", tc.input, output, tc.expected)
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)