Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-05-14 14:48:48 +0200
committerMartin Hořeňovský2020-05-14 14:48:48 +0200
commitd5e87eabbb6a39f88eae445a5679987bb128938b (patch)
tree29e98ff745c39ee2c59d2c13be2eada56d28711c
parent29d4b3768ceef7ee690d366c61ac6ff55de4d5f8 (diff)
downloadcatch3-d5e87eabbb6a39f88eae445a5679987bb128938b.tar.gz
Add provided generic matchers to the documentation
-rw-r--r--docs/matchers.md32
1 files changed, 31 insertions, 1 deletions
diff --git a/docs/matchers.md b/docs/matchers.md
index 39003b49..a5bf13f2 100644
--- a/docs/matchers.md
+++ b/docs/matchers.md
@@ -241,6 +241,35 @@ Note that `DerivedException` in the example above has to derive from
> the exception message matcher lives in `catch2/matchers/catch_matchers_exception.hpp`
+### Generic range Matchers
+
+> Generic range matchers were introduced in Catch X.Y.Z
+
+Catch2 also provides some matchers that use the new style matchers
+definitions to handle generic range-like types. These are:
+
+* `IsEmpty()`
+* `SizeIs(size_t target_size)`
+* `SizeIs(Matcher size_matcher)`
+* `Contains(T&& target_element, Comparator = std::equal_to<>{})`
+* `Contains(Matcher element_matcher)`
+
+`IsEmpty` should be self-explanatory. It successfully matches objects
+that are empty according to either `std::empty`, or ADL-found `empty`
+free function.
+
+`SizeIs` checks range's size. If constructed with `size_t` arg, the
+matchers accepts ranges whose size is exactly equal to the arg. If
+constructed from another matcher, then the resulting matcher accepts
+ranges whose size is accepted by the provided matcher.
+
+`Contains` accepts ranges that contain specific element. There are
+again two variants, one that accepts the desired element directly,
+in which case a range is accepted if any of its elements is equal to
+the target element. The other variant is constructed from a matcher,
+in which case a range is accepted if any of its elements is accepted
+by the provided matcher.
+
## Writing custom matchers (old style)
@@ -316,7 +345,8 @@ style matchers arbitrarily.
## Writing custom matchers (new style)
-The new style of writing matchers has been introduced in Catch2 v3.
+> New style matchers were introduced in Catch X.Y.Z
+
To create a new-style matcher, you have to create your own type that
derives from `Catch::Matchers::MatcherGenericBase`. Your type has to
also provide two methods, `bool match( ... ) const` and overriden