You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usermaskset_test.go 831B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2020 Shivaram Lingamneni
  2. // released under the MIT license
  3. package irc
  4. import (
  5. "testing"
  6. )
  7. func TestUserMaskSet(t *testing.T) {
  8. s := NewUserMaskSet()
  9. if s.Match("horse!~evan@tor-network.onion") {
  10. t.Errorf("empty set should not match anything")
  11. }
  12. s.Add("m:horse!*@*", "", "")
  13. if s.Match("horse!~evan@tor-network.onion") {
  14. t.Errorf("mute extbans should not Match(), only MatchMute()")
  15. }
  16. s.Add("*!~evan@*", "", "")
  17. if !s.Match("horse!~evan@tor-network.onion") {
  18. t.Errorf("expected Match() failed")
  19. }
  20. if s.Match("horse!~horse@tor-network.onion") {
  21. t.Errorf("unexpected Match() succeeded")
  22. }
  23. if !s.MatchMute("horse!~evan@tor-network.onion") {
  24. t.Errorf("expected MatchMute() failed")
  25. }
  26. if s.MatchMute("evan!~evan@tor-network.onion") {
  27. t.Errorf("unexpected MatchMute() succeeded")
  28. }
  29. }