• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>BOOST_TEST_NO_MAIN</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="../link_references.html" title="Build scenarios and behaviors">
9<link rel="prev" href="link_boost_test_dyn_link.html" title="BOOST_TEST_DYN_LINK">
10<link rel="next" href="link_boost_test_global_configuration.html" title="BOOST_TEST_GLOBAL_CONFIGURATION">
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="link_boost_test_dyn_link.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../link_references.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="link_boost_test_global_configuration.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.utf_reference.link_references.link_boost_test_no_main"></a><a class="link" href="link_boost_test_no_main.html" title="BOOST_TEST_NO_MAIN"><code class="computeroutput"><span class="identifier">BOOST_TEST_NO_MAIN</span></code></a>
28</h4></div></div></div>
29<p>
30          Prevents the auto generation of the test module initialization functions.
31          This macro is particularly relevant for manually registered tests in conjunction
32          with dynamic variant of the <span class="emphasis"><em>Unit Test Framework</em></span>. When
33          defined, a <code class="computeroutput"><span class="identifier">main</span></code> function
34          registering all the tests should be implemented.
35        </p>
36<p>
37          An example of a module initialization would be
38        </p>
39<pre class="programlisting"><span class="preprocessor">#define</span> <a class="link" href="link_boost_test_no_main.html" title="BOOST_TEST_NO_MAIN"><code class="computeroutput"><span class="identifier">BOOST_TEST_NO_MAIN</span></code></a>
40<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">unit_test</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
41
42<span class="comment">// a function in another compilation unit registering tests under the master test suite.</span>
43<span class="keyword">void</span> <span class="identifier">register_some_tests_manually</span><span class="special">(</span><span class="identifier">test_suite</span><span class="special">*</span> <span class="identifier">test</span><span class="special">);</span>
44
45<span class="keyword">bool</span> <span class="identifier">registering_all_tests</span><span class="special">()</span>
46<span class="special">{</span>
47  <span class="identifier">test_suite</span><span class="special">*</span> <span class="identifier">test_master_suite</span> <span class="special">=</span> <span class="special">&amp;</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">framework</span><span class="special">::</span><span class="identifier">master_test_suite</span><span class="special">();</span>
48  <span class="identifier">register_some_tests_manually</span><span class="special">(</span><span class="identifier">test_master_suite</span><span class="special">);</span>
49
50  <span class="comment">// register any other tests function or test suite to the master test suite</span>
51  <span class="comment">// ...</span>
52  <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span>
53<span class="special">}</span>
54
55<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">argv</span><span class="special">[])</span>
56<span class="special">{</span>
57  <span class="keyword">return</span> <span class="special">::</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">::</span><span class="identifier">unit_test_main</span><span class="special">(&amp;</span><span class="identifier">registering_all_tests</span><span class="special">,</span> <span class="identifier">argc</span><span class="special">,</span> <span class="identifier">argv</span><span class="special">);</span>
58<span class="special">}</span>
59</pre>
60</div>
61<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
62<td align="left"></td>
63<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p>
64        Distributed under the Boost Software License, Version 1.0. (See accompanying
65        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>)
66      </p>
67</div></td>
68</tr></table>
69<hr>
70<div class="spirit-nav">
71<a accesskey="p" href="link_boost_test_dyn_link.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../link_references.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="link_boost_test_global_configuration.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
72</div>
73</body>
74</html>
75