@@ -220,7 +220,6 @@ func AssertLE(value, expect interface{}) {
220
220
// AssertIN checks `value` is IN `expect`.
221
221
// The `expect` should be a slice,
222
222
// but the `value` can be a slice or a basic type variable.
223
- // TODO map support.
224
223
// TODO: gconv.Strings(0) is not [0]
225
224
func AssertIN (value , expect interface {}) {
226
225
var (
@@ -249,6 +248,14 @@ func AssertIN(value, expect interface{}) {
249
248
expectStr = gconv .String (expect )
250
249
)
251
250
passed = gstr .Contains (expectStr , valueStr )
251
+ case reflect .Map :
252
+ expectMap := gconv .Map (expect )
253
+ for _ , v1 := range gconv .Strings (value ) {
254
+ if _ , exists := expectMap [v1 ]; ! exists {
255
+ passed = false
256
+ break
257
+ }
258
+ }
252
259
default :
253
260
panic (fmt .Sprintf (`[ASSERT] INVALID EXPECT VALUE TYPE: %v` , expectKind ))
254
261
}
@@ -260,7 +267,6 @@ func AssertIN(value, expect interface{}) {
260
267
// AssertNI checks `value` is NOT IN `expect`.
261
268
// The `expect` should be a slice,
262
269
// but the `value` can be a slice or a basic type variable.
263
- // TODO map support.
264
270
func AssertNI (value , expect interface {}) {
265
271
var (
266
272
passed = true
@@ -287,6 +293,14 @@ func AssertNI(value, expect interface{}) {
287
293
expectStr = gconv .String (expect )
288
294
)
289
295
passed = ! gstr .Contains (expectStr , valueStr )
296
+ case reflect .Map :
297
+ expectMap := gconv .Map (expect )
298
+ for _ , v1 := range gconv .Strings (value ) {
299
+ if _ , exists := expectMap [v1 ]; exists {
300
+ passed = false
301
+ break
302
+ }
303
+ }
290
304
default :
291
305
panic (fmt .Sprintf (`[ASSERT] INVALID EXPECT VALUE TYPE: %v` , expectKind ))
292
306
}
0 commit comments