test_org_boost_test_dataset_fixture.html 5.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>BOOST_DATA_TEST_CASE_F</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_dataset.html" title="BOOST_DATA_TEST_CASE">
  10. <link rel="next" href="test_org_boost_test_suite.html" title="BOOST_TEST_SUITE">
  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_dataset.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_suite.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_fixture"></a><a class="link" href="test_org_boost_test_dataset_fixture.html" title="BOOST_DATA_TEST_CASE_F"><code class="computeroutput"><span class="identifier">BOOST_DATA_TEST_CASE_F</span></code></a>
  28. </h4></div></div></div>
  29. <p>
  30. Declares and registers a data-driven test case, using a particular dataset
  31. and a fixture. This is basically the same as <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> with fixture
  32. support added.
  33. </p>
  34. <pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">my_fixture</span> <span class="special">{</span>
  35. <span class="identifier">my_fixture</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">some_string</span><span class="special">(</span><span class="string">"environment X"</span><span class="special">)</span> <span class="special">{</span>
  36. <span class="special">}</span>
  37. <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">some_string</span><span class="special">;</span>
  38. <span class="special">};</span>
  39. <span class="identifier">BOOST_DATA_TEST_CASE_F</span><span class="special">(</span><span class="identifier">my_fixture</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>
  40. <span class="special">{</span>
  41. <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>
  42. <span class="comment">//...</span>
  43. <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>
  44. <span class="special">}</span>
  45. </pre>
  46. <p>
  47. The fixture should implement the appropriate <a class="link" href="../../tests_organization/fixtures/models.html" title="Fixture models">interface</a>.
  48. As any fixture, it is possible to have test assertions in the fixture class.
  49. </p>
  50. <p>
  51. See <a class="link" href="../../tests_organization/fixtures/case.html" title="Test case fixture">here</a>
  52. for more details on fixtures and <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>
  53. for more details on datasets declaration.
  54. </p>
  55. </div>
  56. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  57. <td align="left"></td>
  58. <td align="right"><div class="copyright-footer">Copyright &#169; 2001-2019 Boost.Test
  59. contributors<p>
  60. Distributed under the Boost Software License, Version 1.0. (See accompanying
  61. 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>)
  62. </p>
  63. </div></td>
  64. </tr></table>
  65. <hr>
  66. <div class="spirit-nav">
  67. <a accesskey="p" href="test_org_boost_test_dataset.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_suite.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
  68. </div>
  69. </body>
  70. </html>