forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhdg_test.go
44 lines (41 loc) · 846 Bytes
/
hdg_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
package nmea
import (
"testing"
"github.com/go-test/deep"
)
func Test_newHDG(t *testing.T) {
tests := []struct {
name string
raw string
want HDG
wantErr bool
}{
// TODO: Add test cases.
{
name: "test1",
raw: makeSentence("$BDHDG,5.0,100.1,E,9.00,W"),
want: HDG{
Heading: 5.0,
Deviation: 100.1,
DeviationDirection: "E",
Variation: 9.00,
VariationDirection: "W",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m, err := Parse(tt.raw)
if err != nil {
t.Errorf("newHDG() error = %v", err)
return
}
msg := m.(HDG)
msg.BaseSentence = BaseSentence{}
if diff := deep.Equal(msg, tt.want); diff != nil {
t.Errorf("newHDG() = %#v, want %#v, dif = %v", msg, tt.want, diff)
}
})
}
}