Files
car-radio/car-radio/testing/clock_test.go
T
2026-10-27 21:15:24 -05:00

28 lines
668 B
Go

package fdim
import (
"testing"
"time"
)
func TestClockFrame(t *testing.T) {
cases := []struct {
hour, min int
h24 bool
wantH, wantM uint8
}{
{18, 45, false, 0x06, 0x45},
{18, 45, true, 0x18, 0x45},
{0, 5, false, 0x12, 0x05},
{0, 5, true, 0x00, 0x05},
{12, 59, false, 0x12, 0x59},
{9, 30, false, 0x09, 0x30},
}
for _, c := range cases {
f := ClockFrame(time.Date(2026, 10, 21, c.hour, c.min, 0, 0, time.Local), c.h24)
if f.ID != ClockID || f.Data[0] != c.wantH || f.Data[1] != c.wantM || f.Data[5] != 0xF0 {
t.Errorf("%02d:%02d h24=%v: got % X, want %02X %02X ...", c.hour, c.min, c.h24, f.Data, c.wantH, c.wantM)
}
}
}