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{})
| 776 | // array := NewArray(t, []interface{}{123, 456}) |
| 777 | // array.IsEqual([]int{}{123, 456}) |
| 778 | func (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. |