@@ -40,6 +40,14 @@ func toMapAny[T basetype](val map[string]T) map[string]any {
40
40
return ret
41
41
}
42
42
43
+ func toSlice (val []map [string ]any ) []any {
44
+ ret := make ([]any , len (val ))
45
+ for i , v := range val {
46
+ ret [i ] = v
47
+ }
48
+ return ret
49
+ }
50
+
43
51
func toSliceAny [T basetype ](val []map [string ]T ) []any {
44
52
ret := make ([]any , len (val ))
45
53
for i , v := range val {
@@ -129,7 +137,7 @@ func Gopt_Case_MatchMap(t CaseT, expected, got map[string]any, name ...string) {
129
137
}
130
138
}
131
139
132
- func Gopt_Case_MatchSlice (t CaseT , expected , got []any , name ... string ) {
140
+ func Gopt_Case_MatchSlice [ T any ] (t CaseT , expected [] T , got []any , name ... string ) {
133
141
t .Helper ()
134
142
if len (expected ) != len (got ) {
135
143
t .Fatalf ("unmatched slice%s length - expected: %d, got: %d\n " , nameCtx (name ), len (expected ), len (got ))
@@ -287,6 +295,9 @@ retry:
287
295
case * Var__3 [[]string ]:
288
296
Gopt_Case_MatchBaseSlice (t , ev , gv .Val (), name ... )
289
297
return
298
+ case []any :
299
+ Gopt_Case_MatchSlice (t , ev , gv , name ... )
300
+ return
290
301
}
291
302
case TySet [string ]:
292
303
switch gv := got .(type ) {
@@ -396,6 +407,9 @@ retry:
396
407
expected = toMapAny (ev )
397
408
goto retry
398
409
410
+ case []map [string ]any :
411
+ expected = toSlice (ev )
412
+ goto retry
399
413
case []map [string ]string :
400
414
expected = toSliceAny (ev )
401
415
goto retry
0 commit comments