Files
ham/protocol/aprs/_attic/position_test.go
maze 27e2da1943
Some checks failed
Run tests / test (1.25) (push) Failing after 1m0s
Run tests / test (stable) (push) Failing after 1m0s
Added Radio.ID and refactored the Stats interface
2026-03-17 08:33:06 +01:00

54 lines
1.1 KiB
Go

package aprs
import "testing"
func TestLatitude(t *testing.T) {
tests := []struct {
Test string
Want Latitude
}{
{"4903.50N", 49.05833333333333},
{"4903.50S", -49.05833333333333},
{"4903.5 S", -49.05833333333333},
{"4903. S", -49.05},
{"490 . S", -49},
{"4 . S", -40},
}
for _, test := range tests {
t.Run(test.Test, func(t *testing.T) {
var lat Latitude
if err := lat.ParseUncompressed([]byte(test.Test)); err != nil {
t.Fatal(err)
}
if !testAlmostEqual(float64(test.Want), float64(lat)) {
t.Errorf("expected %f, got %f", test.Want, lat)
}
})
}
}
func TestLongitude(t *testing.T) {
tests := []struct {
Test string
Want Longitude
}{
{"00000.00E", 0},
{"00000.00W", 0},
{"00000.98W", -0.016333},
{"00098. W", -1.633333},
{"098 . W", -98.000000},
{"9 . W", -180.000000},
}
for _, test := range tests {
t.Run(test.Test, func(t *testing.T) {
var long Longitude
if err := long.ParseUncompressed([]byte(test.Test)); err != nil {
t.Fatal(err)
}
if !testAlmostEqual(float64(test.Want), float64(long)) {
t.Errorf("expected %f, got %f", test.Want, long)
}
})
}
}