Skip to content

Commit c57eef5

Browse files
committed
Merge pull request #24 from bcwaldon/set-remove
feat(set): Implement set.Remove
2 parents eac79bc + 72838f0 commit c57eef5

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

dbus/set.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ func (s *set) Add(value string) {
88
s.data[value] = true
99
}
1010

11+
func (s *set) Remove(value string) {
12+
delete(s.data, value)
13+
}
14+
1115
func (s *set) Contains(value string) (exists bool) {
1216
_, exists = s.data[value]
1317
return

dbus/set_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package dbus
2+
3+
import (
4+
"testing"
5+
)
6+
7+
// TestBasicSetActions asserts that Add & Remove behavior is correct
8+
func TestBasicSetActions(t *testing.T) {
9+
s := set{}
10+
11+
if s.Contains("foo") {
12+
t.Fatal("set should not contain 'foo'")
13+
}
14+
15+
s.Add("foo")
16+
17+
if !s.Contains("foo") {
18+
t.Fatal("set should contain 'foo'")
19+
}
20+
21+
s.Remove("foo")
22+
23+
if s.Contains("foo") {
24+
t.Fatal("set should not contain 'foo'")
25+
}
26+
}

0 commit comments

Comments
 (0)