logger-customization-point.run-fail.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. //! @file
  8. //! Customization point for printing user defined types
  9. // *****************************************************************************
  10. //[example_code
  11. #define BOOST_TEST_MODULE logger-customization-point
  12. #include <boost/test/included/unit_test.hpp>
  13. namespace user_defined_namespace {
  14. struct user_defined_type {
  15. int value;
  16. user_defined_type(int value_) : value(value_)
  17. {}
  18. bool operator==(int right) const {
  19. return right == value;
  20. }
  21. };
  22. }
  23. namespace user_defined_namespace {
  24. std::ostream& boost_test_print_type(std::ostream& ostr, user_defined_type const& right) {
  25. ostr << "** value of user_defined_type is " << right.value << " **";
  26. return ostr;
  27. }
  28. }
  29. BOOST_AUTO_TEST_CASE(test1)
  30. {
  31. user_defined_namespace::user_defined_type t(10);
  32. BOOST_TEST(t == 11);
  33. using namespace user_defined_namespace;
  34. user_defined_type t2(11);
  35. BOOST_TEST(t2 == 11);
  36. }
  37. //]