ConsistsOf succeeds if array contains all given elements, in given order, and only them. Before comparison, array and all elements are converted to canonical form. Example: array := NewArray(t, []interface{}{"foo", 123}) array.ConsistsOf("foo", 123) These calls are equivalent: array.ConsistsO
(values ...interface{})
| 1117 | // array.ConsistsOf("a", "b") |
| 1118 | // array.IsEqual([]interface{}{"a", "b"}) |
| 1119 | func (a *Array) ConsistsOf(values ...interface{}) *Array { |
| 1120 | opChain := a.chain.enter("ConsistsOf()") |
| 1121 | defer opChain.leave() |
| 1122 | |
| 1123 | if opChain.failed() { |
| 1124 | return a |
| 1125 | } |
| 1126 | |
| 1127 | expected, ok := canonArray(opChain, values) |
| 1128 | if !ok { |
| 1129 | return a |
| 1130 | } |
| 1131 | |
| 1132 | if !reflect.DeepEqual(expected, a.value) { |
| 1133 | opChain.fail(AssertionFailure{ |
| 1134 | Type: AssertEqual, |
| 1135 | Actual: &AssertionValue{a.value}, |
| 1136 | Expected: &AssertionValue{expected}, |
| 1137 | Errors: []error{ |
| 1138 | errors.New("expected: array consists of given elements"), |
| 1139 | }, |
| 1140 | }) |
| 1141 | } |
| 1142 | |
| 1143 | return a |
| 1144 | } |
| 1145 | |
| 1146 | // NotConsistsOf is opposite to ConsistsOf. |
| 1147 | // |