MCPcopy Create free account
hub / github.com/google/gapid / mapsEqual

Method mapsEqual

core/assert/map.go:69–95  ·  view source on GitHub ↗
(expected interface{}, same func(a, b interface{}) bool)

Source from the content-addressed store, hash-verified

67}
68
69func (o OnMap) mapsEqual(expected interface{}, same func(a, b interface{}) bool) bool {
70 return o.Test(func() bool {
71 gs := reflect.ValueOf(o.mp)
72 es := reflect.ValueOf(expected)
73 equal := true
74 for _, k := range gs.MapKeys() {
75 gv := gs.MapIndex(k)
76 ev := es.MapIndex(k)
77 if !ev.IsValid() {
78 o.Printf("\tExtra key: %#v\n", k.Interface())
79 equal = false
80 continue
81 }
82 if !same(gv.Interface(), ev.Interface()) {
83 o.Printf("\tKey: %#v, %#v differs from expected: %#v\n", k.Interface(), gv.Interface(), ev.Interface())
84 equal = false
85 }
86 }
87 for _, k := range es.MapKeys() {
88 if !gs.MapIndex(k).IsValid() {
89 o.Printf("\tKey missing: %#v\n", k.Interface())
90 equal = false
91 }
92 }
93 return equal
94 }())
95}

Callers 3

EqualsMethod · 0.95
EqualsWithComparatorMethod · 0.95
DeepEqualsMethod · 0.95

Calls 5

TestMethod · 0.80
InterfaceMethod · 0.80
IsValidMethod · 0.65
MapIndexMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected