1
0
forked from boostorg/core

Change BOOST_TEST to match BOOST_TEST_EQ et al, in order to avoid 'expression result unused' warning from Clang

This commit is contained in:
Peter Dimov
2020-02-21 19:46:42 +02:00
parent b5c2726d1b
commit 27d8ef1286

View File

@ -93,12 +93,21 @@ inline int& test_errors()
return test_results().errors();
}
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
inline bool test_impl(char const * expr, char const * file, int line, char const * function, bool v)
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_results().errors();
if( v )
{
test_results();
return true;
}
else
{
BOOST_LIGHTWEIGHT_TEST_OSTREAM
<< file << "(" << line << "): test '" << expr << "' failed in function '"
<< function << "'" << std::endl;
++test_results().errors();
return false;
}
}
inline void error_impl(char const * msg, char const * file, int line, char const * function)
@ -417,7 +426,7 @@ inline int report_errors()
} // namespace boost
#define BOOST_TEST(expr) ((expr)? ((void)::boost::detail::test_results(), true): (::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION), false))
#define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) )
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )