package layout import ( "testing" "printer.backend/internal/model" ) func TestPack(t *testing.T) { plate := model.Plate{ WidthMM: 300, HeightMM: 400, MarginTop: 10, MarginRight: 10, MarginBottom: 10, MarginLeft: 10, } spec := model.ItemSpec{SizeMM: 80, BleedMM: 2, MarginMM: 5} // footprint = 80+4+10 = 94, cell = 94+2 = 96 // printable 280x380 -> cols=2, rows=3 -> 6 preview := Pack(plate, spec, 2) if preview.Columns != 2 { t.Fatalf("columns: got %d want 2", preview.Columns) } if preview.Rows != 3 { t.Fatalf("rows: got %d want 3", preview.Rows) } if preview.Count != 6 { t.Fatalf("count: got %d want 6", preview.Count) } if len(preview.Positions) != 6 { t.Fatalf("positions: got %d want 6", len(preview.Positions)) } if preview.Positions[0].XMM != 10 || preview.Positions[0].YMM != 10 { t.Fatalf("first position: got (%v,%v)", preview.Positions[0].XMM, preview.Positions[0].YMM) } } func TestPackZeroCell(t *testing.T) { plate := model.Plate{WidthMM: 10, HeightMM: 10} spec := model.ItemSpec{SizeMM: 100} preview := Pack(plate, spec, 0) if preview.Count != 0 { t.Fatalf("expected 0 items, got %d", preview.Count) } }