forked from adrianmo/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalf_test.go
58 lines (55 loc) · 1.14 KB
/
alf_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
58
package nmea
import (
"testing"
"github.com/go-test/deep"
)
func Test_newALF(t *testing.T) {
tests := []struct {
name string
raw string
want ALF
wantErr bool
}{
// TODO: Add test cases.
{
name: "test1",
raw: makeSentence("$BDALF,1,1,0,012345.78,A,W,V,FEC,999999,null,99,9,alarming"),
want: ALF{
TotalNum: 1,
SentenceNum: 1,
SeqID: "0",
LastChangeTime: Time{
Valid: true,
Hour: 1,
Minute: 23,
Second: 45,
Millisecond: 780,
},
AlertCatogory: "A",
AlertPriority: "W",
AlertState: "V",
MCode: "FEC",
AlertID: "999999",
AlertInstance: "null",
Revision: "99",
Escalation: "9",
AlertText: "alarming",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m, err := Parse(tt.raw)
if err != nil {
t.Errorf("newALF() error = %v", err)
return
}
msg := m.(ALF)
msg.BaseSentence = BaseSentence{}
if diff := deep.Equal(msg, tt.want); diff != nil {
t.Errorf("newALF() = %#v, want %#v, dif = %v", msg, tt.want, diff)
}
})
}
}