forked from boostorg/core
Change lw_name_traits to lw_predicate_name
This commit is contained in:
@ -173,11 +173,7 @@ template<class T> inline const void* test_output_impl(T volatile* v) { return co
|
|||||||
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
|
inline const void* test_output_impl(std::nullptr_t) { return nullptr; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <typename BinaryPredicate>
|
// predicates
|
||||||
struct lw_name_traits
|
|
||||||
{
|
|
||||||
static const char* op() { return "<+>"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lw_test_eq
|
struct lw_test_eq
|
||||||
{
|
{
|
||||||
@ -185,72 +181,75 @@ struct lw_test_eq
|
|||||||
bool operator()(const T& t, const U& u) const { return t == u; }
|
bool operator()(const T& t, const U& u) const { return t == u; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct lw_name_traits<lw_test_eq>
|
|
||||||
{
|
|
||||||
static const char* op() { return "=="; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lw_test_ne
|
struct lw_test_ne
|
||||||
{
|
{
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
bool operator()(const T& t, const U& u) const { return t != u; }
|
bool operator()(const T& t, const U& u) const { return t != u; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct lw_name_traits<lw_test_ne>
|
|
||||||
{
|
|
||||||
static const char* op() { return "!="; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lw_test_lt
|
struct lw_test_lt
|
||||||
{
|
{
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
bool operator()(const T& t, const U& u) const { return t < u; }
|
bool operator()(const T& t, const U& u) const { return t < u; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct lw_name_traits<lw_test_lt>
|
|
||||||
{
|
|
||||||
static const char* op() { return "<"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lw_test_le
|
struct lw_test_le
|
||||||
{
|
{
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
bool operator()(const T& t, const U& u) const { return t <= u; }
|
bool operator()(const T& t, const U& u) const { return t <= u; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct lw_name_traits<lw_test_le>
|
|
||||||
{
|
|
||||||
static const char* op() { return "<="; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lw_test_gt
|
struct lw_test_gt
|
||||||
{
|
{
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
bool operator()(const T& t, const U& u) const { return t > u; }
|
bool operator()(const T& t, const U& u) const { return t > u; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct lw_name_traits<lw_test_gt>
|
|
||||||
{
|
|
||||||
static const char* op() { return ">"; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct lw_test_ge
|
struct lw_test_ge
|
||||||
{
|
{
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
bool operator()(const T& t, const U& u) const { return t >= u; }
|
bool operator()(const T& t, const U& u) const { return t >= u; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
// lw_predicate_name
|
||||||
struct lw_name_traits<lw_test_ge>
|
|
||||||
|
template<class T> 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<class BinaryPredicate, class T, class U>
|
template<class BinaryPredicate, class T, class U>
|
||||||
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||||
char const * file, int line, char const * function,
|
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
|
else
|
||||||
{
|
{
|
||||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||||
<< file << "(" << line << "): test '" << expr1 << " " << lw_name_traits<decltype(pred)>::op() << " " << expr2
|
<< file << "(" << line << "): test '" << expr1 << " " << lw_predicate_name(pred) << " " << expr2
|
||||||
<< "' ('" << test_output_impl(t) << "' " << lw_name_traits<decltype(pred)>::op() << " '" << test_output_impl(u)
|
<< "' ('" << test_output_impl(t) << "' " << lw_predicate_name(pred) << " '" << test_output_impl(u)
|
||||||
<< "') failed in function '" << function << "'" << std::endl;
|
<< "') failed in function '" << function << "'" << std::endl;
|
||||||
++test_results().errors();
|
++test_results().errors();
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user