-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtempbasal_test.go
56 lines (53 loc) · 1.03 KB
/
tempbasal_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
package medtronic
import (
"reflect"
"testing"
"time"
)
func insulinPointer(n int) *Insulin {
v := Insulin(n)
return &v
}
func TestTempBasal(t *testing.T) {
cases := []struct {
data []byte
b TempBasalInfo
}{
{
parseBytes("06 00 00 00 8C 00 1E"),
TempBasalInfo{
Duration: 30 * time.Minute,
Type: Absolute,
Rate: insulinPointer(3500),
},
},
{
parseBytes("06 00 00 00 37 00 17"),
TempBasalInfo{
Duration: 23 * time.Minute,
Type: Absolute,
Rate: insulinPointer(1375),
},
},
{
parseBytes("06 00 00 05 50 00 1E"),
TempBasalInfo{
Duration: 30 * time.Minute,
Type: Absolute,
Rate: insulinPointer(34000),
},
},
}
for _, c := range cases {
t.Run("", func(t *testing.T) {
b, err := decodeTempBasal(c.data)
if err != nil {
t.Errorf("decodeTempBasal(% X) returned %+v, want %+v", c.data, err, c.b)
return
}
if !reflect.DeepEqual(b, c.b) {
t.Errorf("decodeTempBasal(% X) == %+v, want %+v", c.data, b, c.b)
}
})
}
}