(t *testing.T)
| 126 | } |
| 127 | |
| 128 | func TestRB(t *testing.T) { |
| 129 | tree = bt.NewRB[int]() |
| 130 | |
| 131 | if tree.Empty() { |
| 132 | t.Log("RB Tree is empty now.") |
| 133 | } |
| 134 | |
| 135 | tree.Push(1, 4, 10) |
| 136 | tree.Push(-8) |
| 137 | nums := []int{87, 18, 10, -34} |
| 138 | tree.Push(nums...) |
| 139 | tree.Push(4) // duplicate key, dismiss it |
| 140 | |
| 141 | if tree.Has(4) { |
| 142 | t.Logf("There is a node of 4") |
| 143 | } |
| 144 | |
| 145 | if n, ok := tree.Get(10); ok { |
| 146 | t.Logf("node of 10: %T", n) |
| 147 | } |
| 148 | |
| 149 | if ret, ok := tree.Min(); ok { |
| 150 | t.Logf("tree.Min() = %v", ret) |
| 151 | } |
| 152 | |
| 153 | if ret, ok := tree.Max(); ok { |
| 154 | t.Logf("tree.Max() = %v", ret) |
| 155 | } |
| 156 | |
| 157 | if ret, ok := tree.Predecessor(1); ok { |
| 158 | t.Logf("tree.Preducessor(1) = %v", ret) |
| 159 | } |
| 160 | |
| 161 | if ret, ok := tree.Successor(18); ok { |
| 162 | t.Logf("tree.Successor(18) = %v", ret) |
| 163 | } |
| 164 | |
| 165 | fmt.Println(tree.InOrder()) |
| 166 | fmt.Println(tree.AccessNodesByLayer()) |
| 167 | } |
nothing calls this directly
no test coverage detected