(path []string, less func(a, b interface{}) bool)
| 158 | } |
| 159 | |
| 160 | func WithSort(path []string, less func(a, b interface{}) bool) func(a, b interface{}) { |
| 161 | return func(a, b interface{}) { |
| 162 | for _, p := range path { |
| 163 | mapA, ok := a.(map[string]interface{}) |
| 164 | if !ok { |
| 165 | return |
| 166 | } |
| 167 | a = mapA[p] |
| 168 | mapB, ok := b.(map[string]interface{}) |
| 169 | if !ok { |
| 170 | return |
| 171 | } |
| 172 | b = mapB[p] |
| 173 | } |
| 174 | aSlice, ok := a.([]interface{}) |
| 175 | if !ok { |
| 176 | return |
| 177 | } |
| 178 | bSlice, ok := b.([]interface{}) |
| 179 | if !ok { |
| 180 | return |
| 181 | } |
| 182 | sort.Slice(aSlice, func(i, j int) bool { return less(aSlice[i], aSlice[j]) }) |
| 183 | sort.Slice(bSlice, func(i, j int) bool { return less(bSlice[i], bSlice[j]) }) |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | func IsJSONSubset(t testing.TB, a, b []byte, opts ...func(a, b interface{})) bool { |
| 188 | var aval, bval interface{} |
nothing calls this directly
no outgoing calls
no test coverage detected