package policy import "testing" func TestMatchAddress(t *testing.T) { wl := []string{"bob@example.com", "@trusted.com"} cases := []struct { addr string want bool }{ {"bob@example.com", true}, {"BOB@Example.com", true}, {`"Bob" `, true}, {"alice@trusted.com", true}, {"alice@untrusted.com", false}, {"eve@example.com", false}, {"", false}, } for _, c := range cases { if got := MatchAddress(wl, c.addr); got != c.want { t.Fatalf("MatchAddress(%q)=%v want %v", c.addr, got, c.want) } } } func TestNormalizeAddr(t *testing.T) { if got := NormalizeAddr(`"Bob Smith" `); got != "bob@example.com" { t.Fatalf("got %q", got) } }