diff options
| author | chrislu <chris.lu@gmail.com> | 2022-02-27 03:41:32 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-02-27 03:41:32 -0800 |
| commit | d602d68fd1cd50c0780c6b07cf3c782f7faf91ab (patch) | |
| tree | 678a0c0fc6d2406c105152f21f3efda4b0ac64be /weed/util/bounded_tree/bounded_tree_test.go | |
| parent | 706a86077d9b646d9d9c8f012eba61fa7656dec6 (diff) | |
| download | seaweedfs-d602d68fd1cd50c0780c6b07cf3c782f7faf91ab.tar.xz seaweedfs-d602d68fd1cd50c0780c6b07cf3c782f7faf91ab.zip | |
remove dead code
Diffstat (limited to 'weed/util/bounded_tree/bounded_tree_test.go')
| -rw-r--r-- | weed/util/bounded_tree/bounded_tree_test.go | 126 |
1 files changed, 0 insertions, 126 deletions
diff --git a/weed/util/bounded_tree/bounded_tree_test.go b/weed/util/bounded_tree/bounded_tree_test.go deleted file mode 100644 index 465f1cc9c..000000000 --- a/weed/util/bounded_tree/bounded_tree_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package bounded_tree - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/chrislusf/seaweedfs/weed/util" -) - -var ( - visitFn = func(path util.FullPath) (childDirectories []string, err error) { - fmt.Printf(" visit %v ...\n", path) - switch path { - case "/": - return []string{"a", "g", "h"}, nil - case "/a": - return []string{"b", "f"}, nil - case "/a/b": - return []string{"c", "e"}, nil - case "/a/b/c": - return []string{"d"}, nil - case "/a/b/c/d": - return []string{"i", "j"}, nil - case "/a/b/c/d/i": - return []string{}, nil - case "/a/b/c/d/j": - return []string{}, nil - case "/a/b/e": - return []string{}, nil - case "/a/f": - return []string{}, nil - } - return nil, nil - } - - printMap = func(m map[string]*Node) { - for k := range m { - println(" >", k) - } - } -) - -func TestBoundedTree(t *testing.T) { - - // a/b/c/d/i - // a/b/c/d/j - // a/b/c/d - // a/b/e - // a/f - // g - // h - - tree := NewBoundedTree(util.FullPath("/")) - - 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) - - a := tree.root.getChild("a") - - b := a.getChild("b") - if !b.isVisited() { - t.Errorf("expect visited /a/b") - } - c := b.getChild("c") - if !c.isVisited() { - t.Errorf("expect visited /a/b/c") - } - - d := c.getChild("d") - if d.isVisited() { - t.Errorf("expect unvisited /a/b/c/d") - } - - tree.EnsureVisited(util.FullPath("/a/b/c/d"), visitFn) - tree.EnsureVisited(util.FullPath("/a/b/c/d/i"), visitFn) - tree.EnsureVisited(util.FullPath("/a/b/c/d/j"), visitFn) - tree.EnsureVisited(util.FullPath("/a/b/e"), visitFn) - tree.EnsureVisited(util.FullPath("/a/f"), visitFn) - - printMap(tree.root.Children) - -} - -func TestEmptyBoundedTree(t *testing.T) { - - // g - // h - - tree := NewBoundedTree(util.FullPath("/")) - - visitFn := func(path util.FullPath) (childDirectories []string, err error) { - fmt.Printf(" visit %v ...\n", path) - switch path { - case "/": - return []string{"g", "h"}, nil - } - t.Fatalf("expected visit %s", path) - return nil, nil - } - - tree.EnsureVisited(util.FullPath("/a/b"), visitFn) - - tree.EnsureVisited(util.FullPath("/a/b"), visitFn) - - printMap(tree.root.Children) - - assert.Equal(t, true, tree.HasVisited(util.FullPath("/a/b"))) - assert.Equal(t, true, tree.HasVisited(util.FullPath("/a"))) - assert.Equal(t, false, tree.HasVisited(util.FullPath("/g"))) - assert.Equal(t, false, tree.HasVisited(util.FullPath("/g/x"))) - -} |
