This repository was archived by the owner on Sep 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmapper_test.go
More file actions
70 lines (68 loc) · 2.09 KB
/
Copy pathmapper_test.go
File metadata and controls
70 lines (68 loc) · 2.09 KB
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
67
68
69
70
package gmg
import (
"reflect"
"testing"
)
func TestGetGrillInfoResponseToGrillInfo(t *testing.T) {
type args struct {
response []byte
}
tests := []struct {
name string
args args
expectError bool
want *State
}{
{
name: "power off",
args: args{[]byte{0x55, 0x52, 0x66, 0x0, 0x59, 0x2, 0x96, 0x0, 0x5, 0xb, 0x14, 0x32, 0x19, 0x19, 0x19, 0x19, 0x59, 0x2, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x3}},
want: &State{
CurrentTemperature: 102,
TargetTemperature: 150,
Probe1Temperature: 601,
Probe1TargetTemperature: 0,
Probe2Temperature: 601,
Probe2TargetTemperature: 0,
CurveRemainTime: [3]int{1193046, 28, 15},
WarnCode: WarnCodeNone,
PowerState: PowerStateOff,
FireState: FireStateOff,
APIVersion: 5,
},
},
{
name: "power on cold smoke",
args: args{[]byte{0x55, 0x52, 0x66, 0x0, 0x59, 0x2, 0x1e, 0x0, 0x5, 0xb, 0x14, 0x32, 0x19, 0x19, 0x19, 0x19, 0x59, 0x2, 0xfa, 0x0, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x96, 0x0, 0x3, 0x0, 0xc6, 0x0, 0x0, 0x3}},
want: &State{
CurrentTemperature: 102,
TargetTemperature: 30,
Probe1Temperature: 601,
Probe1TargetTemperature: 150,
Probe2Temperature: 601,
Probe2TargetTemperature: 250,
CurveRemainTime: [3]int{1193046, 28, 15},
WarnCode: WarnCodeNone,
PowerState: PowerStateColdSmoke,
FireState: FireStateColdSmoke,
APIVersion: 5,
},
},
{
name: "error: unexpected EOF",
expectError: true,
args: args{[]byte{0x55, 0x52}},
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := BytesToState(tt.args.response)
if err != nil && !tt.expectError {
t.Errorf("BytesToState() returned an error: %v", err)
}
if !tt.expectError && !reflect.DeepEqual(got, tt.want) {
t.Errorf("BytesToState() = %v, want %v", got, tt.want)
}
})
}
}