more test cases

This commit is contained in:
Chris Lu 2020-06-19 09:16:14 -07:00
parent 55b6efb755
commit c0283eee1a
2 changed files with 11 additions and 4 deletions

View file

@ -1,8 +1,6 @@
package bounded_tree
import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/util"
)
@ -135,7 +133,7 @@ func (t *BoundedTree) HasVisited(p util.FullPath) bool {
}
components := p.Split()
fmt.Printf("components %v %d\n", components, len(components))
// fmt.Printf("components %v %d\n", components, len(components))
return t.hasVisited(t.root, util.FullPath("/"), components, 0)
}
@ -149,7 +147,7 @@ func (t *BoundedTree) hasVisited(n *Node, currentPath util.FullPath, components
return false
}
fmt.Printf(" hasVisited child %v %+v %d\n", currentPath, components, i)
// fmt.Printf(" hasVisited child %v %+v %d\n", currentPath, components, i)
if i >= len(components) {
return true

View file

@ -62,6 +62,15 @@ func TestBoundedTree(t *testing.T) {
tree.EnsureVisited(util.FullPath("/a/b/c"), visitFn)
assert.Equal(t, true, tree.HasVisited(util.FullPath("/a/b")))
assert.Equal(t, true, tree.HasVisited(util.FullPath("/a/b/c")))
assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/b/c/d")))
assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/b/e")))
assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/f")))
assert.Equal(t, false, tree.HasVisited(util.FullPath("/g")))
assert.Equal(t, false, tree.HasVisited(util.FullPath("/h")))
assert.Equal(t, true, tree.HasVisited(util.FullPath("/")))
assert.Equal(t, true, tree.HasVisited(util.FullPath("/x")))
assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/b/e/x")))
printMap(tree.root.Children)