MCPcopy Create free account
hub / github.com/chain/txvm / IsSubset

Function IsSubset

testutil/deepequal.go:203–240  ·  view source on GitHub ↗
(a, b interface{})

Source from the content-addressed store, hash-verified

201}
202
203func IsSubset(a, b interface{}) bool {
204 if reflect.TypeOf(a) != reflect.TypeOf(b) {
205 return false
206 }
207 switch va := a.(type) {
208 case map[string]interface{}:
209 // don't check length or presence of fields
210 // exclusively in a, since this is a subset check
211 vb := b.(map[string]interface{})
212 for k := range vb {
213 if !IsSubset(va[k], vb[k]) {
214 return false
215 }
216 }
217 return true
218 case []interface{}:
219 vb := b.([]interface{})
220 if len(va) != len(vb) {
221 return false
222 }
223 for i := range va {
224 if !IsSubset(va[i], vb[i]) {
225 return false
226 }
227 }
228 return true
229 case float64:
230 return va == b.(float64)
231 case bool:
232 return va == b.(bool)
233 case string:
234 return va == b.(string)
235 case nil:
236 return true
237 default:
238 return false
239 }
240}

Callers 1

IsJSONSubsetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected