From 97a37a74f86ec963b3dc361375cf4a18309101e8 Mon Sep 17 00:00:00 2001 From: John Beard Date: Fri, 11 Jan 2019 23:37:44 +0000 Subject: [PATCH] QA: Use free operator<< for Boost test logging An unhappy conjunction of GCC bug #56480 [1] and Boost having different namespaces for the print_log_value make it quite ugly to support this method. For the limited purposes of the unit tests, a free function in the unit_test_utils header (in the absence of any implementation in the main libraries) will do, even if it is a little intrusive. From Boost 1.64 onwards, the customisation point boost_test_print_type is avaiable, and anyt print functions should be transitioned over to that method when the minimum Boost version is 1.64 or higher. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 --- .../include/unit_test_utils/geometry.h | 20 +++++++++---------- .../include/unit_test_utils/unit_test_utils.h | 12 ----------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/qa/unit_test_utils/include/unit_test_utils/geometry.h b/qa/unit_test_utils/include/unit_test_utils/geometry.h index cc10cd3814..2f8be6f707 100644 --- a/qa/unit_test_utils/include/unit_test_utils/geometry.h +++ b/qa/unit_test_utils/include/unit_test_utils/geometry.h @@ -8,17 +8,17 @@ #include #include -/** - * Printer for BOX2I type - */ -template <> struct BOOST_PRINT::print_log_value -{ - void operator()( std::ostream& os, const BOX2I& aBox ) - { - os << "BOX[ " << aBox.GetOrigin() << " + " << aBox.GetSize() << " ]"; - } -}; +/** + * Define a stream function for logging this type. + * + * TODO: convert to boost_test_print_type when Boost minver > 1.64 + */ +std::ostream& operator<<( std::ostream& os, const BOX2I& aBox ) +{ + os << "BOX[ " << aBox.GetOrigin() << " + " << aBox.GetSize() << " ]"; + return os; +} namespace KI_TEST { 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 9e54e0fbb4..160d01d55a 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 @@ -77,16 +77,4 @@ #endif -/* - * Define a helper to make it easier to use the right namespace for - * defining the print helpers like this: - * - * template<> - * struct BOOST_PRINT::print_log_value< MY_TYPE > - */ -#if BOOST_VERSION < 105900 -namespace BOOST_PRINT = boost::test_tools; -#else -namespace BOOST_PRINT = boost::test_tools::tt_detail; -#endif #endif // UNIT_TEST_UTILS__H \ No newline at end of file