You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement 'Contains(e).Times(n)' matcher modifier which allows to test for arbitrary occurrences including absence with Times(0).
PiperOrigin-RevId: 382210276
Copy file name to clipboardExpand all lines: docs/reference/matchers.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -116,6 +116,7 @@ messages, you can use:
116
116
|`BeginEndDistanceIs(m)`|`argument` is a container whose `begin()` and `end()` iterators are separated by a number of increments matching `m`. E.g. `BeginEndDistanceIs(2)` or `BeginEndDistanceIs(Lt(2))`. For containers that define a `size()` method, `SizeIs(m)` may be more efficient. |
117
117
|`ContainerEq(container)`| The same as `Eq(container)` except that the failure message also includes which elements are in one container but not the other. |
118
118
|`Contains(e)`|`argument` contains an element that matches `e`, which can be either a value or a matcher. |
119
+
|`Contains(e).Times(n)`|`argument` contains elements that match `e`, which can be either a value or a matcher, and the number of matches is `n`, which can be either a value or a matcher. Unlike the plain `Contains` and `Each` this allows to check for arbitrary occurrences including testing for absence with `Contains(e).Times(0)`. |
119
120
|`Each(e)`|`argument` is a container where *every* element matches `e`, which can be either a value or a matcher. |
120
121
|`ElementsAre(e0, e1, ..., en)`|`argument` has `n + 1` elements, where the *i*-th element matches `ei`, which can be a value or a matcher. |
121
122
|`ElementsAreArray({e0, e1, ..., en})`, `ElementsAreArray(a_container)`, `ElementsAreArray(begin, end)`, `ElementsAreArray(array)`, or `ElementsAreArray(array, count)`| The same as `ElementsAre()` except that the expected element values/matchers come from an initializer list, STL-style container, iterator range, or C-style array. |
0 commit comments