test_output_macro_message.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Custom messages</title>
  5. <link rel="stylesheet" href="../../../boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="../../../index.html" title="Boost.Test">
  8. <link rel="up" href="../test_tools_support_for_logging.html" title="Tools supports for logging">
  9. <link rel="prev" href="testing_tool_output_disable.html" title="Logging user defined types">
  10. <link rel="next" href="checkpoints.html" title="Checkpoints for accurate failure location">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="testing_tool_output_disable.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_tools_support_for_logging.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="checkpoints.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h4 class="title">
  27. <a name="boost_test.test_output.test_tools_support_for_logging.test_output_macro_message"></a><a class="link" href="test_output_macro_message.html" title="Custom messages">Custom
  28. messages</a>
  29. </h4></div></div></div>
  30. <p>
  31. The macro <a class="link" href="../../utf_reference/testout_reference/test_output_macro_message.html" title="BOOST_TEST_MESSAGE"><code class="computeroutput"><span class="identifier">BOOST_TEST_MESSAGE</span></code></a> is intended
  32. to be used for the purpose of injecting an additional message into the
  33. <span class="emphasis"><em>Unit Test Framework</em></span> test log. These messages are not
  34. intended to indicate any error or warning conditions, but rather as information/status
  35. notifications. The macro signature is as follows:
  36. </p>
  37. <pre class="programlisting"><a class="link" href="../../utf_reference/testout_reference/test_output_macro_message.html" title="BOOST_TEST_MESSAGE"><code class="computeroutput"><span class="identifier">BOOST_TEST_MESSAGE</span></code></a><span class="special">(</span><span class="identifier">test_message</span><span class="special">);</span>
  38. </pre>
  39. <p>
  40. The test_message argument can be as simple as C string literal or any custom
  41. expression that you can produce with in a manner similar to standard <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">iostream</span></code> operation.
  42. </p>
  43. <div class="important"><table border="0" summary="Important">
  44. <tr>
  45. <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../../doc/src/images/important.png"></td>
  46. <th align="left">Important</th>
  47. </tr>
  48. <tr><td align="left" valign="top"><p>
  49. Messages generated by this tool do not appear in test log output with
  50. default value of the active log level threshold. For these messages to
  51. appear the active log level threshold has to be set to a value below
  52. or equal to "message".
  53. </p></td></tr>
  54. </table></div>
  55. <h6>
  56. <a name="boost_test.test_output.test_tools_support_for_logging.test_output_macro_message.h0"></a>
  57. <span class="phrase"><a name="boost_test.test_output.test_tools_support_for_logging.test_output_macro_message.example_descr"></a></span><a class="link" href="test_output_macro_message.html#boost_test.test_output.test_tools_support_for_logging.test_output_macro_message.example_descr">Example:
  58. <code class="computeroutput"><span class="identifier">BOOST_TEST_MESSAGE</span></code> usage</a>
  59. </h6>
  60. <div class="informaltable"><table class="table">
  61. <colgroup><col></colgroup>
  62. <thead><tr><th>
  63. <p>
  64. Code
  65. </p>
  66. </th></tr></thead>
  67. <tbody><tr><td>
  68. <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_TEST_MODULE</span> <span class="identifier">example</span>
  69. <span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">included</span><span class="special">/</span><span class="identifier">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
  70. <span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test_init</span> <span class="special">)</span>
  71. <span class="special">{</span>
  72. <span class="keyword">int</span> <span class="identifier">current_time</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="comment">// real call is required here</span>
  73. <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Testing initialization :"</span> <span class="special">);</span>
  74. <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Current time:"</span> <span class="special">&lt;&lt;</span> <span class="identifier">current_time</span> <span class="special">);</span>
  75. <span class="special">}</span>
  76. <span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test_update</span> <span class="special">)</span>
  77. <span class="special">{</span>
  78. <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">field_name</span> <span class="special">=</span> <span class="string">"Volume"</span><span class="special">;</span>
  79. <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span>
  80. <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Testing update :"</span> <span class="special">);</span>
  81. <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Update "</span> <span class="special">&lt;&lt;</span> <span class="identifier">field_name</span> <span class="special">&lt;&lt;</span> <span class="string">" with "</span> <span class="special">&lt;&lt;</span> <span class="identifier">value</span> <span class="special">);</span>
  82. <span class="special">}</span>
  83. </pre>
  84. </td></tr></tbody>
  85. </table></div>
  86. <div class="informaltable"><table class="table">
  87. <colgroup><col></colgroup>
  88. <thead><tr><th>
  89. <p>
  90. Output
  91. </p>
  92. </th></tr></thead>
  93. <tbody><tr><td>
  94. <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">&gt;</span> <span class="identifier">example</span> <span class="special">--</span><span class="identifier">log_level</span><span class="special">=</span><span class="identifier">message</span>
  95. <span class="identifier">Running</span> <span class="number">2</span> <span class="identifier">test</span> <span class="identifier">cases</span><span class="special">...</span>
  96. <span class="identifier">Testing</span> <span class="identifier">initialization</span> <span class="special">:</span>
  97. <span class="identifier">Current</span> <span class="identifier">time</span><span class="special">:</span><span class="number">0</span>
  98. <span class="identifier">Testing</span> <span class="identifier">update</span> <span class="special">:</span>
  99. <span class="identifier">Update</span> <span class="identifier">Volume</span> <span class="identifier">with</span> <span class="number">100</span>
  100. <span class="special">***</span> <span class="identifier">No</span> <span class="identifier">errors</span> <span class="identifier">detected</span>
  101. </pre>
  102. </td></tr></tbody>
  103. </table></div>
  104. </div>
  105. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  106. <td align="left"></td>
  107. <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2019 Boost.Test
  108. contributors<p>
  109. Distributed under the Boost Software License, Version 1.0. (See accompanying
  110. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  111. </p>
  112. </div></td>
  113. </tr></table>
  114. <hr>
  115. <div class="spirit-nav">
  116. <a accesskey="p" href="testing_tool_output_disable.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_tools_support_for_logging.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="checkpoints.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
  117. </div>
  118. </body>
  119. </html>