forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rot_test.go
48 lines (46 loc) · 868 Bytes
/
rot_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
package nmea
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestROT(t *testing.T) {
var tests = []struct {
name string
raw string
err string
msg ROT
}{
{
name: "good sentence",
raw: "$HEROT,-11.23,A*07",
msg: ROT{
RateOfTurn: -11.23,
Valid: true,
},
},
{
name: "invalid RateOfTurn",
raw: "$HEROT,x,A*7D",
err: "nmea: HEROT invalid rate of turn: x",
},
{
name: "invalid Valid",
raw: "$HEROT,-11.23,X*1E",
err: "nmea: HEROT invalid status valid: 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)
rot := m.(ROT)
rot.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, rot)
}
})
}
}