forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aam_test.go
56 lines (54 loc) · 1.33 KB
/
aam_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
package nmea
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestAAM(t *testing.T) {
var tests = []struct {
name string
raw string
err string
msg AAM
}{
{
name: "good sentence",
raw: "$GPAAM,A,A,0.10,N,WPTNME*32",
msg: AAM{
StatusArrivalCircleEntered: WPStatusArrivalCircleEnteredA,
StatusPerpendicularPassed: WPStatusPerpendicularPassedA,
ArrivalCircleRadius: 0.1,
ArrivalCircleRadiusUnit: DistanceUnitNauticalMile,
DestinationWaypointID: "WPTNME",
},
},
{
name: "invalid nmea: StatusArrivalCircleEntered",
raw: "$GPAAM,x,A,0.10,N,WPTNME*0B",
err: "nmea: GPAAM invalid arrival circle entered status: x",
},
{
name: "invalid nmea: StatusPerpendicularPassed",
raw: "$GPAAM,A,x,0.10,N,WPTNME*0B",
err: "nmea: GPAAM invalid perpendicularly passed status: x",
},
{
name: "invalid nmea: DistanceUnitNauticalMile",
raw: "$GPAAM,A,A,0.10,x,WPTNME*04",
err: "nmea: GPAAM invalid arrival circle radius units: x",
},
}
for _, tt := range tests {
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)
aam := m.(AAM)
aam.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, aam)
}
})
}
}