summaryrefslogtreecommitdiff
path: root/bst
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-12-01 18:35:28 +0300
committerValery Piashchynski <[email protected]>2021-12-01 18:35:28 +0300
commit005bce86625b8fffdb3657103ee5589cbb6eed87 (patch)
tree15adef89d99954a71f5c45f8748ed7e66e57d7c4 /bst
parent859a9f696f732fa58dd49427a936fd0fecc0bc7d (diff)
improve codecov
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'bst')
-rw-r--r--bst/bst_test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/bst/bst_test.go b/bst/bst_test.go
index 2271508c..2afbee10 100644
--- a/bst/bst_test.go
+++ b/bst/bst_test.go
@@ -40,6 +40,49 @@ func TestNewBST(t *testing.T) {
assert.Len(t, exist3, 100)
}
+func TestBSTContains(t *testing.T) {
+ // create a new bst
+ g := NewBST()
+
+ for i := 0; i < 100; i++ {
+ g.Insert(uuid.NewString(), "comments")
+ }
+
+ for i := 0; i < 100; i++ {
+ g.Insert(uuid.NewString(), "comments2")
+ }
+
+ for i := 0; i < 100; i++ {
+ g.Insert(uuid.NewString(), "comments3")
+ }
+
+ exist := g.Contains("comments")
+ assert.True(t, exist)
+
+ exist2 := g.Contains("comments2")
+ assert.True(t, exist2)
+
+ exist3 := g.Contains("comments3")
+ assert.True(t, exist3)
+
+ exist4 := g.Contains("comments5")
+ assert.False(t, exist4)
+
+ exist5 := g.Contains("comments6")
+ assert.False(t, exist5)
+}
+
+func TestBSTRemove(t *testing.T) {
+ // create a new bst
+ g := NewBST()
+ u := uuid.NewString()
+ g.Insert(u, "comments")
+ g.Remove(u, "comments")
+
+ res := g.Contains("comments")
+ assert.False(t, res)
+}
+
func BenchmarkGraph(b *testing.B) {
g := NewBST()