-
Notifications
You must be signed in to change notification settings - Fork 78
/
mwv_test.go
53 lines (50 loc) · 903 Bytes
/
mwv_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
package nmea
import (
"github.com/stretchr/testify/assert"
"testing"
)
var mwvtests = []struct {
name string
raw string
err string
msg MWV
}{
{
name: "good sentence",
raw: "$WIMWV,12.1,T,10.1,N,A*27",
msg: MWV{
WindAngle: 12.1,
Reference: "T",
WindSpeed: 10.1,
WindSpeedUnit: "N",
StatusValid: true,
},
},
{
name: "invalid data",
raw: "$WIMWV,,T,,N,V*32",
msg: MWV{
WindAngle: 0,
Reference: "T",
WindSpeed: 0,
WindSpeedUnit: "N",
StatusValid: false,
},
},
}
func TestMWV(t *testing.T) {
for _, tt := range mwvtests {
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)
mwv := m.(MWV)
mwv.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, mwv)
}
})
}
}