package main import "testing" // A retired word's plural is the word; anything else joined on is another word. func TestPatternMatchesTheWordAndItsPlural(t *testing.T) { cases := []struct { word, text string want bool }{ {"control plane", "ask the control plane", true}, {"control plane", "two control planes", true}, {"control plane", "two control\n\tplanes", true}, {"substrate", "the substrates", true}, {"flavor", "flavors of a module", true}, {"flavor", "flavored", false}, {"node tools", "node toolsets", false}, {"mesh-console", "the mesh-consoles", true}, {"mesh-console", "mesh-console-x", false}, } for _, c := range cases { if got := pattern(c.word).MatchString(c.text); got != c.want { t.Errorf("pattern(%q) on %q = %v, want %v", c.word, c.text, got, c.want) } } }