Add BOOST_TEST_LT, BOOST_TEST_LE

This commit is contained in:
Peter Dimov
2017-03-16 01:31:43 +02:00
parent 064cfd3d73
commit 46545326d8
6 changed files with 143 additions and 5 deletions

View File

@@ -147,6 +147,40 @@ template<class T, class U> inline void test_ne_impl( char const * expr1, char co
}
}
template<class T, class U> inline void test_lt_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t < u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " < " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' >= '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
}
}
template<class T, class U> inline void test_le_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, T const & t, U const & u )
{
if( t <= u )
{
report_errors_remind();
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr1 << " <= " << expr2
<< "' failed in function '" << function << "': "
<< "'" << test_output_impl(t) << "' > '" << test_output_impl(u) << "'" << std::endl;
++test_errors();
}
}
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
char const * file, int line, char const * function, char const * const t, char const * const u )
{
@@ -360,6 +394,9 @@ inline int report_errors()
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_lt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_le_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
#define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )