From e155e13084b367846863ab57f375c96e2b81406c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 6 Jun 2020 21:48:16 +0300 Subject: [PATCH] Change lw_name_traits to lw_predicate_name --- include/boost/core/lightweight_test.hpp | 83 ++++++++++++------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 405682c..2135a26 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -173,11 +173,7 @@ template inline const void* test_output_impl(T volatile* v) { return co inline const void* test_output_impl(std::nullptr_t) { return nullptr; } #endif -template -struct lw_name_traits -{ - static const char* op() { return "<+>"; } -}; +// predicates struct lw_test_eq { @@ -185,72 +181,75 @@ struct lw_test_eq bool operator()(const T& t, const U& u) const { return t == u; } }; -template <> -struct lw_name_traits -{ - static const char* op() { return "=="; } -}; - struct lw_test_ne { template bool operator()(const T& t, const U& u) const { return t != u; } }; -template <> -struct lw_name_traits -{ - static const char* op() { return "!="; } -}; - struct lw_test_lt { template bool operator()(const T& t, const U& u) const { return t < u; } }; -template <> -struct lw_name_traits -{ - static const char* op() { return "<"; } -}; - struct lw_test_le { template bool operator()(const T& t, const U& u) const { return t <= u; } }; -template <> -struct lw_name_traits -{ - static const char* op() { return "<="; } -}; - struct lw_test_gt { template bool operator()(const T& t, const U& u) const { return t > u; } }; -template <> -struct lw_name_traits -{ - static const char* op() { return ">"; } -}; - struct lw_test_ge { template bool operator()(const T& t, const U& u) const { return t >= u; } }; -template <> -struct lw_name_traits +// lw_predicate_name + +template char const * lw_predicate_name( T const& ) { - static const char* op() { return ">="; } -}; - + return "~="; +} + +inline char const * lw_predicate_name( lw_test_eq const& ) +{ + return "=="; +} + +inline char const * lw_predicate_name( lw_test_ne const& ) +{ + return "!="; +} + +inline char const * lw_predicate_name( lw_test_lt const& ) +{ + return "<"; +} + +inline char const * lw_predicate_name( lw_test_le const& ) +{ + return "<="; +} + +inline char const * lw_predicate_name( lw_test_gt const& ) +{ + return ">"; +} + +inline char const * lw_predicate_name( lw_test_ge const& ) +{ + return ">="; +} + +// + template inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2, char const * file, int line, char const * function, @@ -264,8 +263,8 @@ inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const else { BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): test '" << expr1 << " " << lw_name_traits::op() << " " << expr2 - << "' ('" << test_output_impl(t) << "' " << lw_name_traits::op() << " '" << test_output_impl(u) + << file << "(" << line << "): test '" << expr1 << " " << lw_predicate_name(pred) << " " << expr2 + << "' ('" << test_output_impl(t) << "' " << lw_predicate_name(pred) << " '" << test_output_impl(u) << "') failed in function '" << function << "'" << std::endl; ++test_results().errors(); return false;