You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-algorithms/binaryTree/binaryTree_test.go

31 lines
500 B
Go

package binaryTree
import "testing"
func compare(x interface{}, y interface{}) bool {
if x.(int) < y.(int) {
return true
} else {
return false
}
}
func Test_binaryTree(t *testing.T) {
tree := New(compare)
tree.Insert(1)
tree.Insert(2)
tree.Insert(3)
findTree := tree.Search(2)
if findTree.node != 2 {
t.Error("[Error] Search error")
}
findNilTree := tree.Search(100)
if findNilTree != nil {
t.Error("[Error] 2. Search erro")
}
}