mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +01:00
37 lines
831 B
Go
37 lines
831 B
Go
|
// 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")
|
||
|
}
|
||
|
}
|