38 lines
1018 B
Go
38 lines
1018 B
Go
package render
|
|
|
|
import (
|
|
"image/color"
|
|
"testing"
|
|
"time"
|
|
|
|
"silverpose/v2/internal/fall"
|
|
)
|
|
|
|
func TestRenderUsesCriticalBorderOnlyForConfirmed(t *testing.T) {
|
|
bgr := make([]byte, 4*3*3)
|
|
for index := range bgr {
|
|
bgr[index] = 64
|
|
}
|
|
normal, err := Render(bgr, 4, 3, fall.FrameResult{}, time.Date(2026, 7, 22, 8, 0, 0, 0, time.UTC))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
confirmed, err := Render(bgr, 4, 3, fall.FrameResult{People: []fall.PersonAnalysis{{State: fall.Confirmed}}}, time.Date(2026, 7, 22, 8, 0, 0, 0, time.UTC))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := normal.RGBAAt(0, 0); got != (color.RGBA{R: 64, G: 64, B: 64, A: 255}) {
|
|
t.Fatalf("normal border = %#v", got)
|
|
}
|
|
if got := confirmed.RGBAAt(0, 0); got != criticalColor {
|
|
t.Fatalf("confirmed border = %#v, want %#v", got, criticalColor)
|
|
}
|
|
}
|
|
|
|
func TestRenderRejectsInvalidBGRLength(t *testing.T) {
|
|
_, err := Render([]byte{1, 2, 3}, 2, 2, fall.FrameResult{}, time.Time{})
|
|
if err == nil {
|
|
t.Fatal("expected invalid frame length error")
|
|
}
|
|
}
|