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

Function TestTreeInOrder

structure/tree/tree_test.go:109–138  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestTreeInOrder(t *testing.T) {
110 lens := []int{100, 1_000, 10_000, 100_000}
111 for _, ll := range lens {
112 nums := rand.Perm(ll)
113
114 t.Run("Test Binary Search Tree", func(t *testing.T) {
115 bsTree := bt.NewBinarySearch[int]()
116 bsTree.Push(nums...)
117 if ret := bsTree.InOrder(); !sort.IntsAreSorted(ret) {
118 t.Errorf("Error with InOrder")
119 }
120 })
121
122 t.Run("Test Red-Black Tree", func(t *testing.T) {
123 rbTree := bt.NewRB[int]()
124 rbTree.Push(nums...)
125 if ret := rbTree.InOrder(); !sort.IntsAreSorted(ret) {
126 t.Errorf("Error with InOrder")
127 }
128 })
129
130 t.Run("Test AVL Tree", func(t *testing.T) {
131 avlTree := bt.NewAVL[int]()
132 avlTree.Push(nums...)
133 if ret := avlTree.InOrder(); !sort.IntsAreSorted(ret) {
134 t.Errorf("Error with InOrder")
135 }
136 })
137 }
138}
139
140func TestTreePostOrder(t *testing.T) {
141 t.Run("Test for Binary-Search Tree", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

PushMethod · 0.65
InOrderMethod · 0.65

Tested by

no test coverage detected