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