add tests for power management

This commit is contained in:
soypat
2023-05-22 23:04:26 -03:00
parent 048f89366f
commit 87658d8b62
6 changed files with 181 additions and 34 deletions
+21
View File
@@ -58,3 +58,24 @@ func TestTimeOnAir(t *testing.T) {
})
}
}
func TestTemperature(t *testing.T) {
for _, cs := range []struct {
tempVal uint8
expect uint8
celsius int
}{
{tempVal: 63, expect: 0, celsius: -40},
{tempVal: 33, expect: 36, celsius: -15},
{tempVal: 0, expect: 100, celsius: 15},
{tempVal: 245, expect: 128, celsius: 10},
{tempVal: 211, expect: 220, celsius: 55},
{tempVal: 181, expect: 255, celsius: 85},
} {
val := cs.tempVal
val -= 64
val = uint8(255 - 14*uint16(val)/8)
// val += 128
t.Errorf("regTemp=%d val=%d expect=%d celsius=%d", cs.tempVal, val, cs.expect, cs.celsius)
}
}