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

Function TestFunctionCall

pkg/sql/ast/nodes_test.go:853–921  ·  view source on GitHub ↗

Test FunctionCall node

(t *testing.T)

Source from the content-addressed store, hash-verified

851
852// Test FunctionCall node
853func TestFunctionCall(t *testing.T) {
854 tests := []struct {
855 name string
856 funcCall *FunctionCall
857 wantLiteral string
858 wantChildren int
859 }{
860 {
861 name: "COUNT(*) function",
862 funcCall: &FunctionCall{
863 Name: "COUNT",
864 Arguments: []Expression{&Identifier{Name: "*"}},
865 },
866 wantLiteral: "COUNT",
867 wantChildren: 1,
868 },
869 {
870 name: "SUM function with column",
871 funcCall: &FunctionCall{
872 Name: "SUM",
873 Arguments: []Expression{&Identifier{Name: "amount"}},
874 },
875 wantLiteral: "SUM",
876 wantChildren: 1,
877 },
878 {
879 name: "window function with OVER clause",
880 funcCall: &FunctionCall{
881 Name: "ROW_NUMBER",
882 Arguments: []Expression{},
883 Over: &WindowSpec{Name: "w"},
884 },
885 wantLiteral: "ROW_NUMBER",
886 wantChildren: 1,
887 },
888 {
889 name: "function with multiple arguments",
890 funcCall: &FunctionCall{
891 Name: "COALESCE",
892 Arguments: []Expression{
893 &Identifier{Name: "email"},
894 &LiteralValue{Value: "N/A"},
895 },
896 },
897 wantLiteral: "COALESCE",
898 wantChildren: 2,
899 },
900 }
901
902 for _, tt := range tests {
903 tt := tt // G601: Create local copy to avoid memory aliasing
904 t.Run(tt.name, func(t *testing.T) {
905 // Test TokenLiteral
906 if got := tt.funcCall.TokenLiteral(); got != tt.wantLiteral {
907 t.Errorf("FunctionCall.TokenLiteral() = %v, want %v", got, tt.wantLiteral)
908 }
909
910 // Test Children

Callers

nothing calls this directly

Calls 5

RunMethod · 0.80
TokenLiteralMethod · 0.65
ErrorfMethod · 0.65
ChildrenMethod · 0.65
expressionNodeMethod · 0.65

Tested by

no test coverage detected