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
This commit is contained in:
John Beard 2019-01-11 23:37:44 +00:00 committed by jean-pierre charras
parent 0f1a11ef38
commit 97a37a74f8
2 changed files with 10 additions and 22 deletions

View File

@ -8,17 +8,17 @@
#include <math/box2.h>
#include <math/vector2d.h>
/**
* Printer for BOX2I type
*/
template <> struct BOOST_PRINT::print_log_value<BOX2I>
{
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
{

View File

@ -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