package config import "testing" func TestLayoutDimensions(t *testing.T) { good := map[string][2]int{"2x2": {2, 2}, "3X3": {3, 3}, " 4x2 ": {4, 2}, "1x1": {1, 1}} for grid, want := range good { l := Layout{Name: "t", Grid: grid} c, r, err := l.Dimensions() if err != nil { t.Fatalf("grid %q: unexpected error %v", grid, err) } if c != want[0] || r != want[1] { t.Errorf("grid %q: got %dx%d want %dx%d", grid, c, r, want[0], want[1]) } } for _, bad := range []string{"", "2", "2x", "x2", "0x2", "axb"} { if _, _, err := (Layout{Name: "t", Grid: bad}).Dimensions(); err == nil { t.Errorf("grid %q: expected error", bad) } } } func TestValidateRejectsUnknownCameraRef(t *testing.T) { c := &Config{ Cameras: []Camera{{Name: "front"}}, Layouts: []Layout{{Name: "l", Grid: "2x2", Slots: []string{"front", "missing", "", ""}}}, } c.Defaults() if err := c.Validate(); err == nil { t.Fatal("expected validation error for unknown camera reference") } } func TestValidateRejectsTooManySlots(t *testing.T) { c := &Config{Layouts: []Layout{{Name: "l", Grid: "1x1", Slots: []string{"", ""}}}} c.Defaults() if err := c.Validate(); err == nil { t.Fatal("expected validation error for slot overflow") } }