1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-12 08:42:29 +08:00

test: add unit test TestBSTree_IsSubTree

This commit is contained in:
dudaodong
2022-04-27 11:36:51 +08:00
parent 0d48778886
commit 61c7012e17
3 changed files with 14 additions and 16 deletions

View File

@@ -134,24 +134,24 @@ func TestBSTree_Depth(t *testing.T) {
assert.Equal(bstree.Depth(), 4)
}
func TestBSTree_IsSubTree(t *testing.T) {
assert := internal.NewAssert(t, "TestBSTree_IsSubTree")
superTree := NewBSTree(6, &intComparator{})
superTree.InsertNode(7)
superTree := NewBSTree(8, &intComparator{})
superTree.InsertNode(4)
superTree.InsertNode(5)
superTree.InsertNode(2)
superTree.InsertNode(6)
superTree.InsertNode(9)
superTree.InsertNode(4)
superTree.Print()
subTree1 := NewBSTree(3, &intComparator{})
subTree1.InsertNode(5)
subTree1.InsertNode(2)
subTree1.InsertNode(4)
subTree := NewBSTree(5, &intComparator{})
subTree.InsertNode(4)
subTree.InsertNode(6)
assert.Equal(true, superTree)
subTree1.Print()
subTree.Print()
}
assert.Equal(true, superTree.HasSubTree(subTree))
assert.Equal(false, subTree.HasSubTree(superTree))
}