3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 14:39:31 +01:00
ergo/irc/usermaskset_test.go

37 lines
831 B
Go
Raw Normal View History

2020-10-21 17:08:55 +02:00
// Copyright (c) 2020 Shivaram Lingamneni
// released under the MIT license
package irc
import (
"testing"
)
func TestUserMaskSet(t *testing.T) {
s := NewUserMaskSet()
if s.Match("horse!~evan@tor-network.onion") {
t.Errorf("empty set should not match anything")
}
s.Add("m:horse!*@*", "", "")
if s.Match("horse!~evan@tor-network.onion") {
t.Errorf("mute extbans should not Match(), only MatchMute()")
}
s.Add("*!~evan@*", "", "")
if !s.Match("horse!~evan@tor-network.onion") {
t.Errorf("expected Match() failed")
}
if s.Match("horse!~horse@tor-network.onion") {
t.Errorf("unexpected Match() succeeded")
}
if !s.MatchMute("horse!~evan@tor-network.onion") {
t.Errorf("expected MatchMute() failed")
}
if s.MatchMute("evan!~evan@tor-network.onion") {
t.Errorf("unexpected MatchMute() succeeded")
}
}