2021-11-22 18:18:41 +01:00
|
|
|
package geo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2023-09-20 16:56:38 +02:00
|
|
|
func TestKmToDeg(t *testing.T) {
|
|
|
|
t.Run("10km", func(t *testing.T) {
|
|
|
|
assert.Equal(t, 0.09009009, KmToDeg(10))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestKm(t *testing.T) {
|
2021-11-22 18:18:41 +01:00
|
|
|
t.Run("BerlinShanghai", func(t *testing.T) {
|
2021-11-23 19:23:10 +01:00
|
|
|
berlin := Position{Name: "Berlin", Lat: 52.5243700, Lng: 13.4105300}
|
|
|
|
shanghai := Position{Name: "Shanghai", Lat: 31.2222200, Lng: 121.4580600}
|
2021-11-22 18:18:41 +01:00
|
|
|
|
2021-11-23 19:23:10 +01:00
|
|
|
result := Km(berlin, shanghai)
|
2021-11-22 18:18:41 +01:00
|
|
|
|
|
|
|
assert.Equal(t, 8396, int(result))
|
|
|
|
})
|
|
|
|
}
|