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

Method ConsistsOf

array.go:1119–1144  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

1117// array.ConsistsOf("a", "b")
1118// array.IsEqual([]interface{}{"a", "b"})
1119func (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//

Callers 8

ElementsMethod · 0.95
TestArray_FailedChainFunction · 0.80
TestArray_ConsistsOfFunction · 0.80
TestExpect_TraverseFunction · 0.80
TestIrisThingsFunction · 0.80
TestFruitsFunction · 0.80
testChunkedHandlerFunction · 0.80
testBasicHandlerFunction · 0.80

Calls 5

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

Tested by 7

TestArray_FailedChainFunction · 0.64
TestArray_ConsistsOfFunction · 0.64
TestExpect_TraverseFunction · 0.64
TestIrisThingsFunction · 0.64
TestFruitsFunction · 0.64
testChunkedHandlerFunction · 0.64
testBasicHandlerFunction · 0.64