| 10 | ) |
| 11 | |
| 12 | func 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 | |
| 36 | func TestDelete(t *testing.T) { |
| 37 | t.Run("Delete a node with no child", func(t *testing.T) { |