1
0
Fork 0
forked from External/ergo

refactor WhoFields to use value receivers

This commit is contained in:
Shivaram Lingamneni 2020-07-11 22:49:17 -04:00
parent bdfee9cb39
commit 97417f4c32
2 changed files with 46 additions and 14 deletions

View file

@ -56,3 +56,33 @@ func TestUserMasks(t *testing.T) {
t.Error("failure to match")
}
}
func TestWhoFields(t *testing.T) {
var w whoxFields
if w.Has('a') {
t.Error("zero value of whoxFields must be empty")
}
w = w.Add('a')
if !w.Has('a') {
t.Error("failed to set and get")
}
if w.Has('A') {
t.Error("false positive")
}
if w.Has('o') {
t.Error("false positive")
}
w = w.Add('🐬')
if w.Has('🐬') {
t.Error("should not be able to set invalid who field")
}
w = w.Add('o')
if !w.Has('o') {
t.Error("failed to set and get")
}
w = w.Add('z')
if !w.Has('z') {
t.Error("failed to set and get")
}
}