package inflation import ( "testing" ) // This is your first Go test file! // Run with: go test ./internal/inflation/... // Go's testing package is built-in — no extra library needed. func TestMatcher_ExactMatch(t *testing.T) { m := NewMatcher() tests := []struct { raw string expected string }{ {"whole milk gallon", "milk_whole_1gal"}, {"large eggs 12ct", "eggs_large_dozen"}, {"white bread", "bread_white_loaf"}, {"ground beef", "ground_beef_1lb"}, } for _, tt := range tests { t.Run(tt.raw, func(t *testing.T) { got := m.Match(tt.raw) if got != tt.expected { t.Errorf("Match(%q) = %q, want %q", tt.raw, got, tt.expected) } }) } } func TestMatcher_CaseInsensitive(t *testing.T) { m := NewMatcher() got := m.Match("WHOLE MILK GALLON") if got != "milk_whole_1gal" { t.Errorf("expected milk_whole_1gal, got %q", got) } } func TestMatcher_TokenOverlap(t *testing.T) { m := NewMatcher() // "MILK WHL 1 GAL" should still match via token overlap got := m.Match("MILK WHL 1 GAL") if got != "milk_whole_1gal" { t.Logf("Note: token overlap match returned %q (may need alias tuning)", got) } } func TestMatcher_NoMatch(t *testing.T) { m := NewMatcher() got := m.Match("toilet paper mega roll 12ct") if got != "" { t.Errorf("expected no match, got %q", got) } } func TestNormalize(t *testing.T) { tests := []struct { input string expected string }{ {"Whole Milk, 1 Gal.", "whole milk 1 gal"}, {"EGGS (LARGE) 12CT", "eggs large 12ct"}, {"80/20 Ground Beef", "80/20 ground beef"}, } for _, tt := range tests { got := normalize(tt.input) if got != tt.expected { t.Errorf("normalize(%q) = %q, want %q", tt.input, got, tt.expected) } } }