package main
import "testing"
func TestHighlightMatches(t *testing.T) {
cases := []struct{ name, query, want string }{
{"Project Alpha", "alpha", "Project Alpha"},
// Overlapping and adjacent spans merge.
{"Project Alpha", "pro ject", "Project Alpha"},
{"Project Alpha", "roj proj", "Project Alpha"},
{"a&c", "b", "a<b>&c"},
{"Notes", "zzz", "Notes"},
// Lowercasing changes the byte length: no highlight, still escaped.
{"İstanbul ", "stan", "İstanbul <x>"},
}
for _, c := range cases {
if got := string(highlightMatches(c.name, suggestTokens(c.query))); got != c.want {
t.Errorf("highlightMatches(%q, %q) = %q, want %q", c.name, c.query, got, c.want)
}
}
}