-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
52 lines (42 loc) · 1.06 KB
/
main_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
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMoveNorth(t *testing.T) {
boat := ferry{x: 0, y: 0, direction: east}
boat.turn(-90)
assert.Equal(t, boat.direction, north)
boat.turn(-270)
assert.Equal(t, boat.direction, east)
boat.turn(270)
assert.Equal(t, boat.direction, north)
boat.turn(270)
assert.Equal(t, boat.direction, west)
boat.turn(180)
assert.Equal(t, boat.direction, east)
boat.turn(90)
assert.Equal(t, boat.direction, south)
boat.turn(-180)
assert.Equal(t, boat.direction, north)
}
func TestAngleStep2(t *testing.T) {
x, y := wayPointTurn(4, 10, 90)
assert.Equal(t, 10, x)
assert.Equal(t, -4, y)
x, y = wayPointTurn(4, 10, 180)
assert.Equal(t, -4, x)
assert.Equal(t, -10, y)
x, y = wayPointTurn(4, 10, 270)
assert.Equal(t, -10, x)
assert.Equal(t, 4, y)
x, y = wayPointTurn(4, 10, -90)
assert.Equal(t, -10, x)
assert.Equal(t, 4, y)
x, y = wayPointTurn(4, 10, -180)
assert.Equal(t, -4, x)
assert.Equal(t, -10, y)
x, y = wayPointTurn(4, 10, -270)
assert.Equal(t, 10, x)
assert.Equal(t, -4, y)
}