1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>BOOST_DATA_TEST_CASE</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_org_reference.html" title="Tests declaration and organization"> 9<link rel="prev" href="test_org_boost_test_case_parameter.html" title="BOOST_PARAM_TEST_CASE"> 10<link rel="next" href="test_org_boost_test_dataset_fixture.html" title="BOOST_DATA_TEST_CASE_F"> 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_org_boost_test_case_parameter.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_org_reference.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_org_boost_test_dataset_fixture.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.test_org_reference.test_org_boost_test_dataset"></a><a class="link" href="test_org_boost_test_dataset.html" title="BOOST_DATA_TEST_CASE"><code class="computeroutput"><span class="identifier">BOOST_DATA_TEST_CASE</span></code></a> 28</h4></div></div></div> 29<p> 30 Declares and registers a data-driven test case, using a particular dataset. 31 </p> 32<p> 33 Several forms of the macro are available. 34 </p> 35<pre class="programlisting"><span class="identifier">BOOST_DATA_TEST_CASE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">dataset</span><span class="special">)</span> 36<span class="special">{</span> 37 <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sample</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span> 38<span class="special">}</span> 39</pre> 40<p> 41 should be used for datasets with arity 1. In the body of the test case, 42 the samples of the dataset are taken by the variable <code class="computeroutput"><span class="identifier">sample</span></code>. 43 </p> 44<pre class="programlisting"><span class="identifier">BOOST_DATA_TEST_CASE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">dataset</span><span class="special">,</span> <span class="identifier">var1</span><span class="special">)</span> 45<span class="special">{</span> 46 <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">var1</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span> 47<span class="special">}</span> 48</pre> 49<p> 50 same as the first form, but the samples are taken by the variable <code class="computeroutput"><span class="identifier">var1</span></code> instead of the variable <code class="computeroutput"><span class="identifier">sample</span></code> 51 </p> 52<pre class="programlisting"><span class="identifier">BOOST_DATA_TEST_CASE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">dataset</span><span class="special">,</span> <span class="identifier">var1</span><span class="special">,</span> <span class="identifier">var2</span><span class="special">...,</span> <span class="identifier">varN</span><span class="special">)</span> 53<span class="special">{</span> 54 <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">var1</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span> 55 <span class="comment">//...</span> 56 <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">varN</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span> 57<span class="special">}</span> 58</pre> 59<p> 60 same as the second form, but for dataset of arity <code class="computeroutput"><span class="identifier">N</span></code>. 61 </p> 62<p> 63 For compilers <span class="bold"><strong>lacking the variadic template</strong></span> 64 support, the maximal arity (the maximal value of <code class="computeroutput"><span class="identifier">N</span></code>) 65 is controlled by the macro <code class="computeroutput"><span class="identifier">BOOST_TEST_DATASET_MAX_ARITY</span></code> 66 which is set to <code class="computeroutput"><span class="number">10</span></code> by default. 67 If you need a greater value, define <code class="computeroutput"><span class="identifier">BOOST_TEST_DATASET_MAX_ARITY</span></code> 68 to the desired value <span class="bold"><strong>before</strong></span> including 69 the <span class="emphasis"><em>Unit Test Framework</em></span> headers. 70 </p> 71<p> 72 See <a class="link" href="../../tests_organization/test_cases/test_case_generation/datasets_auto_registration.html" title="Declaring and registering test cases with datasets">here</a> 73 for more details. 74 </p> 75</div> 76<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 77<td align="left"></td> 78<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p> 79 Distributed under the Boost Software License, Version 1.0. (See accompanying 80 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>) 81 </p> 82</div></td> 83</tr></table> 84<hr> 85<div class="spirit-nav"> 86<a accesskey="p" href="test_org_boost_test_case_parameter.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_org_reference.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_org_boost_test_dataset_fixture.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 87</div> 88</body> 89</html> 90