diff --git a/qa/common/test_lib_table.cpp b/qa/common/test_lib_table.cpp index bd073cc3b8..3394524021 100644 --- a/qa/common/test_lib_table.cpp +++ b/qa/common/test_lib_table.cpp @@ -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 ); } diff --git a/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h b/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h index e11f33bf5f..529e4eb182 100644 --- a/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h +++ b/qa/unit_test_utils/include/unit_test_utils/unit_test_utils.h @@ -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 +{ + inline void operator()( std::ostream& os, nullptr_t const& p ) + { + os << "nullptr"; + } +}; +} +BOOST_TEST_PRINT_NAMESPACE_CLOSE + +#endif + namespace KI_TEST {