test_tools_support.qbk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. [/
  2. / Copyright (c) 2015 Boost.Test contributors
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:test_tools_support_for_logging Tools supports for logging]
  8. [/ -------------------------------------------------------------------------------------------------- ]
  9. [section:testing_tool_output_disable Logging user defined types]
  10. Most of the [link boost_test.testing_tools testing tools] print values of their
  11. arguments to the output stream in some form of log statement. If arguments type does not support
  12. ``
  13. operator<<(std::ostream&, ArgumentType const&);
  14. ``
  15. interface, you will get a compilation error.
  16. The __UTF__ supports three different methods for logging user defined types:
  17. # through the `operator<<` for that specific type: any type that implements the above interface has direct support for
  18. logging,
  19. # through a customization point responsible for logging a specific type, which is less intrusive than the implementation
  20. of `operator<<`. This is explained in more details in [link ref_log_output_custom_customization_point this section],
  21. # by prohibiting the [link boost_test.testing_tools testing tools] from logging argument values for
  22. specified type through __BOOST_TEST_DONT_PRINT_LOG_VALUE__.
  23. This is explained in more details in [link ref_log_output_custom_avoid_printing this section].
  24. [#ref_log_output_custom_customization_point]
  25. [h4 User type customization point for logging]
  26. It is possible to indicate a function, `boost_test_print_type`, to __UTF__ that is responsible for the printing of a user defined type, without
  27. the need to override the `operator<<` for that specific type. This is convenient for instance when
  28. the `operator<<` has already been defined for other needs.
  29. The syntax follows the `operator<<`, and this function should be in the same namespace as the type:
  30. ```
  31. std::ostream& boost_test_print_type(std::ostream& ostr, ArgumentType const& right);
  32. ```
  33. [bt_example logger-customization-point..Logging customization point usage..run-fail]
  34. [#ref_log_output_custom_avoid_printing]
  35. [h4 Prohibiting the printing of a specific type]
  36. To prohibit the printing of a specific type, use the following statement on file level before first
  37. test case that includes statement failing to compile:
  38. ``
  39. BOOST_TEST_DONT_PRINT_LOG_VALUE(ArgumentType)
  40. ``
  41. [bt_example example32..BOOST_TEST_DONT_PRINT_LOG_VALUE usage..run-fail]
  42. [endsect] [/section:testing_tool_output_disable]
  43. [/ -------------------------------------------------------------------------------------------------- ]
  44. [section:test_output_macro_message Custom messages]
  45. The macro __BOOST_TEST_MESSAGE__ is intended to be used for the purpose of injecting an additional message into the
  46. __UTF__ test log. These messages are not intended to indicate any error or warning conditions, but rather as
  47. information/status notifications. The macro signature is as follows:
  48. __BOOST_TEST_MESSAGE__(test_message);
  49. The test_message argument can be as simple as C string literal or any custom expression that you can produce with in a
  50. manner similar to standard `std::iostream` operation.
  51. [important Messages generated by this tool do not appear in test log output with default value of the active log level
  52. threshold. For these messages to appear the active log level threshold has to be set to a value below or equal
  53. to "message".
  54. ]
  55. [bt_example example21..__BOOST_TEST_MESSAGE__ usage..run]
  56. [endsect] [/section:test_output_macro_message]
  57. [/ -------------------------------------------------------------------------------------------------- ]
  58. [include checkpoints.qbk]
  59. [include contexts.qbk]
  60. [include logging_floating_point.qbk]
  61. [endsect] [/ Tools supports for logging]