MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / TestRBTreePush

Function TestRBTreePush

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

Source from the content-addressed store, hash-verified

10)
11
12func 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
48func TestRBTreeDelete(t *testing.T) {
49 tree := bt.NewRB[int]()

Callers

nothing calls this directly

Calls 4

InOrderMethod · 0.65
MinMethod · 0.65
MaxMethod · 0.65
PushMethod · 0.65

Tested by

no test coverage detected