-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy paththreshold_test.go
More file actions
87 lines (85 loc) · 1.21 KB
/
threshold_test.go
File metadata and controls
87 lines (85 loc) · 1.21 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import "testing"
func TestThresholds_GetDutyCycleFromTemperature(t1 *testing.T) {
ps := []Threshold{
{
Temperature: 50,
DutyCycle: 50,
},
{
Temperature: 70,
DutyCycle: 70,
},
{
Temperature: 80,
DutyCycle: 80,
},
{
Temperature: 90,
DutyCycle: 100,
},
}
type fields struct {
points []Threshold
}
type args struct {
temp int
}
tests := []struct {
name string
fields fields
args args
want int
}{
{
name: "low",
fields: fields{
points: ps,
},
args: args{
temp: 49,
},
want: 50,
},
{
name: "middle",
fields: fields{
points: ps,
},
args: args{
temp: 71,
},
want: 70,
},
{
name: "high",
fields: fields{
points: ps,
},
args: args{
temp: 95,
},
want: 100,
},
{
name: "highest",
fields: fields{
points: ps,
},
args: args{
temp: 101,
},
want: 100,
},
}
for _, tt := range tests {
t1.Run(tt.name, func(t1 *testing.T) {
t := &Thresholds{
points: tt.fields.points,
}
if got := t.GetDutyCycleFromTemperature(tt.args.temp); got != tt.want {
t1.Errorf("GetDutyCycleFromTemperature() = %v, want %v", got, tt.want)
}
})
}
}