Test BetweenExpression node
(t *testing.T)
| 1073 | |
| 1074 | // Test BetweenExpression node |
| 1075 | func TestBetweenExpression(t *testing.T) { |
| 1076 | tests := []struct { |
| 1077 | name string |
| 1078 | betweenExpr *BetweenExpression |
| 1079 | wantLiteral string |
| 1080 | wantChildren int |
| 1081 | }{ |
| 1082 | { |
| 1083 | name: "simple BETWEEN expression", |
| 1084 | betweenExpr: &BetweenExpression{ |
| 1085 | Expr: &Identifier{Name: "age"}, |
| 1086 | Lower: &LiteralValue{Value: "18"}, |
| 1087 | Upper: &LiteralValue{Value: "65"}, |
| 1088 | Not: false, |
| 1089 | }, |
| 1090 | wantLiteral: "BETWEEN", |
| 1091 | wantChildren: 3, |
| 1092 | }, |
| 1093 | { |
| 1094 | name: "NOT BETWEEN expression", |
| 1095 | betweenExpr: &BetweenExpression{ |
| 1096 | Expr: &Identifier{Name: "price"}, |
| 1097 | Lower: &LiteralValue{Value: "100"}, |
| 1098 | Upper: &LiteralValue{Value: "500"}, |
| 1099 | Not: true, |
| 1100 | }, |
| 1101 | wantLiteral: "BETWEEN", |
| 1102 | wantChildren: 3, |
| 1103 | }, |
| 1104 | } |
| 1105 | |
| 1106 | for _, tt := range tests { |
| 1107 | tt := tt // G601: Create local copy to avoid memory aliasing |
| 1108 | t.Run(tt.name, func(t *testing.T) { |
| 1109 | // Test TokenLiteral |
| 1110 | if got := tt.betweenExpr.TokenLiteral(); got != tt.wantLiteral { |
| 1111 | t.Errorf("BetweenExpression.TokenLiteral() = %v, want %v", got, tt.wantLiteral) |
| 1112 | } |
| 1113 | |
| 1114 | // Test Children |
| 1115 | children := tt.betweenExpr.Children() |
| 1116 | if len(children) != tt.wantChildren { |
| 1117 | t.Errorf("BetweenExpression.Children() count = %d, want %d", len(children), tt.wantChildren) |
| 1118 | } |
| 1119 | |
| 1120 | // Test that it implements Expression interface |
| 1121 | var _ Expression = tt.betweenExpr |
| 1122 | tt.betweenExpr.expressionNode() |
| 1123 | }) |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | // Test UnaryExpression node |
| 1128 | func TestUnaryExpression(t *testing.T) { |
nothing calls this directly
no test coverage detected