MCPcopy
hub / github.com/google/mangle / TestIntervalTree_Rebuild

Function TestIntervalTree_Rebuild

factstore/interval_tree_test.go:198–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

196}
197
198func TestIntervalTree_Rebuild(t *testing.T) {
199 tree := NewIntervalTree()
200
201 // Initial intervals
202 tree.Insert(makeTestInterval(100, 200))
203 tree.Insert(makeTestInterval(50, 75))
204
205 // Rebuild with different intervals
206 newIntervals := []ast.Interval{
207 makeTestInterval(300, 400),
208 makeTestInterval(500, 600),
209 makeTestInterval(700, 800),
210 }
211
212 tree.Rebuild(newIntervals)
213
214 if tree.Size() != 3 {
215 t.Errorf("Expected size 3 after rebuild, got %d", tree.Size())
216 }
217
218 // Old intervals should be gone
219 count := 0
220 tree.QueryPoint(100, func(interval ast.Interval) error {
221 count++
222 return nil
223 })
224 if count != 0 {
225 t.Error("Old interval should not be found after rebuild")
226 }
227
228 // New intervals should be present
229 count = 0
230 tree.QueryPoint(350, func(interval ast.Interval) error {
231 count++
232 return nil
233 })
234 if count != 1 {
235 t.Error("New interval should be found after rebuild")
236 }
237}
238
239func TestIntervalTree_EternalInterval(t *testing.T) {
240 tree := NewIntervalTree()

Callers

nothing calls this directly

Calls 7

InsertMethod · 0.95
RebuildMethod · 0.95
SizeMethod · 0.95
QueryPointMethod · 0.95
NewIntervalTreeFunction · 0.85
makeTestIntervalFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected