Test LiteralValue node
(t *testing.T)
| 801 | |
| 802 | // Test LiteralValue node |
| 803 | func 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 |
| 853 | func TestFunctionCall(t *testing.T) { |
nothing calls this directly
no test coverage detected