-
Notifications
You must be signed in to change notification settings - Fork 80
/
gll_test.go
71 lines (67 loc) · 1.36 KB
/
gll_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package nmea
import (
"testing"
"github.com/stretchr/testify/assert"
)
var glltests = []struct {
name string
raw string
err string
msg GLL
}{
{
name: "good sentence",
raw: "$GPGLL,3926.7952,N,12000.5947,W,022732,A,A*58",
msg: GLL{
Latitude: MustParseLatLong("3926.7952 N"),
Longitude: MustParseLatLong("12000.5947 W"),
Time: Time{
Valid: true,
Hour: 2,
Minute: 27,
Second: 32,
Millisecond: 0,
},
Validity: "A",
FFAMode: FAAModeAutonomous,
},
},
{
name: "good sentence without FAA mode",
raw: "$IIGLL,5924.462,N,01030.048,E,062216,A*38",
msg: GLL{
Latitude: MustParseLatLong("5924.462 N"),
Longitude: MustParseLatLong("01030.048 E"),
Time: Time{
Valid: true,
Hour: 6,
Minute: 22,
Second: 16,
Millisecond: 0,
},
Validity: "A",
FFAMode: "",
},
},
{
name: "bad validity",
raw: "$GPGLL,3926.7952,N,12000.5947,W,022732,D,A*5D",
err: "nmea: GPGLL invalid validity: D",
},
}
func TestGLL(t *testing.T) {
for _, tt := range glltests {
t.Run(tt.name, func(t *testing.T) {
m, err := Parse(tt.raw)
if tt.err != "" {
assert.Error(t, err)
assert.EqualError(t, err, tt.err)
} else {
assert.NoError(t, err)
gll := m.(GLL)
gll.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, gll)
}
})
}
}