File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments