Add PredicateMatcher that takes an arbitrary predicate functions
Also adds `Predicate` helper function to create `PredicateMatcher`.
Because of limitations in type inference it needs to be explicitly
typed, like so
`Predicate<std::string>([](std::string const& str) { ... })`.
It also takes an optional second argument for description of the
predicate.
It is possible to infer the argument with sufficient TMP, see
43561563 (43561563)
but I don't think that the magic is worth introducing ATM.
Closes #1236
This commit is contained in:
parent
dfb83f20e9
commit
1ca8f43b01
11 changed files with 204 additions and 7 deletions
9
include/internal/catch_matchers_generic.cpp
Normal file
9
include/internal/catch_matchers_generic.cpp
Normal file
|
@ -0,0 +1,9 @@
|
|||
#include "catch_matchers_generic.hpp"
|
||||
|
||||
std::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) {
|
||||
if (desc.empty()) {
|
||||
return "matches undescribed predicate";
|
||||
} else {
|
||||
return "matches predicate: \"" + desc + '"';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue