-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_test.go
53 lines (48 loc) · 977 Bytes
/
command_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
package main
import (
"github.com/stretchr/testify/assert"
"go-soldiers/army"
"testing"
)
func initTestArmy() army.Army {
commandSet := army.InitCommands()
return army.Army{
Soldiers: []army.Soldier{
{
Compass: army.North,
X: 1,
Y: 1,
},
{
Compass: army.West,
X: 2,
Y: 2,
},
{
Compass: army.East,
X: 3,
Y: 3,
},
},
CommandSet: &commandSet,
MapSize: 10,
}
}
func Test(t *testing.T) {
a := initTestArmy()
dataSet := []struct {
compass army.Compass
command []string
}{
{army.East, []string{"turn", "east"}},
{army.West, []string{"turn", "west"}},
{army.South, []string{"turn", "south"}},
{army.North, []string{"turn", "north"}},
}
for _, value := range dataSet {
_ = a.ExecuteCommand(value.command[0], value.command[1:])
for i := range a.Soldiers {
assert.Equal(t, value.compass, a.Soldiers[i].Compass, "Soldier was not turned south")
}
}
}