-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid_test.go
54 lines (51 loc) · 1.1 KB
/
grid_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
46
47
48
49
50
51
52
53
54
package main
import (
"reflect"
"testing"
)
func Test_newGrid(t *testing.T) {
tests := []struct {
name string
dimensions int
moves string
zombie zombie
creatures []creature
expectedGrid Grid
}{
{
name: "test happy path",
dimensions: 4,
moves: "DLUURR",
zombie: zombie{XPos: 2, YPos: 1},
creatures: []creature{
creature{XPos: 0, YPos: 1},
creature{XPos: 1, YPos: 2},
creature{XPos: 3, YPos: 1},
},
expectedGrid: Grid{
Dimensions: 4,
Moves: "DLUURR",
Zombies: []zombie{
zombie{XPos: 2, YPos: 1},
},
Creatures: []creature{
creature{XPos: 0, YPos: 1},
creature{XPos: 1, YPos: 2},
creature{XPos: 3, YPos: 1},
},
},
},
{
name: "test empty value",
expectedGrid: Grid{
Zombies: []zombie{zombie{}},
},
},
}
for _, test := range tests {
output := newGrid(test.dimensions, test.moves, test.zombie, test.creatures)
if !reflect.DeepEqual(test.expectedGrid, output) {
t.Errorf("for %s, expected result %+v, but got %+v", test.name, test.expectedGrid, output)
}
}
}