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

Function TestFunctionCallPosition

pkg/sql/ast/positions_test.go:225–242  ·  view source on GitHub ↗

----------------------------------------------------------------------------- TestFunctionCallPosition verifies FunctionCall nodes carry positions -----------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

223// -----------------------------------------------------------------------------
224
225func TestFunctionCallPosition(t *testing.T) {
226 tree := parseWithPositions(t, "SELECT COUNT(*) FROM users")
227
228 sel := tree.Statements[0].(*ast.SelectStatement)
229
230 if len(sel.Columns) == 0 {
231 t.Fatal("expected at least 1 column")
232 }
233
234 fn, ok := sel.Columns[0].(*ast.FunctionCall)
235 if !ok {
236 t.Fatalf("expected *ast.FunctionCall, got %T", sel.Columns[0])
237 }
238
239 assertPos(t, "FunctionCall(COUNT).Pos", fn.Pos)
240 // COUNT starts at column 8 in "SELECT COUNT(*) FROM users"
241 assertPosEqual(t, "FunctionCall(COUNT).Pos", fn.Pos, 1, 8)
242}
243
244func TestNestedFunctionCallPosition(t *testing.T) {
245 tree := parseWithPositions(t, "SELECT SUM(amount) FROM orders")

Callers

nothing calls this directly

Calls 4

parseWithPositionsFunction · 0.85
assertPosFunction · 0.85
assertPosEqualFunction · 0.85
FatalfMethod · 0.65

Tested by

no test coverage detected