MCPcopy Create free account
hub / github.com/gavv/httpexpect / IsEqual

Method IsEqual

object.go:811–836  ·  view source on GitHub ↗

IsEqual succeeds if object is equal to given value. Before comparison, both object and value are converted to canonical form. value should be map[string]interface{} or struct. Example: object := NewObject(t, map[string]interface{}{"foo": 123}) object.IsEqual(map[string]interface{}{"foo": 123})

(value interface{})

Source from the content-addressed store, hash-verified

809// object := NewObject(t, map[string]interface{}{"foo": 123})
810// object.IsEqual(map[string]interface{}{"foo": 123})
811func (o *Object) IsEqual(value interface{}) *Object {
812 opChain := o.chain.enter("IsEqual()")
813 defer opChain.leave()
814
815 if opChain.failed() {
816 return o
817 }
818
819 expected, ok := canonMap(opChain, value)
820 if !ok {
821 return o
822 }
823
824 if !reflect.DeepEqual(expected, o.value) {
825 opChain.fail(AssertionFailure{
826 Type: AssertEqual,
827 Actual: &AssertionValue{o.value},
828 Expected: &AssertionValue{expected},
829 Errors: []error{
830 errors.New("expected: maps are equal"),
831 },
832 })
833 }
834
835 return o
836}
837
838// NotEqual succeeds if object is not equal to given value.
839// Before comparison, both object and value are converted to canonical form.

Callers 2

EqualMethod · 0.95
TestObject_ConstructorsFunction · 0.95

Calls 5

canonMapFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 1

TestObject_ConstructorsFunction · 0.76