6
6
types "github.com/rishitc/go-kd-tree/internal/types"
7
7
)
8
8
9
- func Test2DDeleteAllNodesInTree (t * testing.T ) {
9
+ func Test2DRemoveAllNodesInTree (t * testing.T ) {
10
10
treeNodes := NewKDNode (types.Tensor2D {5 , 6 })
11
11
tree := NewTestKDTree (2 , treeNodes )
12
12
@@ -20,15 +20,15 @@ func Test2DDeleteAllNodesInTree(t *testing.T) {
20
20
},
21
21
}
22
22
for _ , v := range testTable {
23
- ok := tree .Delete (v .input )
23
+ ok := tree .Remove (v .input )
24
24
if ! ok || ! IdenticalTrees (tree , v .expected ) {
25
25
t .Fatalf ("Tree does not match expected tree structure\n Expected:\n %s\n Got:\n %s" , v .expected , tree )
26
26
}
27
27
}
28
28
}
29
29
30
30
// https://youtu.be/DkBNF98MV1Q?si=YhQLGxiH7BbG9D8s&t=37
31
- func Test2DDeleteLeafNode (t * testing.T ) {
31
+ func Test2DRemoveLeafNode (t * testing.T ) {
32
32
treeNodes := NewKDNode (types.Tensor2D {25 , 50 }).
33
33
SetLeft (
34
34
NewKDNode (types.Tensor2D {3 , 25 }),
@@ -58,15 +58,15 @@ func Test2DDeleteLeafNode(t *testing.T) {
58
58
},
59
59
}
60
60
for _ , v := range testTable {
61
- ok := tree .Delete (v .input )
61
+ ok := tree .Remove (v .input )
62
62
if ! ok || ! IdenticalTrees (tree , v .expected ) {
63
63
t .Fatalf ("Tree does not match expected tree structure\n Expected:\n %s\n Got:\n %s" , v .expected , tree )
64
64
}
65
65
}
66
66
}
67
67
68
68
// https://youtu.be/DkBNF98MV1Q?si=-tQZZtNASyMXnhNc&t=90
69
- func Test2DDeleteNodeWithRightSubtree (t * testing.T ) {
69
+ func Test2DRemoveNodeWithRightSubtree (t * testing.T ) {
70
70
treeNodes := NewKDNode (types.Tensor2D {25 , 50 }).
71
71
SetLeft (
72
72
NewKDNode (types.Tensor2D {3 , 25 }).
@@ -108,15 +108,15 @@ func Test2DDeleteNodeWithRightSubtree(t *testing.T) {
108
108
},
109
109
}
110
110
for _ , v := range testTable {
111
- ok := tree .Delete (v .input )
111
+ ok := tree .Remove (v .input )
112
112
if ! ok || ! IdenticalTrees (tree , v .expected ) {
113
113
t .Fatalf ("Tree does not match expected tree structure\n Expected:\n %s\n Got:\n %s" , v .expected , tree )
114
114
}
115
115
}
116
116
}
117
117
118
118
// https://youtu.be/DkBNF98MV1Q?si=v-TuZNV9YiTmCOFg&t=189
119
- func Test2DDeleteNodeWithLeftSubtreeOnly (t * testing.T ) {
119
+ func Test2DRemoveNodeWithLeftSubtreeOnly (t * testing.T ) {
120
120
treeNodes := NewKDNode (types.Tensor2D {25 , 50 }).
121
121
SetLeft (
122
122
NewKDNode (types.Tensor2D {3 , 25 }).
@@ -158,14 +158,14 @@ func Test2DDeleteNodeWithLeftSubtreeOnly(t *testing.T) {
158
158
},
159
159
}
160
160
for _ , v := range testTable {
161
- ok := tree .Delete (v .input )
161
+ ok := tree .Remove (v .input )
162
162
if ! ok || ! IdenticalTrees (tree , v .expected ) {
163
163
t .Fatalf ("Tree does not match expected tree structure\n Expected:\n %s\n Got:\n %s" , v .expected , tree )
164
164
}
165
165
}
166
166
}
167
167
168
- func Test2DDeleteNode1 (t * testing.T ) {
168
+ func Test2DRemoveNode1 (t * testing.T ) {
169
169
const dimensions = 2
170
170
ps := []types.Tensor2D {
171
171
{5 , 6 },
@@ -185,13 +185,13 @@ func Test2DDeleteNode1(t *testing.T) {
185
185
},
186
186
}
187
187
for _ , v := range testTable {
188
- ok := tree .Delete (v .input )
188
+ ok := tree .Remove (v .input )
189
189
if ! ok || ! IdenticalTrees (tree , v .expected ) {
190
190
t .Fatalf ("Tree does not match expected tree structure\n Expected:\n %s\n Got:\n %s" , v .expected , tree )
191
191
}
192
192
}
193
193
}
194
- func Test2DDeleteNode2 (t * testing.T ) {
194
+ func Test2DRemoveNode2 (t * testing.T ) {
195
195
treeNodes := NewKDNode (types.Tensor2D {5 , 6 }).
196
196
SetLeft (
197
197
NewKDNode (types.Tensor2D {4 , 10 }).
@@ -215,7 +215,7 @@ func Test2DDeleteNode2(t *testing.T) {
215
215
},
216
216
}
217
217
for _ , v := range testTable {
218
- ok := tree .Delete (v .input )
218
+ ok := tree .Remove (v .input )
219
219
if ! ok || ! IdenticalTrees (tree , v .expected ) {
220
220
t .Fatalf ("Tree does not match expected tree structure\n Expected:\n %s\n Got:\n %s" , v .expected , tree )
221
221
}
@@ -227,7 +227,7 @@ func Test2DDeleteNode2(t *testing.T) {
227
227
// child of node (70, 20), and not the right child of node (70, 20).
228
228
// However, the resultant tree shown in the video lecture is correct and has been used in this test case.
229
229
// The below test case, has been created using the corrected valid KD-Tree as input
230
- func Test2DDeleteNode3 (t * testing.T ) {
230
+ func Test2DRemoveNode3 (t * testing.T ) {
231
231
treeNodes := NewKDNode (types.Tensor2D {35 , 60 }).
232
232
SetLeft (
233
233
NewKDNode (types.Tensor2D {20 , 45 }).
@@ -293,7 +293,7 @@ func Test2DDeleteNode3(t *testing.T) {
293
293
},
294
294
}
295
295
for _ , v := range testTable {
296
- ok := tree .Delete (v .input )
296
+ ok := tree .Remove (v .input )
297
297
if ! ok || ! IdenticalTrees (tree , v .expected ) {
298
298
t .Fatalf ("Tree does not match expected tree structure\n Expected:\n %s\n Got:\n %s" , v .expected , tree )
299
299
}
0 commit comments