Logo
Explore Help
Sign In
catchorg/Catch2
1
0
Fork 1
You've already forked Catch2
mirror of https://github.com/catchorg/Catch2.git synced 2025-11-04 09:01:50 +01:00
Code Issues Packages Projects Releases Wiki Activity
Files
c38a5caa2ebf0738e468f419c4d3ed857001cfb0
Catch2/include/internal/catch_matchers_generic.cpp

10 lines
278 B
C++
Raw Normal View History

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 https://stackoverflow.com/questions/43560492/how-to-extract-lambdas-return-type-and-variadic-parameters-pack-back-from-gener/43561563#43561563 but I don't think that the magic is worth introducing ATM. Closes #1236
2018-04-03 23:28:14 +02:00
#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 + '"';
}
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 29ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API