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

Function TestIdentifier

pkg/sql/ast/nodes_test.go:697–739  ·  view source on GitHub ↗

Test Identifier node

(t *testing.T)

Source from the content-addressed store, hash-verified

695
696// Test Identifier node
697func TestIdentifier(t *testing.T) {
698 tests := []struct {
699 name string
700 identifier *Identifier
701 wantLiteral string
702 }{
703 {
704 name: "simple identifier",
705 identifier: &Identifier{Name: "id"},
706 wantLiteral: "id",
707 },
708 {
709 name: "qualified identifier",
710 identifier: &Identifier{Table: "users", Name: "id"},
711 wantLiteral: "id",
712 },
713 {
714 name: "asterisk identifier",
715 identifier: &Identifier{Name: "*"},
716 wantLiteral: "*",
717 },
718 }
719
720 for _, tt := range tests {
721 tt := tt // G601: Create local copy to avoid memory aliasing
722 t.Run(tt.name, func(t *testing.T) {
723 // Test TokenLiteral
724 if got := tt.identifier.TokenLiteral(); got != tt.wantLiteral {
725 t.Errorf("Identifier.TokenLiteral() = %v, want %v", got, tt.wantLiteral)
726 }
727
728 // Test Children
729 children := tt.identifier.Children()
730 if children != nil {
731 t.Errorf("Identifier.Children() = %v, want nil", children)
732 }
733
734 // Test that it implements Expression interface
735 var _ Expression = tt.identifier
736 tt.identifier.expressionNode()
737 })
738 }
739}
740
741// Test BinaryExpression node
742func TestBinaryExpression(t *testing.T) {

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