mirror of https://github.com/emirpasic/gods
- red-black tree tests
parent
e7a7e55a47
commit
a4ce69b5af
@ -0,0 +1,32 @@
|
||||
package redblacktree
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPut(t *testing.T) {
|
||||
|
||||
tree := NewWithIntComparator()
|
||||
|
||||
tree.Put(3, "c")
|
||||
tree.Put(4, "d")
|
||||
tree.Put(1, "x")
|
||||
tree.Put(2, "b")
|
||||
tree.Put(1, "a")
|
||||
|
||||
// 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])
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue