-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzda_test.go
55 lines (51 loc) · 991 Bytes
/
zda_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
package nmea
import (
"testing"
"github.com/stretchr/testify/assert"
)
var zdatests = []struct {
name string
raw string
err string
msg ZDA
}{
{
name: "good sentence",
raw: "$GPZDA,172809.456,12,07,1996,00,00*57",
msg: ZDA{
Time: Time{
Valid: true,
Hour: 17,
Minute: 28,
Second: 9,
Millisecond: 456,
},
Day: 12,
Month: 7,
Year: 1996,
OffsetHours: 0,
OffsetMinutes: 0,
},
},
{
name: "invalid day",
raw: "$GPZDA,220516,D,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*76",
err: "nmea: GPZDA invalid day: D",
},
}
func TestZDA(t *testing.T) {
for _, tt := range zdatests {
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)
zda := m.(ZDA)
zda.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, zda)
}
})
}
}