3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Template test cases</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_cases.html" title="Test cases">
9 <link rel="prev" href="test_case_generation/generators.html" title="Datasets generators">
10 <link rel="next" href="param_test.html" title="Parametrized test cases">
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>
22 <div class="spirit-nav">
23 <a accesskey="p" href="test_case_generation/generators.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_cases.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="param_test.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="boost_test.tests_organization.test_cases.test_organization_templates"></a><a class="link" href="test_organization_templates.html" title="Template test cases">Template
29 </h4></div></div></div>
31 In order to test a template based component, it is frequently necessary
32 to perform the same set of checks for a component instantiated with different
36 One way to perform the same set of checks for a component instantiated
37 with different template parameters would be:
39 <pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
40 <span class="keyword">void</span> <span class="identifier">single_test</span><span class="special">()</span>
41 <span class="special">{</span>
42 <span class="identifier">BOOST_CHECK</span><span class="special">(</span> <span class="comment">/* test assertion */</span> <span class="special">);</span>
43 <span class="special">}</span>
45 <span class="keyword">void</span> <span class="identifier">combined_test</span><span class="special">()</span>
46 <span class="special">{</span>
47 <span class="identifier">single_test</span><span class="special"><</span><span class="keyword">int</span><span class="special">>();</span>
48 <span class="identifier">single_test</span><span class="special"><</span><span class="keyword">float</span><span class="special">>();</span>
49 <span class="identifier">single_test</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">>();</span>
50 <span class="special">}</span>
53 There several problems/inconveniences with above approach, including:
55 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
57 Fatal error in one of the invocation will stop whole test case and
58 will skip invocations with different types
61 You need to repeat function invocation manually for all the parameters
65 You need two functions to implement the test
69 The <span class="emphasis"><em>Unit Test Framework</em></span> provides a facility, the
70 <span class="bold"><strong>template test case</strong></span>, to create a series
71 of test cases based on a list of desired types and <span class="emphasis"><em>nullary</em></span>
72 function. This facility comes with an <a class="link" href="test_organization_templates.html#ref_BOOST_AUTO_TEST_CASE_TEMPLATE">automatic</a>
73 and <a class="link" href="test_organization_templates.html#ref_BOOST_TEST_CASE_TEMPLATE">manual</a> registration
76 <div class="tip"><table border="0" summary="Tip">
78 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../../doc/src/images/tip.png"></td>
79 <th align="left">Tip</th>
81 <tr><td align="left" valign="top"><p>
82 The test case template facility is preferable to the approach in example
83 above, since execution of each sub test case is guarded and counted separately.
84 It produces a better test log/results report (in example above in case
85 of failure you can't say which type is at fault) and allows you to test
86 all types even if one of them causes termination of the sub test case.
89 <a name="ref_BOOST_AUTO_TEST_CASE_TEMPLATE"></a><h5>
90 <a name="boost_test.tests_organization.test_cases.test_organization_templates.h0"></a>
91 <span class="phrase"><a name="boost_test.tests_organization.test_cases.test_organization_templates.template_test_case_with_automate"></a></span><a class="link" href="test_organization_templates.html#boost_test.tests_organization.test_cases.test_organization_templates.template_test_case_with_automate">Template
92 test case with automated registration</a>
95 A template test case, registered automatically and in place of its implementation,
96 is declared through the macro <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_auto_template.html" title="BOOST_AUTO_TEST_CASE_TEMPLATE"><code class="computeroutput"><span class="identifier">BOOST_AUTO_TEST_CASE_TEMPLATE</span></code></a>:
98 <pre class="programlisting"><span class="identifier">BOOST_AUTO_TEST_CASE_TEMPLATE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">formal_type_parameter_name</span><span class="special">,</span> <span class="identifier">collection_of_types</span><span class="special">);</span>
101 The arguments are as follow:
103 <div class="orderedlist"><ol class="orderedlist" type="1">
104 <li class="listitem">
105 <code class="computeroutput"><span class="identifier">test_case_name</span></code>: the
106 test case template name: unique test cases template identifier
108 <li class="listitem">
109 <code class="computeroutput"><span class="identifier">formal_type_parameter_name</span></code>:
110 the name of a formal template parameter: name of the type the test
111 case template is instantiated with
113 <li class="listitem">
114 <code class="computeroutput"><span class="identifier">collection_of_types</span></code>:
115 the collection of types to instantiate test case template with. This
116 is an <span class="bold"><strong>arbitrary MPL sequence</strong></span> or a
117 sequence of types wrapped in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">tuple</span></code>
118 (since <a class="link" href="../../change_log.html#ref_CHANGE_LOG_3_7"><span class="emphasis"><em>Unit Test Framework</em></span>
119 v3.7</a>, if supported by the compiler)
123 The resulting name of the test is a composition of the <code class="computeroutput"><span class="identifier">test_case_name</span></code>
124 parameter and the current type being tested. Since <a class="link" href="../../change_log.html#ref_CHANGE_LOG_3_12"><span class="emphasis"><em>Unit
125 Test Framework</em></span> v3.12</a>, the framework tries to unify the
126 name of the resulting type across various platforms such that they are
127 easier to reference from the <a class="link" href="../../runtime_config/test_unit_filtering.html" title="Test unit filtering">command
131 <a name="boost_test.tests_organization.test_cases.test_organization_templates.h1"></a>
132 <span class="phrase"><a name="boost_test.tests_organization.test_cases.test_organization_templates.example_descr"></a></span><a class="link" href="test_organization_templates.html#boost_test.tests_organization.test_cases.test_organization_templates.example_descr">Example:
133 Test case template with automated registration</a>
135 <div class="informaltable"><table class="table">
136 <colgroup><col></colgroup>
143 <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>
144 <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>
145 <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mpl</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
147 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="keyword">long</span><span class="special">,</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">></span> <span class="identifier">test_types</span><span class="special">;</span>
149 <span class="identifier">BOOST_AUTO_TEST_CASE_TEMPLATE</span><span class="special">(</span> <span class="identifier">my_test</span><span class="special">,</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">test_types</span> <span class="special">)</span>
150 <span class="special">{</span>
151 <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span> <span class="special">==</span> <span class="special">(</span><span class="keyword">unsigned</span><span class="special">)</span><span class="number">4</span> <span class="special">);</span>
152 <span class="special">}</span>
154 <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">tuple</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="keyword">long</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">></span> <span class="identifier">test_types_w_tuples</span><span class="special">;</span>
156 <span class="identifier">BOOST_AUTO_TEST_CASE_TEMPLATE</span><span class="special">(</span> <span class="identifier">my_tuple_test</span><span class="special">,</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">test_types_w_tuples</span> <span class="special">)</span>
157 <span class="special">{</span>
158 <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span> <span class="special">==</span> <span class="special">(</span><span class="keyword">unsigned</span><span class="special">)</span><span class="number">4</span> <span class="special">);</span>
159 <span class="special">}</span>
163 <div class="informaltable"><table class="table">
164 <colgroup><col></colgroup>
171 <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>
172 <span class="identifier">Running</span> <span class="number">3</span> <span class="identifier">test</span> <span class="identifier">cases</span><span class="special">...</span>
173 <span class="identifier">test</span><span class="special">.</span><span class="identifier">cpp</span><span class="special">(</span><span class="number">17</span><span class="special">):</span> <span class="identifier">error</span><span class="special">:</span> <span class="identifier">in</span> <span class="string">"my_test<unsigned char>"</span><span class="special">:</span> <span class="identifier">check</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span> <span class="special">==</span> <span class="special">(</span><span class="keyword">unsigned</span><span class="special">)</span><span class="number">4</span> <span class="identifier">has</span> <span class="identifier">failed</span> <span class="special">[</span><span class="number">1</span> <span class="special">!=</span> <span class="number">4</span><span class="special">]</span>
175 <span class="special">***</span> <span class="number">1</span> <span class="identifier">failure</span> <span class="identifier">is</span> <span class="identifier">detected</span> <span class="identifier">in</span> <span class="identifier">the</span> <span class="identifier">test</span> <span class="identifier">module</span> <span class="string">"example"</span>
179 <div class="warning"><table border="0" summary="Warning">
181 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../../doc/src/images/warning.png"></td>
182 <th align="left">Warning</th>
184 <tr><td align="left" valign="top"><p>
185 Since <a class="link" href="../../change_log.html#ref_CHANGE_LOG_3_7"><span class="emphasis"><em>Unit Test Framework</em></span>
186 v3.7</a>, the <span class="emphasis"><em>Unit Test Framework</em></span> does not allow
187 for duplicate test case name under the same test suite. As test names
188 are derived from the types in the <code class="computeroutput"><span class="identifier">collection_of_types</span></code>,
189 this indirectly means that <span class="bold"><strong>having a duplicate type</strong></span>
190 in the <code class="computeroutput"><span class="identifier">collection_of_types</span></code>
191 <span class="bold"><strong>yields an error</strong></span>.
194 <div class="note"><table border="0" summary="Note">
196 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
197 <th align="left">Note</th>
199 <tr><td align="left" valign="top">
201 If you prefer having the template parameter list directly in the declaration
202 of <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_auto_template.html" title="BOOST_AUTO_TEST_CASE_TEMPLATE"><code class="computeroutput"><span class="identifier">BOOST_AUTO_TEST_CASE_TEMPLATE</span></code></a>,
203 you may use the macro <a href="../../../www.boost.org/doc/libs/release/libs/utility/identity_type/doc/html/index.html" target="_top"><code class="computeroutput"><span class="identifier">BOOST_IDENTITY_TYPE</span></code></a>. The previous
204 example gives (note the double parenthesis around the MPL list):
206 <pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">/</span><span class="identifier">identity_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
208 <span class="identifier">BOOST_AUTO_TEST_CASE_TEMPLATE</span><span class="special">(</span>
209 <span class="identifier">my_test</span><span class="special">,</span>
210 <span class="identifier">T</span><span class="special">,</span>
211 <span class="identifier">BOOST_IDENTITY_TYPE</span><span class="special">((</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span>
212 <span class="keyword">int</span><span class="special">,</span>
213 <span class="keyword">long</span><span class="special">,</span>
214 <span class="keyword">unsigned</span> <span class="keyword">char</span>
215 <span class="special">>))</span> <span class="special">)</span>
216 <span class="special">{</span>
217 <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span> <span class="special">==</span> <span class="special">(</span><span class="keyword">unsigned</span><span class="special">)</span><span class="number">4</span> <span class="special">);</span>
218 <span class="special">}</span>
222 <a name="ref_BOOST_TEST_CASE_TEMPLATE"></a><h5>
223 <a name="boost_test.tests_organization.test_cases.test_organization_templates.h2"></a>
224 <span class="phrase"><a name="boost_test.tests_organization.test_cases.test_organization_templates.test_case_template_with_manual_r"></a></span><a class="link" href="test_organization_templates.html#boost_test.tests_organization.test_cases.test_organization_templates.test_case_template_with_manual_r">Test
225 case template with manual registration</a>
228 To manually register template test cases, two macros should be used:
230 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
231 <li class="listitem">
232 <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_template_function.html" title="BOOST_TEST_CASE_TEMPLATE_FUNCTION"><code class="computeroutput"><span class="identifier">BOOST_TEST_CASE_TEMPLATE_FUNCTION</span></code></a>
233 to define the template test case body
235 <li class="listitem">
236 <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_template.html" title="BOOST_TEST_CASE_TEMPLATE"><code class="computeroutput"><span class="identifier">BOOST_TEST_CASE_TEMPLATE</span></code></a> to
237 register the test case based on the previous declaration
241 The macro <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_template_function.html" title="BOOST_TEST_CASE_TEMPLATE_FUNCTION"><code class="computeroutput"><span class="identifier">BOOST_TEST_CASE_TEMPLATE_FUNCTION</span></code></a>
242 requires two arguments:
244 <div class="orderedlist"><ol class="orderedlist" type="1">
245 <li class="listitem">
246 the name of the test case template and
248 <li class="listitem">
249 the name of the format type parameter
252 <pre class="programlisting"><span class="identifier">BOOST_TEST_CASE_TEMPLATE_FUNCTION</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">type_name</span><span class="special">);</span>
254 <pre class="programlisting"><span class="identifier">BOOST_TEST_CASE_TEMPLATE_FUNCTION</span><span class="special">(</span> <span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">type_name</span> <span class="special">)</span>
255 <span class="special">{</span>
256 <span class="comment">// test case template body</span>
257 <span class="special">}</span>
260 The macro <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_template_function.html" title="BOOST_TEST_CASE_TEMPLATE_FUNCTION"><code class="computeroutput"><span class="identifier">BOOST_TEST_CASE_TEMPLATE_FUNCTION</span></code></a>
261 is intended to be used in place of nullary function template signature:
263 <pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">type_name</span><span class="special">></span>
264 <span class="keyword">void</span> <span class="identifier">test_case_name</span><span class="special">()</span>
265 <span class="special">{</span>
266 <span class="comment">// test case template body</span>
267 <span class="special">}</span>
270 The only difference is that the <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_template_function.html" title="BOOST_TEST_CASE_TEMPLATE_FUNCTION"><code class="computeroutput"><span class="identifier">BOOST_TEST_CASE_TEMPLATE_FUNCTION</span></code></a>
271 makes the test case template name usable in the template argument list.
274 <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_template.html" title="BOOST_TEST_CASE_TEMPLATE"><code class="computeroutput"><span class="identifier">BOOST_TEST_CASE_TEMPLATE</span></code></a> requires
277 <div class="orderedlist"><ol class="orderedlist" type="1">
278 <li class="listitem">
279 the name of the test case template and
281 <li class="listitem">
282 Boost.MPL compatible collection of types to instantiate it with.
286 The names passed to both macros should be the same.
288 <pre class="programlisting"><span class="identifier">BOOST_TEST_CASE_TEMPLATE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">collection_of_types</span><span class="special">);</span>
291 <a name="boost_test.tests_organization.test_cases.test_organization_templates.h3"></a>
292 <span class="phrase"><a name="boost_test.tests_organization.test_cases.test_organization_templates.example_descr0"></a></span><a class="link" href="test_organization_templates.html#boost_test.tests_organization.test_cases.test_organization_templates.example_descr0">Example:
293 Manually registered test case template</a>
295 <div class="informaltable"><table class="table">
296 <colgroup><col></colgroup>
303 <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><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>
304 <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">mpl</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
305 <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">unit_test</span><span class="special">;</span>
307 <span class="identifier">BOOST_TEST_CASE_TEMPLATE_FUNCTION</span><span class="special">(</span> <span class="identifier">my_test</span><span class="special">,</span> <span class="identifier">T</span> <span class="special">)</span>
308 <span class="special">{</span>
309 <span class="identifier">BOOST_TEST</span><span class="special">(</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span> <span class="special">==</span> <span class="number">4U</span> <span class="special">);</span>
310 <span class="special">}</span>
312 <span class="identifier">test_suite</span><span class="special">*</span> <span class="identifier">init_unit_test_suite</span><span class="special">(</span> <span class="keyword">int</span> <span class="comment">/*argc*/</span><span class="special">,</span> <span class="keyword">char</span><span class="special">*</span> <span class="comment">/*argv*/</span><span class="special">[]</span> <span class="special">)</span>
313 <span class="special">{</span>
314 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span><span class="keyword">long</span><span class="special">,</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">></span> <span class="identifier">test_types</span><span class="special">;</span>
316 <span class="identifier">framework</span><span class="special">::</span><span class="identifier">master_test_suite</span><span class="special">().</span>
317 <span class="identifier">add</span><span class="special">(</span> <span class="identifier">BOOST_TEST_CASE_TEMPLATE</span><span class="special">(</span> <span class="identifier">my_test</span><span class="special">,</span> <span class="identifier">test_types</span> <span class="special">)</span> <span class="special">);</span>
319 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
320 <span class="special">}</span>
324 <div class="informaltable"><table class="table">
325 <colgroup><col></colgroup>
332 <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>
333 <span class="identifier">Running</span> <span class="number">3</span> <span class="identifier">test</span> <span class="identifier">cases</span><span class="special">...</span>
334 <span class="identifier">test</span><span class="special">.</span><span class="identifier">cpp</span><span class="special">(</span><span class="number">15</span><span class="special">):</span> <span class="identifier">error</span><span class="special">:</span> <span class="identifier">in</span> <span class="string">"my_test<unsigned char>"</span><span class="special">:</span> <span class="identifier">check</span> <span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span> <span class="special">==</span> <span class="number">4U</span> <span class="identifier">has</span> <span class="identifier">failed</span> <span class="special">[</span><span class="number">1</span> <span class="special">!=</span> <span class="number">4</span><span class="special">]</span>
336 <span class="special">***</span> <span class="number">1</span> <span class="identifier">failure</span> <span class="identifier">is</span> <span class="identifier">detected</span> <span class="identifier">in</span> <span class="identifier">the</span> <span class="identifier">test</span> <span class="identifier">module</span> <span class="string">"Master Test Suite"</span>
341 <a class="link" href="../../utf_reference/test_org_reference/test_org_boost_test_case_template.html" title="BOOST_TEST_CASE_TEMPLATE"><code class="computeroutput"><span class="identifier">BOOST_TEST_CASE_TEMPLATE</span></code></a> creates
342 an instance of the test case generator. When passed to the method <code class="computeroutput"><a class="link" href="../../../boost/unit_test/test_suite.html#idm46279112866240-bb">test_suite::add</a></code>,
343 the generator produces a separate sub test case for each type in the supplied
344 collection of types and registers it immediately in the test suite. Each
345 test case is based on the test case template body instantiated with a particular
349 The names for the <span class="emphasis"><em>sub test cases</em></span> are deduced from
350 the macro argument <code class="computeroutput"><span class="identifier">test_case_name</span></code>.
351 If you prefer to assign different test case names, you need to use the
352 underlying <code class="computeroutput"><a class="link" href="../../../header/boost/test/tree/test_unit_hpp.html" title="Header <boost/test/tree/test_unit.hpp>">make_test_case</a></code> interface
353 instead. Both test cases creation and registration is performed in the
354 test module initialization function.
356 <div class="warning"><table border="0" summary="Warning">
358 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../../doc/src/images/warning.png"></td>
359 <th align="left">Warning</th>
361 <tr><td align="left" valign="top"><p>
362 Since <a class="link" href="../../change_log.html#ref_CHANGE_LOG_3_7"><span class="emphasis"><em>Unit Test Framework</em></span>
363 v3.7</a>, the <span class="emphasis"><em>Unit Test Framework</em></span> does not allow
364 for duplicate test case name under the same test suite. As test names
365 are derived from the types in the <code class="computeroutput"><span class="identifier">collection_of_types</span></code>,
366 this indirectly means that having a duplicate of types in the <code class="computeroutput"><span class="identifier">collection_of_types</span></code> will yield an error.
370 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
371 <td align="left"></td>
372 <td align="right"><div class="copyright-footer">Copyright © 2001-2019 Boost.Test
374 Distributed under the Boost Software License, Version 1.0. (See accompanying
375 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>)
380 <div class="spirit-nav">
381 <a accesskey="p" href="test_case_generation/generators.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_cases.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="param_test.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>