You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
538 B
30 lines
538 B
package tests
|
|
|
|
import (
|
|
"testing"
|
|
"github.com/stretchr/testify/assert"
|
|
"MY/dsa/tst"
|
|
)
|
|
|
|
func TestTernarySearchTree(t *testing.T) {
|
|
tree := tst.TST{}
|
|
|
|
tree.Add("hello", 100)
|
|
|
|
hello := tree.Get("hello")
|
|
assert.Equal(t, 100, hello)
|
|
|
|
tree.Add("howdy", 200)
|
|
howdy := tree.Get("howdy")
|
|
assert.Equal(t, 200, howdy)
|
|
|
|
nope := tree.Get("nope")
|
|
assert.Equal(t, nil, nope)
|
|
|
|
tree.Delete("howdy")
|
|
howdy = tree.Get("howdy")
|
|
assert.Equal(t, nil, howdy)
|
|
|
|
maybe := tree.StartsWith("ho")
|
|
assert.Equal(t, 200, maybe.Value)
|
|
}
|
|
|