| 10 | ) |
| 11 | |
| 12 | func TestRBTreePush(t *testing.T) { |
| 13 | tree := bt.NewRB[int]() |
| 14 | |
| 15 | ret := tree.InOrder() |
| 16 | |
| 17 | if !sort.IntsAreSorted(ret) || len(ret) != 0 { |
| 18 | t.Errorf("Error with Push: %v", ret) |
| 19 | } |
| 20 | |
| 21 | if r, ok := tree.Min(); ok { |
| 22 | t.Errorf("Error with Min: %v", r) |
| 23 | } |
| 24 | |
| 25 | if r, ok := tree.Max(); ok { |
| 26 | t.Errorf("Error with Max: %v", r) |
| 27 | } |
| 28 | |
| 29 | nums := []int{10, 8, 88, 888, 4, 1<<63 - 1, -(1 << 62), 188, -188, 4, 1 << 32} |
| 30 | |
| 31 | tree.Push(nums...) |
| 32 | |
| 33 | ret = tree.InOrder() |
| 34 | |
| 35 | if !sort.IntsAreSorted(ret) { |
| 36 | t.Errorf("Error with Push: %v", ret) |
| 37 | } |
| 38 | |
| 39 | if r, ok := tree.Min(); !ok || ret[0] != r { |
| 40 | t.Errorf("Error with Min: %v", r) |
| 41 | } |
| 42 | |
| 43 | if r, ok := tree.Max(); !ok || ret[len(ret)-1] != r { |
| 44 | t.Errorf("Error with Max: %v", r) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestRBTreeDelete(t *testing.T) { |
| 49 | tree := bt.NewRB[int]() |