diff --git a/dbus/set.go b/dbus/set.go index e36aaa03..88378b29 100644 --- a/dbus/set.go +++ b/dbus/set.go @@ -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 diff --git a/dbus/set_test.go b/dbus/set_test.go new file mode 100644 index 00000000..0cd3b3e6 --- /dev/null +++ b/dbus/set_test.go @@ -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'") + } +}