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) } }) } }