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

Function TestPutExpressionAllTypes

pkg/sql/ast/coverage_test.go:24–258  ·  view source on GitHub ↗

TestPutExpressionAllTypes tests PutExpression with all expression types

(t *testing.T)

Source from the content-addressed store, hash-verified

22
23// TestPutExpressionAllTypes tests PutExpression with all expression types
24func 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{

Callers

nothing calls this directly

Calls 11

PutExpressionFunction · 0.85
GetIdentifierFunction · 0.85
GetBinaryExpressionFunction · 0.85
GetLiteralValueFunction · 0.85
GetFunctionCallFunction · 0.85
GetCaseExpressionFunction · 0.85
GetBetweenExpressionFunction · 0.85
GetInExpressionFunction · 0.85
GetSubqueryExpressionFunction · 0.85
GetCastExpressionFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected