MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / TestContainsVars

Function TestContainsVars

pkg/sql/sem/tree/normalize_test.go:25–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestContainsVars(t *testing.T) {
26 defer leaktest.AfterTest(t)()
27 testData := []struct {
28 expr string
29 expected bool
30 }{
31 {`123`, false},
32 {`123+123`, false},
33 {`$1`, true},
34 {`123+$1`, true},
35 {`@1`, true},
36 {`123+@1`, true},
37 }
38
39 for _, d := range testData {
40 t.Run(d.expr, func(t *testing.T) {
41 expr, err := parser.ParseExpr(d.expr)
42 if err != nil {
43 t.Fatalf("%s: %v", d.expr, err)
44 }
45 res := tree.ContainsVars(expr)
46 if res != d.expected {
47 t.Fatalf("%s: expected %v, got %v", d.expr, d.expected, res)
48 }
49 })
50 }
51}
52
53func TestNormalizeExpr(t *testing.T) {
54 defer leaktest.AfterTest(t)()

Callers

nothing calls this directly

Calls 3

AfterTestFunction · 0.92
ParseExprFunction · 0.92
ContainsVarsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…