forked from HVelosoETI/go-nmea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgrme_test.go
66 lines (62 loc) · 1.31 KB
/
pgrme_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
59
60
61
62
63
64
65
66
package nmea
import (
"testing"
"github.com/stretchr/testify/assert"
)
var pgrmetests = []struct {
name string
raw string
err string
msg PGRME
}{
{
name: "good sentence",
raw: "$PGRME,3.3,M,4.9,M,6.0,M*25",
msg: PGRME{
Horizontal: 3.3,
Vertical: 4.9,
Spherical: 6,
},
},
{
name: "invalid horizontal error",
raw: "$PGRME,A,M,4.9,M,6.0,M*4A",
err: "nmea: PGRME invalid horizontal error: A",
},
{
name: "invalid vertical error",
raw: "$PGRME,3.3,M,A,M,6.0,M*47",
err: "nmea: PGRME invalid vertical error: A",
},
{
name: "invalid vertical error unit",
raw: "$PGRME,3.3,M,4.9,A,6.0,M*29",
err: "nmea: PGRME invalid vertical error unit: A",
},
{
name: "invalid spherical error",
raw: "$PGRME,3.3,M,4.9,M,A,M*4C",
err: "nmea: PGRME invalid spherical error: A",
},
{
name: "invalid spherical error unit",
raw: "$PGRME,3.3,M,4.9,M,6.0,A*29",
err: "nmea: PGRME invalid spherical error unit: A",
},
}
func TestPGRME(t *testing.T) {
for _, tt := range pgrmetests {
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)
pgrme := m.(PGRME)
pgrme.BaseSentence = BaseSentence{}
assert.Equal(t, tt.msg, pgrme)
}
})
}
}