-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathminsteps_test.go
44 lines (41 loc) · 933 Bytes
/
minsteps_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
package minsteps
import "testing"
func TestMinSteps(t *testing.T) {
type Scenario struct {
input [][]bool
srcX, srcY, dstX, dstY int
expectedOutput int
}
table := map[string]Scenario{
"route exists": Scenario{
input: [][]bool{
{false, false, false, false},
{true, true, false, true},
{false, false, false, false},
{false, false, false, false},
},
srcX: 3, srcY: 0,
dstX: 0, dstY: 0,
expectedOutput: 7,
},
"no route": Scenario{
input: [][]bool{
{false, false, false, false},
{true, true, false, true},
{false, true, false, false},
{false, false, true, false},
},
srcX: 3, srcY: 0,
dstX: 0, dstY: 0,
expectedOutput: 0,
},
}
for name, s := range table {
if m := MinSteps(s.input,
s.srcX, s.srcY,
s.dstX, s.dstY,
); m != s.expectedOutput {
t.Errorf("\n\t%s: expected:%d got:%d", name, s.expectedOutput, m)
}
}
}