3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

add some testing

This commit is contained in:
Shivaram Lingamneni 2019-05-27 16:09:09 -04:00
parent 9fe65223db
commit dee9740e68

View File

@ -77,6 +77,16 @@ func TestSetMode(t *testing.T) {
} }
} }
func TestModeString(t *testing.T) {
set := NewModeSet()
set.SetMode('A', true)
set.SetMode('z', true)
if modeString := set.String(); !(modeString == "Az" || modeString == "Za") {
t.Errorf("unexpected modestring: %s", modeString)
}
}
func TestNilReceivers(t *testing.T) { func TestNilReceivers(t *testing.T) {
set := NewModeSet() set := NewModeSet()
set = nil set = nil
@ -113,3 +123,16 @@ func TestHighestChannelUserMode(t *testing.T) {
t.Errorf("nil modeset should have the zero mode as highest channel-user mode") t.Errorf("nil modeset should have the zero mode as highest channel-user mode")
} }
} }
func BenchmarkModeString(b *testing.B) {
set := NewModeSet()
set.SetMode('A', true)
set.SetMode('N', true)
set.SetMode('b', true)
set.SetMode('i', true)
set.SetMode('x', true)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = set.String()
}
}