0faf0f2cf5
Signed-off-by: Tim Hårek Andreassen <tim@harek.no>
60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package yr
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.sr.ht/~timharek/yr-go/yr/direction"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestWindDirection(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
south := windDirection(0)
|
|
assert.Equal(direction.SOUTH, south, "south 0")
|
|
|
|
south = windDirection(20)
|
|
assert.Equal(direction.SOUTH, south, "south 20")
|
|
|
|
southwest := windDirection(45)
|
|
assert.Equal(direction.SOUTH_WEST, southwest, "southwest 45")
|
|
|
|
southwest = windDirection(60)
|
|
assert.Equal(direction.SOUTH_WEST, southwest, "southwest 60")
|
|
|
|
west := windDirection(90)
|
|
assert.Equal(direction.WEST, west, "west 90")
|
|
|
|
west = windDirection(100)
|
|
assert.Equal(direction.WEST, west, "west 100")
|
|
|
|
northwest := windDirection(135)
|
|
assert.Equal(direction.NORTH_WEST, northwest, "northwest 135")
|
|
|
|
northwest = windDirection(150)
|
|
assert.Equal(direction.NORTH_WEST, northwest, "northwest 150")
|
|
|
|
north := windDirection(180)
|
|
assert.Equal(direction.NORTH, north, "north 180")
|
|
|
|
north = windDirection(200)
|
|
assert.Equal(direction.NORTH, north, "north 200")
|
|
|
|
northeast := windDirection(225)
|
|
assert.Equal(direction.NORTH_EAST, northeast, "northeast 225")
|
|
|
|
northeast = windDirection(250)
|
|
assert.Equal(direction.NORTH_EAST, northeast, "northeast 250")
|
|
|
|
east := windDirection(270)
|
|
assert.Equal(direction.EAST, east, "east 270")
|
|
|
|
east = windDirection(280)
|
|
assert.Equal(direction.EAST, east, "east 280")
|
|
|
|
southeast := windDirection(315)
|
|
assert.Equal(direction.SOUTH_EAST, southeast, "southeast 315")
|
|
|
|
southeast = windDirection(347.3)
|
|
assert.Equal(direction.SOUTH_EAST, southeast, "southeast 347.3")
|
|
}
|