forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvhw_test.go
47 lines (44 loc) · 911 Bytes
/
vhw_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
package nmea
import (
"testing"
"github.com/go-test/deep"
)
func Test_newVHW(t *testing.T) {
tests := []struct {
name string
raw string
want VHW
wantErr bool
}{
// TODO: Add test cases.
{
name: "test1",
raw: makeSentence("$BDVHW,1.1,T,2.2,M,3.3,N,4.4,K"),
want: VHW{
HeadingTrue: 1.1,
True: "T",
HeadingMagnetic: 2.2,
Magnetic: "M",
SpeedKnots: 3.3,
Knots: "N",
SpeedKph: 4.4,
Kph: "K",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m, err := Parse(tt.raw)
if err != nil {
t.Errorf("newVHW() error = %v", err)
return
}
msg := m.(VHW)
msg.BaseSentence = BaseSentence{}
if diff := deep.Equal(msg, tt.want); diff != nil {
t.Errorf("newVHW() = %#v, want %#v, dif = %v", msg, tt.want, diff)
}
})
}
}