package main import ( "testing" ) func TestDomainMask(t *testing.T) { testCases := []struct { in, out string }{ {"192.0.2.1", "192.0.2.*"}, {"gateway/ip.192.0.2.1", "*.192.0.2.1"}, {"example.com", "example.com"}, {"www.example.com", "*.example.com"}, {"2001:db8::1", "2001:db8::*"}, {"cloaked/user", "cloaked/user"}, } for _, tc := range testCases { t.Run(tc.in, func(t *testing.T) { out := domainMask(tc.in) if out != tc.out { t.Errorf("got %v; want %v", out, tc.out) } }) } } func TestMask(t *testing.T) { testCases := []struct { in, out string }{ {"~test@gateway/web/freenode/ip.192.0.2.1", "*!*test@*.192.0.2.1"}, {"~test@192.0.2.1", "*!*test@192.0.2.*"}, {"test@192.0.2.1", "*!*test@192.0.2.*"}, {"bogus", "*!*bogus"}, } for _, tc := range testCases { t.Run(tc.in, func(t *testing.T) { out := mask(tc.in) if out != tc.out { t.Errorf("got %v; want %v", out, tc.out) } }) } }