package main import "testing" func TestMaxACols(t *testing.T) { tests := []struct { name string results []MatchResult expected int }{ { name: "uniform rows", results: []MatchResult{{RowAData: []string{"a", "b", "c"}}, {RowAData: []string{"d", "e", "f"}}}, expected: 3, }, { name: "ragged rows", results: []MatchResult{{RowAData: []string{"a"}}, {RowAData: []string{"b", "c", "d", "e"}}, {RowAData: []string{"f", "g"}}}, expected: 4, }, { name: "empty rows", results: []MatchResult{{RowAData: []string{}}, {RowAData: []string{"a"}}}, expected: 1, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := maxACols(tt.results) if got != tt.expected { t.Errorf("maxACols() = %d, want %d", got, tt.expected) } }) } } func TestCSVEscape(t *testing.T) { tests := []struct { input string expected string }{ {"hello", "hello"}, {"has,comma", `"has,comma"`}, {"has\"quote", `"has""quote"`}, {"line\nbreak", "\"line\nbreak\""}, } for _, tt := range tests { t.Run(tt.input, func(t *testing.T) { got := csvEscape(tt.input) if got != tt.expected { t.Errorf("csvEscape(%q) = %q, want %q", tt.input, got, tt.expected) } }) } }