2
0
mirror of https://github.com/0xAX/go-algorithms synced 2024-11-09 19:11:08 +00:00
go-algorithms/binaryTree/binaryTree_test.go
2016-03-29 00:36:48 +06:00

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")
}
}