1 // (C) Copyright Raffi Enficiaud 2017. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 // See http://www.boost.org/libs/test for the library home page. 7 // 8 //! @file 9 //! Customization point for printing user defined types 10 // ***************************************************************************** 11 12 //[example_code 13 #define BOOST_TEST_MODULE logger-customization-point 14 #include <boost/test/included/unit_test.hpp> 15 16 namespace user_defined_namespace { 17 struct user_defined_type { 18 int value; 19 user_defined_typeuser_defined_namespace::user_defined_type20 user_defined_type(int value_) : value(value_) 21 {} 22 operator ==user_defined_namespace::user_defined_type23 bool operator==(int right) const { 24 return right == value; 25 } 26 }; 27 } 28 29 namespace user_defined_namespace { boost_test_print_type(std::ostream & ostr,user_defined_type const & right)30 std::ostream& boost_test_print_type(std::ostream& ostr, user_defined_type const& right) { 31 ostr << "** value of user_defined_type is " << right.value << " **"; 32 return ostr; 33 } 34 } 35 BOOST_AUTO_TEST_CASE(test1)36BOOST_AUTO_TEST_CASE(test1) 37 { 38 user_defined_namespace::user_defined_type t(10); 39 BOOST_TEST(t == 11); 40 41 using namespace user_defined_namespace; 42 user_defined_type t2(11); 43 BOOST_TEST(t2 == 11); 44 } 45 //] 46