-
Notifications
You must be signed in to change notification settings - Fork 79
/
mda_test.go
57 lines (54 loc) · 1.25 KB
/
mda_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
package nmea
import (
"github.com/stretchr/testify/assert"
"testing"
)
var mdatests = []struct {
name string
raw string
err string
msg MDA
}{
{
name: "good sentence",
raw: "$WIMDA,3.02,I,1.01,B,23.4,C,,,40.2,,12.1,C,19.3,T,20.1,M,13.1,N,1.1,M*62",
msg: MDA{
PressureInch: 3.02,
InchesValid: true,
PressureBar: 1.01,
BarsValid: true,
AirTemp: 23.4,
AirTempValid: true,
WaterTemp: 0,
WaterTempValid: false,
RelativeHum: 40.2,
AbsoluteHum: 0,
DewPoint: 12.1,
DewPointValid: true,
WindDirectionTrue: 19.3,
TrueValid: true,
WindDirectionMagnetic: 20.1,
MagneticValid: true,
WindSpeedKnots: 13.1,
KnotsValid: true,
WindSpeedMeters: 1.1,
MetersValid: true,
},
},
}
func TestMDA(t *testing.T) {
for _, tt := range mdatests {
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)
mda := m.(MDA)
mda.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, mda)
}
})
}
}