MCPcopy
hub / github.com/TheAlgorithms/Go / TestPush

Function TestPush

structure/tree/bstree_test.go:12–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestPush(t *testing.T) {
13 bst := bt.NewBinarySearch[int]()
14
15 bst.Push(90)
16 bst.Push(80)
17 bst.Push(100)
18
19 if bst.Root.Key() != 90 {
20 t.Errorf("Root should have value = 90")
21 }
22
23 if bst.Root.Left().Key() != 80 {
24 t.Errorf("Left child should have value = 80")
25 }
26
27 if bst.Root.Right().Key() != 100 {
28 t.Errorf("Right child should have value = 100")
29 }
30
31 if bst.Depth() != 2 {
32 t.Errorf("tree should have depth = 1")
33 }
34}
35
36func TestDelete(t *testing.T) {
37 t.Run("Delete a node with no child", func(t *testing.T) {

Callers

nothing calls this directly

Calls 5

PushMethod · 0.65
KeyMethod · 0.65
LeftMethod · 0.65
RightMethod · 0.65
DepthMethod · 0.65

Tested by

no test coverage detected