Skip to content

Commit 37b05f8

Browse files
committed
complete daily 2017. Grid Game
1 parent 62d30d8 commit 37b05f8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

medium/2017_grid_game/2017_grid_game_test.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,45 @@ package grid_game
33
import "testing"
44

55

6+
func TestGridGame(t *testing.T) {
7+
tests := []struct {
8+
name string
9+
grid [][]int
10+
expectedResult int
11+
} {
12+
{
13+
name: "Test Case 1",
14+
grid: [][]int {
15+
{2,5,4},
16+
{1,5,1},
17+
},
18+
expectedResult: 4,
19+
},
20+
{
21+
name: "Test Case 2",
22+
grid: [][]int {
23+
{3,3,1},
24+
{8,5,2},
25+
},
26+
expectedResult: 4,
27+
},
28+
{
29+
name: "Test Case 3",
30+
grid: [][]int {
31+
{1,3,1,15},
32+
{1,3,3,1},
33+
},
34+
expectedResult: 7,
35+
},
36+
}
37+
38+
for _, test := range tests {
39+
t.Run(test.name, func (t *testing.T) {
40+
got := gridGame(test.grid)
41+
if got != test.expectedResult {
42+
t.Errorf("gridGame(%v) = %d; want = %d", test.grid, got, test.expectedResult)
43+
}
44+
})
45+
}
46+
47+
}

0 commit comments

Comments
 (0)