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.
34 lines
589 B
Go
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])
|
|
}
|
|
}
|
|
}
|