mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-07-06 09:07:08 +02:00
more test cases
This commit is contained in:
parent
55b6efb755
commit
c0283eee1a
|
@ -1,8 +1,6 @@
|
||||||
package bounded_tree
|
package bounded_tree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
)
|
)
|
||||||
|
@ -135,7 +133,7 @@ func (t *BoundedTree) HasVisited(p util.FullPath) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
components := p.Split()
|
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)
|
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
|
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) {
|
if i >= len(components) {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -62,6 +62,15 @@ func TestBoundedTree(t *testing.T) {
|
||||||
tree.EnsureVisited(util.FullPath("/a/b/c"), visitFn)
|
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")))
|
||||||
|
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)
|
printMap(tree.root.Children)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue