ContainsValue succeeds if object contains given value with any key. Before comparison, both object and value are converted to canonical form. Example: object := NewObject(t, map[string]interface{}{"foo": 123}) object.ContainsValue(123)
(value interface{})
| 1053 | // object := NewObject(t, map[string]interface{}{"foo": 123}) |
| 1054 | // object.ContainsValue(123) |
| 1055 | func (o *Object) ContainsValue(value interface{}) *Object { |
| 1056 | opChain := o.chain.enter("ContainsValue()") |
| 1057 | defer opChain.leave() |
| 1058 | |
| 1059 | if opChain.failed() { |
| 1060 | return o |
| 1061 | } |
| 1062 | |
| 1063 | if _, ok := containsValue(opChain, o.value, value); !ok { |
| 1064 | opChain.fail(AssertionFailure{ |
| 1065 | Type: AssertContainsElement, |
| 1066 | Actual: &AssertionValue{o.value}, |
| 1067 | Expected: &AssertionValue{value}, |
| 1068 | Errors: []error{ |
| 1069 | errors.New("expected: map contains element (with any key)"), |
| 1070 | }, |
| 1071 | }) |
| 1072 | } |
| 1073 | |
| 1074 | return o |
| 1075 | } |
| 1076 | |
| 1077 | // NotContainsValue succeeds if object does not contain given value with any key. |
| 1078 | // Before comparison, both object and value are converted to canonical form. |