3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 13:29:27 +01:00

re-add nil receiver for ModeSet.HasMode

This commit is contained in:
Shivaram Lingamneni 2018-08-23 10:30:28 -04:00
parent 1fd63672f3
commit 86836905b3
2 changed files with 6 additions and 1 deletions

View File

@ -341,6 +341,10 @@ func NewModeSet() *ModeSet {
// test whether `mode` is set // test whether `mode` is set
func (set *ModeSet) HasMode(mode Mode) bool { func (set *ModeSet) HasMode(mode Mode) bool {
if set == nil {
return false
}
return utils.BitsetGet(set[:], uint(mode)-minMode) return utils.BitsetGet(set[:], uint(mode)-minMode)
} }

View File

@ -78,7 +78,8 @@ func TestSetMode(t *testing.T) {
} }
func TestNilReceivers(t *testing.T) { func TestNilReceivers(t *testing.T) {
var set ModeSet set := NewModeSet()
set = nil
if set.HasMode(Invisible) { if set.HasMode(Invisible) {
t.Errorf("nil ModeSet should not have any modes") t.Errorf("nil ModeSet should not have any modes")