(t *testing.T)
| 133 | } |
| 134 | |
| 135 | func TestIntervalTree_Balance(t *testing.T) { |
| 136 | tree := NewIntervalTree() |
| 137 | |
| 138 | // Insert many intervals in sorted order (worst case for naive BST) |
| 139 | for i := int64(0); i < 100; i++ { |
| 140 | tree.Insert(makeTestInterval(i*10, i*10+5)) |
| 141 | } |
| 142 | |
| 143 | if tree.Size() != 100 { |
| 144 | t.Errorf("Expected size 100, got %d", tree.Size()) |
| 145 | } |
| 146 | |
| 147 | // Tree should be balanced, so root height should be O(log n) |
| 148 | // For 100 elements, height should be around 7-8 (log2(100) ≈ 6.6) |
| 149 | if tree.root == nil { |
| 150 | t.Fatal("Root should not be nil") |
| 151 | } |
| 152 | if tree.root.height > 10 { |
| 153 | t.Errorf("Tree appears unbalanced: height %d for 100 elements", tree.root.height) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func TestIntervalTree_All(t *testing.T) { |
| 158 | tree := NewIntervalTree() |
nothing calls this directly
no test coverage detected