tap: explicitly type the test as std::function

clang doesn't like to implicitly cast lambdas to functions.
This commit is contained in:
Danny Robson 2015-04-15 13:39:59 +10:00
parent 8863ebafe9
commit 46bd7f739f

View File

@ -39,7 +39,7 @@ template <typename T, typename U>
void void
util::TAP::logger::expect_eq (const T&a, const U &b, const std::string &msg) util::TAP::logger::expect_eq (const T&a, const U &b, const std::string &msg)
{ {
static const auto TEST = [] (const T &t, const U &u) -> bool { static const std::function<bool(const T&,const U&)> TEST = [] (const T &t, const U &u) -> bool {
return almost_equal (t, u); return almost_equal (t, u);
}; };
@ -52,7 +52,7 @@ template <typename T, typename U>
void void
util::TAP::logger::expect_neq (const T&a, const U &b, const std::string &msg) util::TAP::logger::expect_neq (const T&a, const U &b, const std::string &msg)
{ {
static const auto TEST = [] (const T &t, const U &u) -> bool { static const std::function<bool(const T&,const U&)> TEST = [] (const T &t, const U &u) -> bool {
return !almost_equal (t, u); return !almost_equal (t, u);
}; };
@ -68,7 +68,8 @@ util::TAP::logger::expect_ ## SUFFIX (const T &a, \
const U &b, \ const U &b, \
const std::string &msg) \ const std::string &msg) \
{ \ { \
expect<const T&, const U&> ([] (const T&t, const U&u) { return t OP u; }, a, b, msg); \ static const std::function<bool(const T&,const U&)> TEST = [] (const T&t, const U&u) { return t OP u; }; \
expect<const T&, const U&> (TEST, a, b, msg); \
} }
TAP_TEST(gt, > ) TAP_TEST(gt, > )
@ -85,5 +86,5 @@ void
util::TAP::logger::expect_nan (const T &t, const std::string &msg) util::TAP::logger::expect_nan (const T &t, const std::string &msg)
{ {
bool(*func)(T) = std::isnan; bool(*func)(T) = std::isnan;
expect<const T&> (func, t, msg); expect<const T&> (std::function<bool(const T&)> (func), t, msg);
} }