-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands_test.go
50 lines (48 loc) · 944 Bytes
/
commands_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
package gmg
import (
"reflect"
"testing"
)
func TestCommand_Build(t *testing.T) {
type args struct {
args []interface{}
}
tests := []struct {
name string
c Command
args args
want []byte
}{
{
name: "Set temp formats properly",
c: CommandSetGrillTemp,
args: args{[]interface{}{150}},
want: []byte("UT150!"),
},
{
name: "Int pads with 0",
c: CommandSetGrillTemp,
args: args{[]interface{}{20}},
want: []byte("UT020!"),
},
{
name: "Int pads with 00",
c: CommandSetGrillTemp,
args: args{[]interface{}{2}},
want: []byte("UT002!"),
},
{
name: "Command without args",
c: CommandPowerOn,
args: args{[]interface{}{}},
want: []byte("UK001!"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.c.Build(tt.args.args...); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Build() = %v, want %v", got, tt.want)
}
})
}
}