package main import ( "testing" "completed/internal/model" ) func TestGameTableSize(t *testing.T) { games := []model.Game{{Name: "Doom"}, {Name: "Half-Life"}} rows, cols := gameTableSize(games) if rows != 3 { t.Errorf("rows = %d, want 3 (header + 2 games)", rows) } if cols != len(gameColumns) { t.Errorf("cols = %d, want %d", cols, len(gameColumns)) } } func TestGameTableSizeEmpty(t *testing.T) { rows, _ := gameTableSize(nil) if rows != 1 { t.Errorf("rows = %d, want 1 (header only)", rows) } } func TestGameCellTextHeader(t *testing.T) { for col, want := range gameColumns { if got := gameCellText(nil, 0, col); got != want { t.Errorf("gameCellText(nil, 0, %d) = %q, want %q", col, got, want) } } } func TestGameCellTextDataRows(t *testing.T) { games := []model.Game{ {Name: "Doom", PlatformName: "PC", Score: 95, ReleaseDate: "1993-12-10"}, {Name: "Half-Life", PlatformName: "PC", Score: 96, ReleaseDate: "1998-11-19", Finished: "1999-01-01"}, } tests := []struct { row, col int want string }{ {1, 0, "Doom"}, {1, 1, "PC"}, {1, 2, "95"}, {1, 3, "1993-12-10"}, {1, 4, ""}, {2, 0, "Half-Life"}, {2, 4, "✓"}, } for _, tt := range tests { if got := gameCellText(games, tt.row, tt.col); got != tt.want { t.Errorf("gameCellText(games, %d, %d) = %q, want %q", tt.row, tt.col, got, tt.want) } } }