gods/trees/redblacktree/redblacktree_test.go
emirpasic 855ba6d469 - red-black-tree remove
- test failing (fixing it up)
2015-03-04 20:20:48 +01:00

34 lines
589 B
Go

package redblacktree
import (
"testing"
)
func TestPutGet(t *testing.T) {
tree := NewWithIntComparator()
tree.Put(5, "e")
tree.Put(3, "c")
tree.Put(4, "d")
tree.Put(1, "x")
tree.Put(2, "b")
tree.Put(1, "a") //overwrite
// key,expectedValue,expectedFound
tests := [][]interface{}{
{1, "a", true},
{2, "b", true},
{3, "c", true},
{4, "d", true},
{5, nil, false},
}
for _, test := range tests {
actualValue, actualFound := tree.Get(test[0])
if actualValue != test[1] || actualFound != test[2] {
t.Errorf("Got %v expected %v", actualValue, test[1])
}
}
}