Test InExpression node
(t *testing.T)
| 1015 | |
| 1016 | // Test InExpression node |
| 1017 | func TestInExpression(t *testing.T) { |
| 1018 | tests := []struct { |
| 1019 | name string |
| 1020 | inExpr *InExpression |
| 1021 | wantLiteral string |
| 1022 | wantChildren int |
| 1023 | }{ |
| 1024 | { |
| 1025 | name: "simple IN expression", |
| 1026 | inExpr: &InExpression{ |
| 1027 | Expr: &Identifier{Name: "id"}, |
| 1028 | List: []Expression{ |
| 1029 | &LiteralValue{Value: "1"}, |
| 1030 | &LiteralValue{Value: "2"}, |
| 1031 | &LiteralValue{Value: "3"}, |
| 1032 | }, |
| 1033 | Not: false, |
| 1034 | }, |
| 1035 | wantLiteral: "IN", |
| 1036 | wantChildren: 4, |
| 1037 | }, |
| 1038 | { |
| 1039 | name: "NOT IN expression", |
| 1040 | inExpr: &InExpression{ |
| 1041 | Expr: &Identifier{Name: "status"}, |
| 1042 | List: []Expression{ |
| 1043 | &LiteralValue{Value: "deleted"}, |
| 1044 | &LiteralValue{Value: "archived"}, |
| 1045 | }, |
| 1046 | Not: true, |
| 1047 | }, |
| 1048 | wantLiteral: "IN", |
| 1049 | wantChildren: 3, |
| 1050 | }, |
| 1051 | } |
| 1052 | |
| 1053 | for _, tt := range tests { |
| 1054 | tt := tt // G601: Create local copy to avoid memory aliasing |
| 1055 | t.Run(tt.name, func(t *testing.T) { |
| 1056 | // Test TokenLiteral |
| 1057 | if got := tt.inExpr.TokenLiteral(); got != tt.wantLiteral { |
| 1058 | t.Errorf("InExpression.TokenLiteral() = %v, want %v", got, tt.wantLiteral) |
| 1059 | } |
| 1060 | |
| 1061 | // Test Children |
| 1062 | children := tt.inExpr.Children() |
| 1063 | if len(children) != tt.wantChildren { |
| 1064 | t.Errorf("InExpression.Children() count = %d, want %d", len(children), tt.wantChildren) |
| 1065 | } |
| 1066 | |
| 1067 | // Test that it implements Expression interface |
| 1068 | var _ Expression = tt.inExpr |
| 1069 | tt.inExpr.expressionNode() |
| 1070 | }) |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | // Test BetweenExpression node |
nothing calls this directly
no test coverage detected