(t *testing.T)
| 62 | } |
| 63 | |
| 64 | func TestSelectStatementPool(t *testing.T) { |
| 65 | // Test getting a SelectStatement |
| 66 | stmt1 := GetSelectStatement() |
| 67 | if stmt1 == nil { |
| 68 | t.Fatal("expected non-nil SelectStatement") |
| 69 | } |
| 70 | if len(stmt1.Columns) != 0 { |
| 71 | t.Errorf("expected empty columns, got %d", len(stmt1.Columns)) |
| 72 | } |
| 73 | if len(stmt1.OrderBy) != 0 { |
| 74 | t.Errorf("expected empty order by, got %d", len(stmt1.OrderBy)) |
| 75 | } |
| 76 | |
| 77 | // Add some expressions |
| 78 | stmt1.Columns = append(stmt1.Columns, &Identifier{Name: "id"}) |
| 79 | stmt1.Where = &BinaryExpression{ |
| 80 | Left: &Identifier{Name: "id"}, |
| 81 | Operator: "=", |
| 82 | Right: &Identifier{Name: "1"}, |
| 83 | } |
| 84 | |
| 85 | // Release back to pool |
| 86 | PutSelectStatement(stmt1) |
| 87 | |
| 88 | // Test getting another SelectStatement reuses the pool |
| 89 | stmt2 := GetSelectStatement() |
| 90 | if stmt2 == nil { |
| 91 | t.Fatal("expected non-nil SelectStatement") |
| 92 | } |
| 93 | if len(stmt2.Columns) != 0 { |
| 94 | t.Errorf("expected empty columns after reset, got %d", len(stmt2.Columns)) |
| 95 | } |
| 96 | if stmt2.Where != nil { |
| 97 | t.Error("expected nil Where after reset") |
| 98 | } |
| 99 | PutSelectStatement(stmt2) |
| 100 | } |
| 101 | |
| 102 | func TestIdentifierPool(t *testing.T) { |
| 103 | // Test getting an Identifier |
nothing calls this directly
no test coverage detected