Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dbus/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ func (s *set) Add(value string) {
s.data[value] = true
}

func (s *set) Remove(value string) {
delete(s.data, value)
}

func (s *set) Contains(value string) (exists bool) {
_, exists = s.data[value]
return
Expand Down
26 changes: 26 additions & 0 deletions dbus/set_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dbus

import (
"testing"
)

// TestBasicSetActions asserts that Add & Remove behavior is correct
func TestBasicSetActions(t *testing.T) {
s := set{}

if s.Contains("foo") {
t.Fatal("set should not contain 'foo'")
}

s.Add("foo")

if !s.Contains("foo") {
t.Fatal("set should contain 'foo'")
}

s.Remove("foo")

if s.Contains("foo") {
t.Fatal("set should not contain 'foo'")
}
}