(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestIntervalTree_QueryPoint(t *testing.T) { |
| 60 | tree := NewIntervalTree() |
| 61 | |
| 62 | // Insert intervals: [100, 200], [150, 250], [50, 75], [300, 400] |
| 63 | tree.Insert(makeTestInterval(100, 200)) |
| 64 | tree.Insert(makeTestInterval(150, 250)) |
| 65 | tree.Insert(makeTestInterval(50, 75)) |
| 66 | tree.Insert(makeTestInterval(300, 400)) |
| 67 | |
| 68 | tests := []struct { |
| 69 | name string |
| 70 | timestamp int64 |
| 71 | wantCount int |
| 72 | }{ |
| 73 | {"before all", 25, 0}, |
| 74 | {"in first interval only", 60, 1}, |
| 75 | {"at start of interval", 100, 1}, |
| 76 | {"in overlapping region", 175, 2}, |
| 77 | {"at end of first interval (overlaps with second)", 200, 2}, |
| 78 | {"between intervals", 275, 0}, |
| 79 | {"in last interval", 350, 1}, |
| 80 | {"after all", 500, 0}, |
| 81 | } |
| 82 | |
| 83 | for _, tt := range tests { |
| 84 | t.Run(tt.name, func(t *testing.T) { |
| 85 | count := 0 |
| 86 | tree.QueryPoint(tt.timestamp, func(interval ast.Interval) error { |
| 87 | count++ |
| 88 | return nil |
| 89 | }) |
| 90 | if count != tt.wantCount { |
| 91 | t.Errorf("QueryPoint(%d) returned %d intervals, want %d", tt.timestamp, count, tt.wantCount) |
| 92 | } |
| 93 | }) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestIntervalTree_QueryRange(t *testing.T) { |
| 98 | tree := NewIntervalTree() |
nothing calls this directly
no test coverage detected