-
Notifications
You must be signed in to change notification settings - Fork 78
/
eve_test.go
50 lines (48 loc) · 986 Bytes
/
eve_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
package nmea
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestEVE(t *testing.T) {
var tests = []struct {
name string
raw string
err string
msg EVE
}{
{
name: "good sentence",
raw: "$FREVE,000001,DZ00513,Fire Alarm On: TEST DZ201 Name*0A",
msg: EVE{
Time: Time{
Valid: true,
Hour: 0,
Minute: 0,
Second: 1,
Millisecond: 0,
},
TagCode: "DZ00513",
Message: "Fire Alarm On: TEST DZ201 Name",
},
},
{
name: "invalid nmea: Time",
raw: "$FREVE,0x0001,DZ00513,Fire Alarm On: TEST DZ201 Name*42",
err: "nmea: FREVE invalid time: 0x0001",
},
}
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)
eve := m.(EVE)
eve.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, eve)
}
})
}
}