(t *testing.T)
| 132 | } |
| 133 | |
| 134 | func TestExprCtxColumnIDAllocator(t *testing.T) { |
| 135 | // default |
| 136 | ctx := NewExprContext() |
| 137 | alloc := ctx.columnIDAllocator |
| 138 | require.NotNil(t, alloc) |
| 139 | _, ok := ctx.columnIDAllocator.(*exprctx.SimplePlanColumnIDAllocator) |
| 140 | require.True(t, ok) |
| 141 | require.Equal(t, int64(1), ctx.AllocPlanColumnID()) |
| 142 | |
| 143 | // Apply without an allocator |
| 144 | ctx2 := ctx.Apply() |
| 145 | require.Same(t, ctx2.columnIDAllocator, ctx.columnIDAllocator) |
| 146 | require.Equal(t, int64(2), ctx2.AllocPlanColumnID()) |
| 147 | require.Equal(t, int64(3), ctx.AllocPlanColumnID()) |
| 148 | |
| 149 | // Apply with new allocator |
| 150 | alloc = exprctx.NewSimplePlanColumnIDAllocator(1024) |
| 151 | ctx3 := ctx.Apply(WithColumnIDAllocator(alloc)) |
| 152 | require.Same(t, alloc, ctx3.columnIDAllocator) |
| 153 | require.NotSame(t, ctx.columnIDAllocator, ctx3.columnIDAllocator) |
| 154 | require.Equal(t, int64(1025), ctx3.AllocPlanColumnID()) |
| 155 | require.Equal(t, int64(4), ctx.AllocPlanColumnID()) |
| 156 | |
| 157 | // New context with allocator |
| 158 | alloc = exprctx.NewSimplePlanColumnIDAllocator(2048) |
| 159 | ctx4 := NewExprContext(WithColumnIDAllocator(alloc)) |
| 160 | require.Same(t, alloc, ctx4.columnIDAllocator) |
| 161 | require.Equal(t, int64(2049), ctx4.AllocPlanColumnID()) |
| 162 | } |
| 163 | |
| 164 | func TestMakeExprContextStatic(t *testing.T) { |
| 165 | evalCtx := NewEvalContext() |
nothing calls this directly
no test coverage detected