/Src/Dependencies/Boost/libs/test/doc/html/utf/user-guide/test-organization/auto-nullary-test-case.html

http://hadesmem.googlecode.com/ · HTML · 89 lines · 84 code · 5 blank · 0 comment · 0 complexity · 5c06f4f02db558f9050d02e4f822d302 MD5 · raw file

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  4. <title>Nullary function based test case with automated registration</title>
  5. <link rel="stylesheet" href="../../../../style/style.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
  7. <link rel="home" href="../../../index.html" title="Boost Test Library">
  8. <link rel="up" href="nullary-test-case.html" title="Nullary function based test case">
  9. <link rel="prev" href="manual-nullary-test-case.html" title="Manually registered nullary function based test case">
  10. <link rel="next" href="unary-test-case.html" title="Unary function based test case">
  11. <script language="JavaScript1.2" src="../../../../js/boost-test.js"></script>
  12. </head>
  13. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  14. <table width="100%"><tr>
  15. <td width="10%"><a href="../../../index.html"><img alt="Home" width="229" height="61" border="0" src="../../../../../../../libs/test/docbook/img/boost.test.logo.png"></a></td>
  16. <td valign="middle" align="left"> &gt; <a href="../../../utf.html">The Unit Test Framework</a> &gt; <a href="../../user-guide.html">User's guide</a><a href="../../testing-tools.html">
  17. &gt;
  18. </a><a href="../test-organization.html">Test organization</a><a href="../fixture.html">
  19. &gt;
  20. </a><a href="nullary-test-case.html">Nullary function based test case</a><a href="unary-test-case.html">
  21. &gt;
  22. </a><b>Automated registration</b>
  23. </td>
  24. <td><div class="spirit-nav">
  25. <a href="manual-nullary-test-case.html"><img src="../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a href="unary-test-case.html"><img src="../../../../../../../doc/html/images/next.png" alt="Next"></a>
  26. </div></td>
  27. </tr></table>
  28. <hr>
  29. <div class="section" lang="en">
  30. <div class="titlepage"><div><div><h6 class="title">
  31. <a name="utf.user-guide.test-organization.auto-nullary-test-case"></a>Nullary function based test case with automated registration</h6></div></div></div>
  32. <p class="first-line-indented">
  33. To create a nullary free function cased test case, which is registered in place of implementation, employ the
  34. macro BOOST_AUTO_TEST_CASE.
  35. </p>
  36. <pre class="inline-synopsis">
  37. <a name="BOOST_AUTO_TEST_CASE"></a>BOOST_AUTO_TEST_CASE(<span class="emphasis"><em>test_case_name</em></span>)</pre>
  38. <p class="first-line-indented">
  39. The macro is designed to closely mimic nullary free function syntax. Changes that are required to make an
  40. existing test case, implemented as a free function, registered in place are illustrated in the following
  41. example (compare with <a class="xref" href="manual-nullary-test-case.html#utf.user-guide.test-organization.manual-nullary-test-case.example01" title="Example 5. Nullary free function manually registered">Example 5, &#8220;Nullary free function manually registered&#8221;</a>):
  42. </p>
  43. <div class="example">
  44. <a name="utf.user-guide.test-organization.auto-nullary-test-case.example06"></a><p class="title"><b>Example 10. Nullary function based test case with automated registration</b></p>
  45. <div class="example-contents">
  46. <pre class="programlisting">#define BOOST_TEST_MODULE example
  47. #include &lt;boost/test/included/unit_test.hpp&gt;
  48. //____________________________________________________________________________//
  49. BOOST_AUTO_TEST_CASE( free_test_function )
  50. {
  51. BOOST_CHECK( true /* test assertion */ );
  52. }
  53. //____________________________________________________________________________//
  54. </pre>
  55. <table class="simplelist" border="0" summary="Simple list"><tr>
  56. <td><code class="literal"><a href="../../../../src/examples/example06.cpp" target="_top">Source code</a></code></td>
  57. <td> | </td>
  58. <td><code class="literal"><a href="#" target="_top" id="id649807" onclick="toggle_element( 'example06-output', 'id649807', 'Show output', 'Hide output' ); return false;">Show output</a></code></td>
  59. </tr></table>
  60. <pre class="example-output" id="example06-output">&gt; example --log_level=test_suite
  61. Running 1 test case...
  62. Entering test suite "example"
  63. Entering test case "free_test_function"
  64. Leaving test case "free_test_function"; testing time: 16ms
  65. Leaving test suite "example"
  66. *** No errors detected
  67. </pre>
  68. </div>
  69. </div>
  70. <br class="example-break"><p class="first-line-indented">
  71. With this macro you don't need to implement the initialization function at all. The macro creates and
  72. registers the test case with the name free_test_function automatically.
  73. </p>
  74. </div>
  75. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  76. <td align="left"></td>
  77. <td align="right"><div class="copyright-footer">Copyright Š 2001-2007 Gennadiy Rozental</div></td>
  78. </tr></table>
  79. <hr>
  80. <div class="spirit-nav">
  81. <a accesskey="p" href="manual-nullary-test-case.html"><img src="../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="nullary-test-case.html"><img src="../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="unary-test-case.html"><img src="../../../../../../../doc/html/images/next.png" alt="Next"></a>
  82. </div>
  83. </body>
  84. </html>