package scan import "testing" func TestRoleSimilar_TruePositives(t *testing.T) { cases := [][2]string{ {"Senior Red Team Operator", "Red Team Operator"}, {"Staff Penetration Tester", "Senior Pen Tester"}, // prefix match pen→penetration {"Security Engineer, Tokyo", "Senior Security Engineer"}, // location + seniority stripped {"Principal ICS Security Consultant", "ICS Security Engineer"}, } for _, c := range cases { if !RoleSimilar(c[0], c[1]) { t.Errorf("expected similar: %q vs %q", c[0], c[1]) } } } func TestRoleSimilar_TrueNegatives(t *testing.T) { cases := [][2]string{ {"Red Team Operator", "Data Engineer"}, {"Security Engineer", "Accounting Analyst"}, {"Head of Engineering", "Head of Marketing"}, // both reduce to [marketing] vs [] after stopwords {"Senior Engineer", "Principal Engineer"}, // both reduce to empty after stopwords } for _, c := range cases { if RoleSimilar(c[0], c[1]) { t.Errorf("expected not similar: %q vs %q", c[0], c[1]) } } } func TestRoleSimilar_EmptyInputs(t *testing.T) { if RoleSimilar("", "") { t.Fatal("empty inputs must not match") } if RoleSimilar("Senior", "Engineer") { t.Fatal("all-stopword inputs must not match") } } func TestTokenizeRole_StripsCorrectly(t *testing.T) { got := tokenizeRole("Senior Red Team Operator, Tokyo (Remote)") // senior, tokyo, remote, engineer stopwords stripped; too-short (≤2) stripped. want := map[string]bool{"red": true, "team": true, "operator": true} if len(got) != len(want) { t.Fatalf("got %v want keys %v", got, want) } for _, w := range got { if !want[w] { t.Errorf("unexpected token %q", w) } } }