forked from klyve/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rte_test.go
63 lines (59 loc) · 1.41 KB
/
rte_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
package nmea
import (
"testing"
"github.com/stretchr/testify/assert"
)
var rtetests = []struct {
name string
raw string
err string
msg RTE
}{
{
name: "good sentence",
raw: "$IIRTE,4,1,c,Rte 1,411,412,413,414,415*6F",
msg: RTE{
NumberOfSentences: 4,
SentenceNumber: 1,
ActiveRouteOrWaypointList: ActiveRoute,
Name: "Rte 1",
Idents: []string{"411", "412", "413", "414", "415"},
},
},
{
name: "index out if range",
raw: "$IIRTE,4,1,c,Rte 1*77",
err: "nmea: IIRTE invalid ident of waypoints: index out of range",
},
{
name: "invalid number of sentences",
raw: "$IIRTE,X,1,c,Rte 1,411,412,413,414,415*03",
err: "nmea: IIRTE invalid number of sentences: X",
},
{
name: "invalid sentence number",
raw: "$IIRTE,4,X,c,Rte 1,411,412,413,414,415*06",
err: "nmea: IIRTE invalid sentence number: X",
},
{
name: "invalid active route or waypoint list",
raw: "$IIRTE,4,1,X,Rte 1,411,412,413,414,415*54",
err: "nmea: IIRTE invalid active route or waypoint list: X",
},
}
func TestRTE(t *testing.T) {
for _, tt := range rtetests {
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)
rte := m.(RTE)
rte.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, rte)
}
})
}
}