123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
- <title>Custom messages</title>
- <link rel="stylesheet" href="../../../boostbook.css" type="text/css">
- <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
- <link rel="home" href="../../../index.html" title="Boost.Test">
- <link rel="up" href="../test_tools_support_for_logging.html" title="Tools supports for logging">
- <link rel="prev" href="testing_tool_output_disable.html" title="Logging user defined types">
- <link rel="next" href="checkpoints.html" title="Checkpoints for accurate failure location">
- </head>
- <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
- <table cellpadding="2" width="100%"><tr>
- <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
- <td align="center"><a href="../../../../../../../index.html">Home</a></td>
- <td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
- <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
- <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
- <td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
- </tr></table>
- <hr>
- <div class="spirit-nav">
- <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>
- </div>
- <div class="section">
- <div class="titlepage"><div><div><h4 class="title">
- <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
- messages</a>
- </h4></div></div></div>
- <p>
- 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
- to be used for the purpose of injecting an additional message into the
- <span class="emphasis"><em>Unit Test Framework</em></span> test log. These messages are not
- intended to indicate any error or warning conditions, but rather as information/status
- notifications. The macro signature is as follows:
- </p>
- <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>
- </pre>
- <p>
- The test_message argument can be as simple as C string literal or any custom
- 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.
- </p>
- <div class="important"><table border="0" summary="Important">
- <tr>
- <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../../../doc/src/images/important.png"></td>
- <th align="left">Important</th>
- </tr>
- <tr><td align="left" valign="top"><p>
- Messages generated by this tool do not appear in test log output with
- default value of the active log level threshold. For these messages to
- appear the active log level threshold has to be set to a value below
- or equal to "message".
- </p></td></tr>
- </table></div>
- <h6>
- <a name="boost_test.test_output.test_tools_support_for_logging.test_output_macro_message.h0"></a>
- <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:
- <code class="computeroutput"><span class="identifier">BOOST_TEST_MESSAGE</span></code> usage</a>
- </h6>
- <div class="informaltable"><table class="table">
- <colgroup><col></colgroup>
- <thead><tr><th>
- <p>
- Code
- </p>
- </th></tr></thead>
- <tbody><tr><td>
- <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>
- <span class="preprocessor">#include</span> <span class="special"><</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">></span>
- <span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test_init</span> <span class="special">)</span>
- <span class="special">{</span>
- <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>
- <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Testing initialization :"</span> <span class="special">);</span>
- <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Current time:"</span> <span class="special"><<</span> <span class="identifier">current_time</span> <span class="special">);</span>
- <span class="special">}</span>
- <span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test_update</span> <span class="special">)</span>
- <span class="special">{</span>
- <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>
- <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span>
- <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Testing update :"</span> <span class="special">);</span>
- <span class="identifier">BOOST_TEST_MESSAGE</span><span class="special">(</span> <span class="string">"Update "</span> <span class="special"><<</span> <span class="identifier">field_name</span> <span class="special"><<</span> <span class="string">" with "</span> <span class="special"><<</span> <span class="identifier">value</span> <span class="special">);</span>
- <span class="special">}</span>
- </pre>
- </td></tr></tbody>
- </table></div>
- <div class="informaltable"><table class="table">
- <colgroup><col></colgroup>
- <thead><tr><th>
- <p>
- Output
- </p>
- </th></tr></thead>
- <tbody><tr><td>
- <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">></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>
- <span class="identifier">Running</span> <span class="number">2</span> <span class="identifier">test</span> <span class="identifier">cases</span><span class="special">...</span>
- <span class="identifier">Testing</span> <span class="identifier">initialization</span> <span class="special">:</span>
- <span class="identifier">Current</span> <span class="identifier">time</span><span class="special">:</span><span class="number">0</span>
- <span class="identifier">Testing</span> <span class="identifier">update</span> <span class="special">:</span>
- <span class="identifier">Update</span> <span class="identifier">Volume</span> <span class="identifier">with</span> <span class="number">100</span>
- <span class="special">***</span> <span class="identifier">No</span> <span class="identifier">errors</span> <span class="identifier">detected</span>
- </pre>
- </td></tr></tbody>
- </table></div>
- </div>
- <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
- <td align="left"></td>
- <td align="right"><div class="copyright-footer">Copyright © 2001-2019 Boost.Test
- contributors<p>
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- 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>)
- </p>
- </div></td>
- </tr></table>
- <hr>
- <div class="spirit-nav">
- <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>
- </div>
- </body>
- </html>
|