|
4 | 4 | "testing" |
5 | 5 |
|
6 | 6 | "github.com/stretchr/testify/assert" |
| 7 | + "github.com/stretchr/testify/require" |
7 | 8 | ) |
8 | 9 |
|
9 | 10 | func TestHandleSyntaxErr(t *testing.T) { |
@@ -1151,3 +1152,46 @@ func TestRule_Match_Multi(t *testing.T) { |
1151 | 1152 | ass.Equal(tc.out, ok, "data=%+v", tc.data) |
1152 | 1153 | } |
1153 | 1154 | } |
| 1155 | + |
| 1156 | +func Test_Compare_Slice_And_One_Element(t *testing.T) { |
| 1157 | + should := require.New(t) |
| 1158 | + var testData = []struct { |
| 1159 | + rawYql string |
| 1160 | + data map[string]interface{} |
| 1161 | + out bool |
| 1162 | + }{ |
| 1163 | + { |
| 1164 | + rawYql: `letter ∩ ('a')`, |
| 1165 | + data: map[string]interface{}{ |
| 1166 | + "letter": []string{"a", "b", "c"}, |
| 1167 | + }, |
| 1168 | + out: true, |
| 1169 | + }, |
| 1170 | + { |
| 1171 | + rawYql: `letter ∩ ('a', 'b')`, |
| 1172 | + data: map[string]interface{}{ |
| 1173 | + "letter": []string{"a", "b", "c"}, |
| 1174 | + }, |
| 1175 | + out: true, |
| 1176 | + }, |
| 1177 | + { |
| 1178 | + rawYql: `letter ∩ ('d')`, |
| 1179 | + data: map[string]interface{}{ |
| 1180 | + "letter": []string{"a", "b", "c"}, |
| 1181 | + }, |
| 1182 | + out: false, |
| 1183 | + }, |
| 1184 | + { |
| 1185 | + rawYql: `letter in ('a')`, |
| 1186 | + data: map[string]interface{}{ |
| 1187 | + "letter": []string{"a", "b", "c"}, |
| 1188 | + }, |
| 1189 | + out: false, |
| 1190 | + }, |
| 1191 | + } |
| 1192 | + for _, tc := range testData { |
| 1193 | + actual, err := Match(tc.rawYql, tc.data) |
| 1194 | + should.NoError(err) |
| 1195 | + should.Equal(tc.out, actual) |
| 1196 | + } |
| 1197 | +} |
0 commit comments