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

Function TestLiteralValue

pkg/sql/ast/nodes_test.go:803–850  ·  view source on GitHub ↗

Test LiteralValue node

(t *testing.T)

Source from the content-addressed store, hash-verified

801
802// Test LiteralValue node
803func TestLiteralValue(t *testing.T) {
804 tests := []struct {
805 name string
806 literal *LiteralValue
807 wantLiteral string
808 }{
809 {
810 name: "string literal",
811 literal: &LiteralValue{Value: "hello"},
812 wantLiteral: "hello",
813 },
814 {
815 name: "number literal",
816 literal: &LiteralValue{Value: "42"},
817 wantLiteral: "42",
818 },
819 {
820 name: "NULL literal",
821 literal: &LiteralValue{Value: "NULL"},
822 wantLiteral: "NULL",
823 },
824 {
825 name: "boolean literal",
826 literal: &LiteralValue{Value: "TRUE"},
827 wantLiteral: "TRUE",
828 },
829 }
830
831 for _, tt := range tests {
832 tt := tt // G601: Create local copy to avoid memory aliasing
833 t.Run(tt.name, func(t *testing.T) {
834 // Test TokenLiteral
835 if got := tt.literal.TokenLiteral(); got != tt.wantLiteral {
836 t.Errorf("LiteralValue.TokenLiteral() = %v, want %v", got, tt.wantLiteral)
837 }
838
839 // Test Children
840 children := tt.literal.Children()
841 if children != nil {
842 t.Errorf("LiteralValue.Children() = %v, want nil", children)
843 }
844
845 // Test that it implements Expression interface
846 var _ Expression = tt.literal
847 tt.literal.expressionNode()
848 })
849 }
850}
851
852// Test FunctionCall node
853func TestFunctionCall(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