|
84 | 84 | @test length(collect(intersects_with(tree, SI.Rect((0.0, 0.0), (0.6, 0.6))))) == 2 |
85 | 85 | @test length(collect(contained_in(tree, SI.Rect((0.0, 0.0), (0.55, 0.55))))) == 1 # a only |
86 | 86 | @test length(collect(intersects_with(tree, SI.Rect((0.0, 0.0), (0.55, 0.55))))) == 2 # a and c |
| 87 | + |
| 88 | + @testset "findfirst()" begin |
| 89 | + @test findfirst(tree, ambr, 2) === nothing |
| 90 | + @test_throws MethodError findfirst(tree, ambr, "1") # wrong key type |
| 91 | + @test_throws MethodError findfirst(tree, SI.empty(SI.Rect{Int,2}())) |
| 92 | + @test findfirst(tree, ambr, 1) == (tree.root, 2) |
| 93 | + @test findfirst(tree, ambr) == (tree.root, 2) # search without id ignores it |
| 94 | + @test findfirst(tree, bmbr, 1) === nothing |
| 95 | + @test findfirst(tree, bmbr, 2) == (tree.root, 1) |
| 96 | + @test findfirst(tree, bmbr) == (tree.root, 1) |
| 97 | + @test findfirst(tree, cmbr, 2) === nothing |
| 98 | + @test findfirst(tree, cmbr, 3) == (tree.root, 3) |
| 99 | + @test findfirst(tree, cmbr) == (tree.root, 3) |
| 100 | + @test findfirst(tree, SI.combine(ambr, cmbr)) === nothing |
| 101 | + @test findfirst(tree, SI.empty(SI.mbrtype(tree))) === nothing |
| 102 | + end |
87 | 103 | end |
88 | 104 |
|
89 | 105 | @testset "RTree{Int,3,String,Nothing}(variant=$tree_var) (no id)" for tree_var in tree_vars |
|
130 | 146 | @test delete!(tree, bmbr) === tree |
131 | 147 | @test length(tree) == 1 |
132 | 148 | @test SI.check(tree) |
| 149 | + @test insert!(tree, bmbr, "4") === tree |
| 150 | + @test length(tree) == 2 |
| 151 | + @test SI.check(tree) |
| 152 | + |
| 153 | + @testset "findfirst()" begin |
| 154 | + @test_throws MethodError findfirst(tree, ambr, 2) # no key |
| 155 | + @test_throws MethodError findfirst(tree, ambr, "1") |
| 156 | + @test_throws MethodError findfirst(tree, SI.empty(SI.Rect{Int,2}())) |
| 157 | + @test_throws MethodError findfirst(tree, SI.empty(SI.Rect{Float64,3}())) |
| 158 | + @test findfirst(tree, ambr) == (tree.root, 1) |
| 159 | + @test findfirst(tree, bmbr) == (tree.root, 2) |
| 160 | + @test findfirst(tree, SI.combine(ambr, bmbr)) === nothing |
| 161 | + @test findfirst(tree, SI.empty(SI.mbrtype(tree))) === nothing |
| 162 | + end |
133 | 163 | end |
134 | 164 | end |
135 | 165 |
|
@@ -157,10 +187,10 @@ end |
157 | 187 | #@show SI.height(tree) |
158 | 188 | #@show tree.nnodes_perlevel |
159 | 189 |
|
160 | | - @testset "findleaf" begin |
| 190 | + @testset "findfirst()" begin |
161 | 191 | # check that the elements can be found |
162 | 192 | for i in 1:length(tree) |
163 | | - node_ix = SI.findleaf(tree.root, mbrs[i], i) |
| 193 | + node_ix = findfirst(tree.root, mbrs[i], i) |
164 | 194 | @test node_ix !== nothing |
165 | 195 | if node_ix !== nothing |
166 | 196 | node, ix = node_ix |
@@ -201,10 +231,10 @@ end |
201 | 231 | @test_throws ArgumentError SI.load!(tree, enumerate(mbrs), method=:OMT, |
202 | 232 | getid = x -> x[1], getmbr = x -> x[2], getval = x -> string(x[1])) |
203 | 233 |
|
204 | | - @testset "findleaf" begin |
| 234 | + @testset "findfirst()" begin |
205 | 235 | # check that the elements can be found |
206 | 236 | for i in 1:length(tree) |
207 | | - node_ix = SI.findleaf(tree.root, mbrs[i], i) |
| 237 | + node_ix = findfirst(tree.root, mbrs[i], i) |
208 | 238 | @test node_ix !== nothing |
209 | 239 | if node_ix !== nothing |
210 | 240 | node, ix = node_ix |
|
235 | 265 | @test length(tree) == 3 |
236 | 266 | @test tree.nelem_deletions == 4 |
237 | 267 | for i in [3, 4, 7] # check that the correct points stayed in the tree |
238 | | - @test SI.findleaf(tree.root, SI.Rect(pts[i], pts[i]), i) !== nothing |
| 268 | + @test findfirst(tree.root, SI.Rect(pts[i], pts[i]), i) !== nothing |
239 | 269 | end |
240 | 270 | end |
241 | 271 |
|
|
0 commit comments