Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / test / doc / html / boost_test / test_output / test_tools_support_for_logging / test_output_macro_message.html
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
71 <span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test_init</span> <span class="special">)</span>
72 <span class="special">{</span>
73   <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>
74
75   <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Testing initialization :"</span> <span class="special">);</span>
76   <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>
77 <span class="special">}</span>
78
79 <span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test_update</span> <span class="special">)</span>
80 <span class="special">{</span>
81   <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>
82   <span class="keyword">int</span>         <span class="identifier">value</span>      <span class="special">=</span> <span class="number">100</span><span class="special">;</span>
83
84   <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Testing update :"</span> <span class="special">);</span>
85   <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>
86 <span class="special">}</span>
87 </pre>
88                 </td></tr></tbody>
89 </table></div>
90 <div class="informaltable"><table class="table">
91 <colgroup><col></colgroup>
92 <thead><tr><th>
93                   <p>
94                     Output
95                   </p>
96                 </th></tr></thead>
97 <tbody><tr><td>
98 <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>
99 <span class="identifier">Running</span> <span class="number">2</span> <span class="identifier">test</span> <span class="identifier">cases</span><span class="special">...</span>
100 <span class="identifier">Testing</span> <span class="identifier">initialization</span> <span class="special">:</span>
101 <span class="identifier">Current</span> <span class="identifier">time</span><span class="special">:</span><span class="number">0</span>
102 <span class="identifier">Testing</span> <span class="identifier">update</span> <span class="special">:</span>
103 <span class="identifier">Update</span> <span class="identifier">Volume</span> <span class="identifier">with</span> <span class="number">100</span>
104
105 <span class="special">***</span> <span class="identifier">No</span> <span class="identifier">errors</span> <span class="identifier">detected</span>
106 </pre>
107                 </td></tr></tbody>
108 </table></div>
109 </div>
110 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
111 <td align="left"></td>
112 <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2019 Boost.Test
113       contributors<p>
114         Distributed under the Boost Software License, Version 1.0. (See accompanying
115         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>)
116       </p>
117 </div></td>
118 </tr></table>
119 <hr>
120 <div class="spirit-nav">
121 <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>
122 </div>
123 </body>
124 </html>