-
Notifications
You must be signed in to change notification settings - Fork 4
/
point_test.go
74 lines (70 loc) · 1.23 KB
/
point_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPoint_MoveWithDirection(t *testing.T) {
type fields struct {
X int
Y int
}
type args struct {
distance int
direction Direction
}
tests := []struct {
name string
fields fields
args args
want Point
}{
{
name: "",
fields: fields{0, 0},
args: args{
direction: South,
distance: 1,
},
want: Point{0, 1},
},
{
name: "",
fields: fields{0, 0},
args: args{
direction: East,
distance: 1,
},
want: Point{1, 0},
},
{
name: "",
fields: fields{1, 1},
args: args{
direction: North,
distance: 3,
},
want: Point{1, -2},
},
{
name: "",
fields: fields{1, 1},
args: args{
direction: West,
distance: 3,
},
want: Point{-2, 1},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := Point{
X: tt.fields.X,
Y: tt.fields.Y,
}
got := p.TranslateToDirection(tt.args.distance, tt.args.direction)
// assert.Equal(t, tt.wantAnyOf, got)
assert.InDelta(t, tt.want.X, got.X, 0.01, "got %v wantAnyOf %v", got.X, tt.want.X)
assert.InDelta(t, tt.want.Y, got.Y, 0.01, "got %v wantAnyOf %v", got.Y, tt.want.Y)
})
}
}