Skip to content

Commit f203b4c

Browse files
committed
augmentedtree: TestTraverse
1 parent fcaff5a commit f203b4c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

augmentedtree/atree_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,3 +622,20 @@ func TestInsertDuplicateIntervalChildren(t *testing.T) {
622622
result := tree.Query(constructSingleDimensionInterval(0, 10, 0))
623623
assert.Contains(t, result, iv1)
624624
}
625+
626+
func TestTraverse(t *testing.T) {
627+
tree := newTree(1)
628+
top := 30
629+
for i := 0; i <= top; i++ {
630+
tree.Add(constructSingleDimensionInterval(int64(i*10), int64((i+1)*10), uint64(i)))
631+
}
632+
found := map[uint64]bool{}
633+
tree.Traverse(func(id Interval) {
634+
found[id.ID()] = true
635+
})
636+
for i := 0; i <= top; i++ {
637+
if found, _ := found[uint64(i)]; !found {
638+
t.Errorf("could not find expected interval %d", i)
639+
}
640+
}
641+
}

0 commit comments

Comments
 (0)