TestPutExpressionAllTypes tests PutExpression with all expression types
(t *testing.T)
| 22 | |
| 23 | // TestPutExpressionAllTypes tests PutExpression with all expression types |
| 24 | func TestPutExpressionAllTypes(t *testing.T) { |
| 25 | t.Run("nil expression", func(t *testing.T) { |
| 26 | // Should not panic |
| 27 | PutExpression(nil) |
| 28 | }) |
| 29 | |
| 30 | t.Run("Identifier", func(t *testing.T) { |
| 31 | id := GetIdentifier() |
| 32 | id.Name = "test_col" |
| 33 | PutExpression(id) |
| 34 | }) |
| 35 | |
| 36 | t.Run("BinaryExpression with children", func(t *testing.T) { |
| 37 | left := GetIdentifier() |
| 38 | left.Name = "a" |
| 39 | right := GetIdentifier() |
| 40 | right.Name = "b" |
| 41 | expr := GetBinaryExpression() |
| 42 | expr.Left = left |
| 43 | expr.Right = right |
| 44 | expr.Operator = "=" |
| 45 | PutExpression(expr) |
| 46 | }) |
| 47 | |
| 48 | t.Run("BinaryExpression with nil children", func(t *testing.T) { |
| 49 | expr := GetBinaryExpression() |
| 50 | expr.Operator = "+" |
| 51 | PutExpression(expr) |
| 52 | }) |
| 53 | |
| 54 | t.Run("LiteralValue", func(t *testing.T) { |
| 55 | lit := GetLiteralValue() |
| 56 | lit.Value = "test" |
| 57 | lit.Type = "string" |
| 58 | PutExpression(lit) |
| 59 | }) |
| 60 | |
| 61 | t.Run("FunctionCall with arguments", func(t *testing.T) { |
| 62 | fn := GetFunctionCall() |
| 63 | fn.Name = "COUNT" |
| 64 | fn.Arguments = []Expression{ |
| 65 | &Identifier{Name: "col1"}, |
| 66 | &LiteralValue{Value: 1, Type: "int"}, |
| 67 | } |
| 68 | fn.Distinct = true |
| 69 | PutExpression(fn) |
| 70 | }) |
| 71 | |
| 72 | t.Run("FunctionCall empty arguments", func(t *testing.T) { |
| 73 | fn := GetFunctionCall() |
| 74 | fn.Name = "NOW" |
| 75 | PutExpression(fn) |
| 76 | }) |
| 77 | |
| 78 | t.Run("CaseExpression full", func(t *testing.T) { |
| 79 | caseExpr := GetCaseExpression() |
| 80 | caseExpr.Value = &Identifier{Name: "status"} |
| 81 | caseExpr.WhenClauses = []WhenClause{ |
nothing calls this directly
no test coverage detected