Skip to content

Commit e24005e

Browse files
committed
Tests for Delete and DeletePrefix
1 parent 44dad5e commit e24005e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tree_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,39 @@ var _ = Describe("Tree", func() {
5151
Ω(value).Should(BeNil())
5252
})
5353
})
54+
Context("Delete", func() {
55+
It("should_not_fail_if_empty", func() {
56+
value, ok := gorax.New().Delete("foo")
57+
Ω(ok).Should(BeFalse())
58+
Ω(value).Should(BeNil())
59+
})
60+
})
61+
Context("DeletePrefix", func() {
62+
It("should_not_fail_if_empty", func() {
63+
count := gorax.New().DeletePrefix("foo")
64+
Ω(count).Should(Equal(0))
65+
})
66+
It("should_delete_subtree", func() {
67+
t := gorax.FromMap(map[string]interface{}{
68+
"bar": 1,
69+
"foof": 2,
70+
"foofoo": 3,
71+
"foobar": 4,
72+
})
73+
count := t.DeletePrefix("foo")
74+
Ω(count).Should(Equal(3))
75+
})
76+
It("should_delete_subtree_and_prefix_itself", func() {
77+
t := gorax.FromMap(map[string]interface{}{
78+
"bar": 1,
79+
"foo": 2,
80+
"foofoo": 3,
81+
"foobar": 4,
82+
})
83+
count := t.DeletePrefix("foo")
84+
Ω(count).Should(Equal(3))
85+
})
86+
})
5487
Context("WalkPrefix", func() {
5588
var (
5689
t *gorax.Tree

0 commit comments

Comments
 (0)