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.

isupport_test.go 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2016 Daniel Oaks <daniel@danieloaks.net>
  2. // released under the MIT license
  3. package irc
  4. import (
  5. "reflect"
  6. "testing"
  7. )
  8. func TestISUPPORT(t *testing.T) {
  9. // create first list
  10. tList1 := NewISupportList()
  11. tList1.Add("SASL", "yes")
  12. tList1.Add("CASEMAPPING", "rfc1459-strict")
  13. tList1.Add("INVEX", "i")
  14. tList1.AddNoValue("EXTBAN")
  15. tList1.Add("RANDKILL", "whenever")
  16. tList1.RegenerateCachedReply()
  17. expected := [][]string{{"CASEMAPPING=rfc1459-strict", "EXTBAN", "INVEX=i", "RANDKILL=whenever", "SASL=yes", "are supported by this server"}}
  18. if !reflect.DeepEqual(tList1.CachedReply, expected) {
  19. t.Error("tList1's cached reply does not match expected cached reply")
  20. }
  21. // create second list
  22. tList2 := NewISupportList()
  23. tList2.Add("SASL", "yes")
  24. tList2.Add("CASEMAPPING", "ascii")
  25. tList2.AddNoValue("INVEX")
  26. tList2.Add("EXTBAN", "TestBah")
  27. tList2.AddNoValue("STABLEKILL")
  28. tList2.RegenerateCachedReply()
  29. expected = [][]string{{"CASEMAPPING=ascii", "EXTBAN=TestBah", "INVEX", "SASL=yes", "STABLEKILL", "are supported by this server"}}
  30. if !reflect.DeepEqual(tList2.CachedReply, expected) {
  31. t.Error("tList2's cached reply does not match expected cached reply")
  32. }
  33. // compare lists
  34. actual := tList1.GetDifference(tList2)
  35. expected = [][]string{{"-RANDKILL", "CASEMAPPING=ascii", "EXTBAN=TestBah", "INVEX", "STABLEKILL", "are supported by this server"}}
  36. if !reflect.DeepEqual(actual, expected) {
  37. t.Error("difference reply does not match expected difference reply")
  38. }
  39. }