MCPcopy Index your code
hub / github.com/gavv/httpexpect / IsEqual

Method IsEqual

array.go:778–803  ·  view source on GitHub ↗

IsEqual succeeds if array is equal to given value. Before comparison, both array and value are converted to canonical form. value should be a slice of any type. Example: array := NewArray(t, []interface{}{"foo", 123}) array.IsEqual([]interface{}{"foo", 123}) array := NewArray(t, []interface{}

(value interface{})

Source from the content-addressed store, hash-verified

776// array := NewArray(t, []interface{}{123, 456})
777// array.IsEqual([]int{}{123, 456})
778func (a *Array) IsEqual(value interface{}) *Array {
779 opChain := a.chain.enter("IsEqual()")
780 defer opChain.leave()
781
782 if opChain.failed() {
783 return a
784 }
785
786 expected, ok := canonArray(opChain, value)
787 if !ok {
788 return a
789 }
790
791 if !reflect.DeepEqual(expected, a.value) {
792 opChain.fail(AssertionFailure{
793 Type: AssertEqual,
794 Actual: &AssertionValue{a.value},
795 Expected: &AssertionValue{expected},
796 Errors: []error{
797 errors.New("expected: arrays are equal"),
798 },
799 })
800 }
801
802 return a
803}
804
805// NotEqual succeeds if array is not equal to given value.
806// Before comparison, both array and value are converted to canonical form.

Callers 2

EqualMethod · 0.95
TestArray_ConstructorsFunction · 0.95

Calls 5

canonArrayFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
failMethod · 0.80

Tested by 1

TestArray_ConstructorsFunction · 0.76