QA: Allow BOOST_CHECKing of nullptr_t
Before Boost 1.64, there was no test logging function
for std::nullptr_t.
Add a logging struct to Boost to deal with this, and some
macros to assist in similar cases. These macros are bit
untidy-looking, but due to GCC bug #56480, we can't use
namespace aliasing to solve this. From Boost 1.64 onwards,
these namespaces are not needed at all.
Remove some code added to work around lack of nullptr printing
in the past.
These macros, and the nullptr printer, can be removed when
the Boost min version is 1.64 or greater.
(cherry picked from commit ad76ebd82a
)
This commit is contained in:
parent
f1a70662c5
commit
2793578dcb
|
@ -332,12 +332,8 @@ BOOST_AUTO_TEST_CASE( URIs )
|
|||
|
||||
const LIB_TABLE_ROW* row = m_mainTableNoFb.FindRowByURI( "://lib/1" );
|
||||
|
||||
// A LIB_TABLE_ROW* nullptr for BOOST_CHECK_NE, because some boost version
|
||||
// do not handle a nullptr with no type
|
||||
const LIB_TABLE_ROW* null_row = nullptr;
|
||||
|
||||
// should be found
|
||||
BOOST_CHECK_NE( null_row, row );
|
||||
BOOST_CHECK_NE( nullptr, row );
|
||||
|
||||
if( row )
|
||||
{
|
||||
|
@ -346,7 +342,7 @@ BOOST_AUTO_TEST_CASE( URIs )
|
|||
|
||||
row = m_mainTableNoFb.FindRowByURI( "this_uri_is_not_found" );
|
||||
|
||||
BOOST_CHECK_EQUAL( null_row, row );
|
||||
BOOST_CHECK_EQUAL( nullptr, row );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,6 +78,58 @@
|
|||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Boost hides the configuration point for print_log_value in different
|
||||
* namespaces between < 1.59 and >= 1.59.
|
||||
*
|
||||
* The macros can be used to open and close the right level of namespacing
|
||||
* based on the version.
|
||||
*
|
||||
* We could just use a conditionally defined namespace alias, but that
|
||||
* doesn't work in GCC <7 (GCC bug #56480)
|
||||
*
|
||||
* From Boost 1.64, this should be done with boost_test_print_type,
|
||||
* and these defines can be removed once all logging functions use that.
|
||||
*/
|
||||
#if BOOST_VERSION >= 105900
|
||||
#define BOOST_TEST_PRINT_NAMESPACE_OPEN \
|
||||
namespace boost \
|
||||
{ \
|
||||
namespace test_tools \
|
||||
{ \
|
||||
namespace tt_detail
|
||||
#define BOOST_TEST_PRINT_NAMESPACE_CLOSE }}
|
||||
#else
|
||||
#define BOOST_TEST_PRINT_NAMESPACE_OPEN \
|
||||
namespace boost \
|
||||
{ \
|
||||
namespace test_tools
|
||||
#define BOOST_TEST_PRINT_NAMESPACE_CLOSE }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Before Boost 1.64, nullptr_t wasn't handled. Provide our own logging
|
||||
* for nullptr_t's, which helps when doing BOOST_CHECK/REQUIRES on pointers.
|
||||
*
|
||||
* This can be removed when our minimum boost version is 1.64 or higher.
|
||||
*/
|
||||
#if BOOST_VERSION < 106400
|
||||
|
||||
BOOST_TEST_PRINT_NAMESPACE_OPEN
|
||||
{
|
||||
template <>
|
||||
struct print_log_value<nullptr_t>
|
||||
{
|
||||
inline void operator()( std::ostream& os, nullptr_t const& p )
|
||||
{
|
||||
os << "nullptr";
|
||||
}
|
||||
};
|
||||
}
|
||||
BOOST_TEST_PRINT_NAMESPACE_CLOSE
|
||||
|
||||
#endif
|
||||
|
||||
namespace KI_TEST
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue