MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestBinaryExpressionPool

Function TestBinaryExpressionPool

pkg/sql/ast/ast_test.go:124–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

122}
123
124func TestBinaryExpressionPool(t *testing.T) {
125 // Test getting a BinaryExpression
126 expr1 := GetBinaryExpression()
127 if expr1 == nil {
128 t.Fatal("expected non-nil BinaryExpression")
129 }
130
131 expr1.Left = &Identifier{Name: "id"}
132 expr1.Operator = "="
133 expr1.Right = &Identifier{Name: "1"}
134
135 // Release back to pool
136 PutBinaryExpression(expr1)
137
138 // Test getting another BinaryExpression reuses the pool
139 expr2 := GetBinaryExpression()
140 if expr2 == nil {
141 t.Fatal("expected non-nil BinaryExpression")
142 }
143 if expr2.Left != nil {
144 t.Error("expected nil Left after reset")
145 }
146 if expr2.Right != nil {
147 t.Error("expected nil Right after reset")
148 }
149 if expr2.Operator != "" {
150 t.Errorf("expected empty operator after reset, got %q", expr2.Operator)
151 }
152 PutBinaryExpression(expr2)
153}
154
155func TestExpressionSlicePool(t *testing.T) {
156 // Test getting an expression slice

Callers

nothing calls this directly

Calls 4

GetBinaryExpressionFunction · 0.85
PutBinaryExpressionFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected