-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_test.go
32 lines (29 loc) · 1.09 KB
/
version_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
package ssp
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewFirmwareVersionResponse(t *testing.T) {
testcases := []struct {
Name string
Data []byte
FirmwareVersion string
DeviceVersion string
ReleaseVersion string
BetaVersion string
}{
{"from docs", []byte{0x7F, 0x80, 0x11, 0xF0, 0x4E, 0x56, 0x30, 0x32, 0x30, 0x30, 0x34, 0x31, 0x34, 0x31, 0x34, 0x39, 0x38, 0x30, 0x30, 0x30, 0xDE, 0x55}, "NV02004141498000", "NV0200", "1498", "000"},
{"from device", []byte{0x7F, 0x80, 0x11, 0xf0, 0x4e, 0x56, 0x53, 0x30, 0x30, 0x39, 0x31, 0x30, 0x39, 0x32, 0x35, 0x30, 0x30, 0x30, 0x30, 0x30, 0x7a, 0x18}, "NVS0091092500000", "NVS009", "2500", "000"},
}
for _, tc := range testcases {
t.Run(tc.Name, func(t *testing.T) {
p, err := Decode(tc.Data)
assert.NoError(t, err)
resp := NewVersionResponse(p)
assert.Equal(t, tc.FirmwareVersion, resp.FirmwareVersion)
assert.Equal(t, tc.DeviceVersion, resp.DeviceVersion)
assert.Equal(t, tc.ReleaseVersion, resp.ReleaseVersion)
assert.Equal(t, tc.BetaVersion, resp.BetaVersion)
})
}
}