1
0
Fork 0
mirror of https://github.com/Luzifer/go_helpers.git synced 2024-12-25 13:31:21 +00:00
go_helpers/position/haversine_test.go
Knut Ahlers 63159db627
Remove gomega from tests and update dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2023-10-12 13:39:52 +02:00

30 lines
760 B
Go

package position_test
import (
"testing"
. "github.com/Luzifer/go_helpers/v2/position"
"github.com/stretchr/testify/assert"
)
func TestHaversine(t *testing.T) {
testCases := []struct {
SourceLat float64
SourceLon float64
DestLat float64
DestLon float64
Distance float64
}{
{50.066389, -5.714722, 58.643889, -3.070000, 968.8535441168448},
{50.063995, -5.609464, 53.553027, 9.993782, 1137.894906816002},
{53.553027, 9.993782, 53.554528, 9.991357, 0.23133816528015647},
{50, 9, 51, 9, 111.19492664455873},
{0, 9, 0, 10, 111.19492664455873},
{1, 0, -1, 0, 222.38985328911747},
}
for i := range testCases {
tc := testCases[i]
assert.Equal(t, tc.Distance, Haversine(tc.SourceLon, tc.SourceLat, tc.DestLon, tc.DestLat))
}
}