• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Class test_unit</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="../../header/boost/test/tree/test_unit_hpp.html" title="Header &lt;boost/test/tree/test_unit.hpp&gt;">
9<link rel="prev" href="test_suite.html" title="Class test_suite">
10<link rel="next" href="test_unit_generator.html" title="Class test_unit_generator">
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="test_suite.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../header/boost/test/tree/test_unit_hpp.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="test_unit_generator.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="refentry">
26<a name="boost.unit_test.test_unit"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class test_unit</span></h2>
29<p>boost::unit_test::test_unit</p>
30</div>
31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../header/boost/test/tree/test_unit_hpp.html" title="Header &lt;boost/test/tree/test_unit.hpp&gt;">boost/test/tree/test_unit.hpp</a>&gt;
33
34</span>
35<span class="keyword">class</span> <a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="special">{</span>
36<span class="keyword">public</span><span class="special">:</span>
37  <span class="comment">// types</span>
38  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">test_unit_id</span> <span class="special">&gt;</span>                                  <a name="boost.unit_test.test_unit.id_list"></a><span class="identifier">id_list</span><span class="special">;</span>
39  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">test_unit_fixture_ptr</span> <span class="special">&gt;</span>                         <a name="boost.unit_test.test_unit.fixture_list_t"></a><span class="identifier">fixture_list_t</span><span class="special">;</span>
40  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">decorator</span><span class="special">::</span><span class="identifier">base_ptr</span> <span class="special">&gt;</span>                           <a name="boost.unit_test.test_unit.decor_list_t"></a><span class="identifier">decor_list_t</span><span class="special">;</span>
41  <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">function</span><span class="special">&lt;</span> <a class="link" href="../test_tools/assertion_result.html" title="Class assertion_result">test_tools::assertion_result</a><span class="special">(</span><span class="identifier">test_unit_id</span><span class="special">)</span><span class="special">&gt;</span> <a name="boost.unit_test.test_unit.precondition_t"></a><span class="identifier">precondition_t</span><span class="special">;</span>
42
43  <span class="keyword">enum</span> <a name="boost.unit_test.test_unit.@0"></a>@0 <span class="special">{</span> type = = TUT_ANY <span class="special">}</span><span class="special">;</span>
44
45  <span class="keyword">enum</span> <a name="boost.unit_test.test_unit.run_status"></a>run_status <span class="special">{</span> RS_DISABLED, RS_ENABLED, RS_INHERIT, RS_INVALID <span class="special">}</span><span class="special">;</span>
46
47  <span class="comment">// <a class="link" href="test_unit.html#boost.unit_test.test_unitconstruct-copy-destruct">construct/copy/destruct</a></span>
48  <a class="link" href="test_unit.html#idm45267286620448-bb"><span class="identifier">test_unit</span></a><span class="special">(</span><span class="identifier">const_string</span><span class="special">,</span> <span class="identifier">const_string</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">,</span> <span class="identifier">test_unit_type</span><span class="special">)</span><span class="special">;</span>
49  <span class="keyword">explicit</span> <a class="link" href="test_unit.html#idm45267286617408-bb"><span class="identifier">test_unit</span></a><span class="special">(</span><span class="identifier">const_string</span><span class="special">)</span><span class="special">;</span>
50  <a class="link" href="test_unit.html#idm45267286620736-bb"><span class="special">~</span><span class="identifier">test_unit</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
51
52  <span class="comment">// <a class="link" href="test_unit.html#idm45267286646880-bb">public member functions</a></span>
53  <span class="keyword">typedef</span> <a class="link" href="test_unit.html#idm45267286646320-bb"><span class="identifier">BOOST_READONLY_PROPERTY</span></a><span class="special">(</span><span class="identifier">test_unit_id</span><span class="special">,</span> <span class="special">(</span><span class="identifier">framework</span><span class="special">::</span><span class="identifier">state</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
54  <span class="keyword">typedef</span> <a class="link" href="test_unit.html#idm45267286644096-bb"><span class="identifier">BOOST_READONLY_PROPERTY</span></a><span class="special">(</span><span class="identifier">test_unit_id</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_suite.html" title="Class test_suite">test_suite</a><span class="special">)</span><span class="special">)</span><span class="special">;</span>
55  <span class="keyword">typedef</span> <a class="link" href="test_unit.html#idm45267286641424-bb"><span class="identifier">BOOST_READONLY_PROPERTY</span></a><span class="special">(</span><span class="identifier">id_list</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a><span class="special">)</span><span class="special">)</span><span class="special">;</span>
56  <span class="keyword">typedef</span> <a class="link" href="test_unit.html#idm45267286638752-bb"><span class="identifier">BOOST_READONLY_PROPERTY</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a><span class="special">)</span><span class="special">)</span><span class="special">;</span>
57  <span class="keyword">typedef</span> <a class="link" href="test_unit.html#idm45267286636064-bb"><span class="identifier">BOOST_READONLY_PROPERTY</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">precondition_t</span> <span class="special">&gt;</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a><span class="special">)</span><span class="special">)</span><span class="special">;</span>
58  <span class="keyword">void</span> <a class="link" href="test_unit.html#idm45267286633376-bb"><span class="identifier">depends_on</span></a><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="special">*</span><span class="special">)</span><span class="special">;</span>
59  <span class="keyword">void</span> <a class="link" href="test_unit.html#idm45267286631552-bb"><span class="identifier">add_precondition</span></a><span class="special">(</span><span class="identifier">precondition_t</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
60  <a class="link" href="../test_tools/assertion_result.html" title="Class assertion_result">test_tools::assertion_result</a> <a class="link" href="test_unit.html#idm45267286630016-bb"><span class="identifier">check_preconditions</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
61  <span class="keyword">void</span> <a class="link" href="test_unit.html#idm45267286628752-bb"><span class="identifier">add_label</span></a><span class="special">(</span><span class="identifier">const_string</span><span class="special">)</span><span class="special">;</span>
62  <span class="keyword">bool</span> <a class="link" href="test_unit.html#idm45267286627216-bb"><span class="identifier">has_label</span></a><span class="special">(</span><span class="identifier">const_string</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
63  <span class="keyword">void</span> <a class="link" href="test_unit.html#idm45267286625408-bb"><span class="identifier">increase_exp_fail</span></a><span class="special">(</span><span class="identifier">counter_t</span><span class="special">)</span><span class="special">;</span>
64  <span class="keyword">bool</span> <a class="link" href="test_unit.html#idm45267286623872-bb"><span class="identifier">is_enabled</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
65  <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a class="link" href="test_unit.html#idm45267286622752-bb"><span class="identifier">full_name</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
66
67  <span class="comment">// public data members</span>
68  <span class="identifier">test_unit_type</span> <span class="keyword">const</span> <span class="identifier">p_type</span><span class="special">;</span>  <span class="comment">// type for this test unit </span>
69  <span class="identifier">const_string</span> <span class="keyword">const</span> <span class="identifier">p_type_name</span><span class="special">;</span>  <span class="comment">// "case"/"suite"/"module" </span>
70  <span class="identifier">const_string</span> <span class="keyword">const</span> <span class="identifier">p_file_name</span><span class="special">;</span>
71  <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="keyword">const</span> <span class="identifier">p_line_num</span><span class="special">;</span>
72  <span class="identifier">id_t</span> <span class="identifier">p_id</span><span class="special">;</span>  <span class="comment">// unique id for this test unit </span>
73  <span class="identifier">parent_id_t</span> <span class="identifier">p_parent_id</span><span class="special">;</span>  <span class="comment">// parent test suite id </span>
74  <span class="identifier">label_list_t</span> <span class="identifier">p_labels</span><span class="special">;</span>  <span class="comment">// list of labels associated with this test unit </span>
75  <span class="identifier">id_list_t</span> <span class="identifier">p_dependencies</span><span class="special">;</span>  <span class="comment">// list of test units this one depends on </span>
76  <span class="identifier">precond_list_t</span> <span class="identifier">p_preconditions</span><span class="special">;</span>  <span class="comment">// user supplied preconditions for this test unit; </span>
77  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">p_name</span><span class="special">;</span>  <span class="comment">// name for this test unit </span>
78  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="identifier">p_description</span><span class="special">;</span>  <span class="comment">// description for this test unit </span>
79  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="keyword">unsigned</span> <span class="special">&gt;</span> <span class="identifier">p_timeout</span><span class="special">;</span>  <span class="comment">// timeout for the test unit execution in seconds </span>
80  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">counter_t</span> <span class="special">&gt;</span> <span class="identifier">p_expected_failures</span><span class="special">;</span>  <span class="comment">// number of expected failures in this test unit </span>
81  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">run_status</span> <span class="special">&gt;</span> <span class="identifier">p_default_status</span><span class="special">;</span>  <span class="comment">// run status obtained by this unit during setup phase </span>
82  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">run_status</span> <span class="special">&gt;</span> <span class="identifier">p_run_status</span><span class="special">;</span>  <span class="comment">// run status assigned to this unit before execution phase after applying all filters </span>
83  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">counter_t</span> <span class="special">&gt;</span> <span class="identifier">p_sibling_rank</span><span class="special">;</span>  <span class="comment">// rank of this test unit amoung siblings of the same parent </span>
84  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">decor_list_t</span> <span class="special">&gt;</span> <span class="identifier">p_decorators</span><span class="special">;</span>  <span class="comment">// automatically assigned decorators; execution is delayed till framework::finalize_setup_phase function </span>
85  <span class="identifier">readwrite_property</span><span class="special">&lt;</span> <span class="identifier">fixture_list_t</span> <span class="special">&gt;</span> <span class="identifier">p_fixtures</span><span class="special">;</span>  <span class="comment">// fixtures associated with this test unit </span>
86<span class="special">}</span><span class="special">;</span></pre></div>
87<div class="refsect1">
88<a name="idm46175614064784"></a><h2>Description</h2>
89<div class="refsect2">
90<a name="idm46175614064368"></a><h3>
91<a name="boost.unit_test.test_unitconstruct-copy-destruct"></a><code class="computeroutput">test_unit</code>
92        public
93       construct/copy/destruct</h3>
94<div class="orderedlist"><ol class="orderedlist" type="1">
95<li class="listitem"><pre class="literallayout"><a name="idm45267286620448-bb"></a><span class="identifier">test_unit</span><span class="special">(</span><span class="identifier">const_string</span> tu_name<span class="special">,</span> <span class="identifier">const_string</span> tc_file<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> tc_line<span class="special">,</span>
96          <span class="identifier">test_unit_type</span> t<span class="special">)</span><span class="special">;</span></pre></li>
97<li class="listitem"><pre class="literallayout"><span class="keyword">explicit</span> <a name="idm45267286617408-bb"></a><span class="identifier">test_unit</span><span class="special">(</span><span class="identifier">const_string</span> module_name<span class="special">)</span><span class="special">;</span></pre></li>
98<li class="listitem"><pre class="literallayout"><a name="idm45267286620736-bb"></a><span class="special">~</span><span class="identifier">test_unit</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li>
99</ol></div>
100</div>
101<div class="refsect2">
102<a name="idm46175614043424"></a><h3>
103<a name="idm45267286646880-bb"></a><code class="computeroutput">test_unit</code> public member functions</h3>
104<div class="orderedlist"><ol class="orderedlist" type="1">
105<li class="listitem"><pre class="literallayout"><span class="keyword">typedef</span> <a name="idm45267286646320-bb"></a><span class="identifier">BOOST_READONLY_PROPERTY</span><span class="special">(</span><span class="identifier">test_unit_id</span><span class="special">,</span> <span class="special">(</span><span class="identifier">framework</span><span class="special">::</span><span class="identifier">state</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre></li>
106<li class="listitem"><pre class="literallayout"><span class="keyword">typedef</span> <a name="idm45267286644096-bb"></a><span class="identifier">BOOST_READONLY_PROPERTY</span><span class="special">(</span><span class="identifier">test_unit_id</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_suite.html" title="Class test_suite">test_suite</a><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre></li>
107<li class="listitem"><pre class="literallayout"><span class="keyword">typedef</span> <a name="idm45267286641424-bb"></a><span class="identifier">BOOST_READONLY_PROPERTY</span><span class="special">(</span><span class="identifier">id_list</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre></li>
108<li class="listitem"><pre class="literallayout"><span class="keyword">typedef</span> <a name="idm45267286638752-bb"></a><span class="identifier">BOOST_READONLY_PROPERTY</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre></li>
109<li class="listitem"><pre class="literallayout"><span class="keyword">typedef</span> <a name="idm45267286636064-bb"></a><span class="identifier">BOOST_READONLY_PROPERTY</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">precondition_t</span> <span class="special">&gt;</span><span class="special">,</span> <span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre></li>
110<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45267286633376-bb"></a><span class="identifier">depends_on</span><span class="special">(</span><a class="link" href="test_unit.html" title="Class test_unit">test_unit</a> <span class="special">*</span> tu<span class="special">)</span><span class="special">;</span></pre></li>
111<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45267286631552-bb"></a><span class="identifier">add_precondition</span><span class="special">(</span><span class="identifier">precondition_t</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre></li>
112<li class="listitem"><pre class="literallayout"><a class="link" href="../test_tools/assertion_result.html" title="Class assertion_result">test_tools::assertion_result</a> <a name="idm45267286630016-bb"></a><span class="identifier">check_preconditions</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
113<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45267286628752-bb"></a><span class="identifier">add_label</span><span class="special">(</span><span class="identifier">const_string</span> l<span class="special">)</span><span class="special">;</span></pre></li>
114<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45267286627216-bb"></a><span class="identifier">has_label</span><span class="special">(</span><span class="identifier">const_string</span> l<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
115<li class="listitem"><pre class="literallayout"><span class="keyword">void</span> <a name="idm45267286625408-bb"></a><span class="identifier">increase_exp_fail</span><span class="special">(</span><span class="identifier">counter_t</span> num<span class="special">)</span><span class="special">;</span></pre></li>
116<li class="listitem"><pre class="literallayout"><span class="keyword">bool</span> <a name="idm45267286623872-bb"></a><span class="identifier">is_enabled</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
117<li class="listitem"><pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <a name="idm45267286622752-bb"></a><span class="identifier">full_name</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre></li>
118</ol></div>
119</div>
120</div>
121</div>
122<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
123<td align="left"></td>
124<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p>
125        Distributed under the Boost Software License, Version 1.0. (See accompanying
126        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>)
127      </p>
128</div></td>
129</tr></table>
130<hr>
131<div class="spirit-nav">
132<a accesskey="p" href="test_suite.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../header/boost/test/tree/test_unit_hpp.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="test_unit_generator.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
133</div>
134</body>
135</html>
136