• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>BOOST_&lt;level&gt;_SMALL</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="../testing_tool_ref.html" title="Reference API for writing tests">
9<link rel="prev" href="assertion_boost_level_exception.html" title="BOOST_&lt;level&gt;_EXCEPTION">
10<link rel="next" href="test_org_boost_test_case_expected_failure.html" title="BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES">
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="assertion_boost_level_exception.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tool_ref.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_case_expected_failure.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.testing_tool_ref.assertion_boost_level_small"></a><a class="link" href="assertion_boost_level_small.html" title="BOOST_&lt;level&gt;_SMALL"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special">&lt;</span><span class="identifier">level</span><span class="special">&gt;</span><span class="identifier">_SMALL</span></code></a>
28</h4></div></div></div>
29<pre class="programlisting"><span class="identifier">BOOST_WARN_SMALL</span><span class="special">(</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">tolerance</span><span class="special">);</span>
30<span class="identifier">BOOST_CHECK_SMALL</span><span class="special">(</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">tolerance</span><span class="special">);</span>
31<span class="identifier">BOOST_REQUIRE_SMALL</span><span class="special">(</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">tolerance</span><span class="special">);</span>
32</pre>
33<p>
34          These tools are used to check that supplied value is small enough. The
35          "smallness" is defined by absolute value of the tolerance supplied
36          as a second argument. Use these tools with caution. To compare to values
37          on closeness it's preferable to use <a class="link" href="assertion_boost_level_close.html" title="BOOST_&lt;level&gt;_CLOSE"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special">&lt;</span><span class="identifier">level</span><span class="special">&gt;</span><span class="identifier">_CLOSE</span></code></a> tools instead.
38        </p>
39<p>
40          The first parameter is the value to check. The second parameter is the
41          tolerance.
42        </p>
43<div class="note"><table border="0" summary="Note">
44<tr>
45<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
46<th align="left">Note</th>
47</tr>
48<tr><td align="left" valign="top"><p>
49            The floating point comparison tools are automatically added if the <span class="emphasis"><em>Unit
50            Test Framework</em></span> is included as indicated in the previous sections.
51            The tools are implemented is in the header <code class="computeroutput"><a class="link" href="../../../header/boost/test/tools/floating_point_comparison_hpp.html" title="Header &lt;boost/test/tools/floating_point_comparison.hpp&gt;">boost/test/tools/floating_point_comparison.hpp</a></code>.
52          </p></td></tr>
53</table></div>
54<h6>
55<a name="boost_test.utf_reference.testing_tool_ref.assertion_boost_level_small.h0"></a>
56          <span class="phrase"><a name="boost_test.utf_reference.testing_tool_ref.assertion_boost_level_small.example_descr"></a></span><a class="link" href="assertion_boost_level_small.html#boost_test.utf_reference.testing_tool_ref.assertion_boost_level_small.example_descr">Example:
57          BOOST_&lt;level&gt;_SMALL usage</a>
58        </h6>
59<div class="informaltable"><table class="table">
60<colgroup><col></colgroup>
61<thead><tr><th>
62                  <p>
63                    Code
64                  </p>
65                </th></tr></thead>
66<tbody><tr><td>
67<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>
68<span class="preprocessor">#include</span> <span class="special">&lt;</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">&gt;</span>
69<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">tools</span><span class="special">/</span><span class="identifier">floating_point_comparison</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
70
71<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test</span> <span class="special">)</span>
72<span class="special">{</span>
73  <span class="keyword">double</span> <span class="identifier">v</span> <span class="special">=</span> <span class="special">-</span><span class="number">1.23456e-3</span><span class="special">;</span>
74  <span class="identifier">BOOST_CHECK_SMALL</span><span class="special">(</span> <span class="identifier">v</span><span class="special">,</span> <span class="number">0.000001</span> <span class="special">);</span>
75<span class="special">}</span>
76</pre>
77                </td></tr></tbody>
78</table></div>
79<div class="informaltable"><table class="table">
80<colgroup><col></colgroup>
81<thead><tr><th>
82                  <p>
83                    Output
84                  </p>
85                </th></tr></thead>
86<tbody><tr><td>
87<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="special">&gt;</span> <span class="identifier">example</span>
88<span class="identifier">Running</span> <span class="number">1</span> <span class="identifier">test</span> <span class="keyword">case</span><span class="special">...</span>
89<span class="identifier">test</span><span class="special">.</span><span class="identifier">cpp</span><span class="special">(</span><span class="number">11</span><span class="special">):</span> <span class="identifier">error</span> <span class="identifier">in</span> <span class="string">"test"</span><span class="special">:</span> <span class="identifier">absolute</span> <span class="identifier">value</span> <span class="identifier">of</span> <span class="identifier">v</span><span class="special">{-</span><span class="number">0.00123456</span><span class="special">}</span> <span class="identifier">exceeds</span> <span class="number">1e-006</span>
90
91<span class="special">***</span> <span class="number">1</span> <span class="identifier">failures</span> <span class="identifier">is</span> <span class="identifier">detected</span> <span class="identifier">in</span> <span class="identifier">test</span> <span class="identifier">suite</span> <span class="string">"example"</span>
92</pre>
93                </td></tr></tbody>
94</table></div>
95<p>
96          See also:
97        </p>
98<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
99<li class="listitem">
100              <a class="link" href="assertion_boost_level_close.html" title="BOOST_&lt;level&gt;_CLOSE"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special">&lt;</span><span class="identifier">level</span><span class="special">&gt;</span><span class="identifier">_CLOSE</span></code></a>
101            </li>
102<li class="listitem">
103              <a class="link" href="assertion_boost_level_close_fraction.html" title="BOOST_&lt;level&gt;_CLOSE_FRACTION"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special">&lt;</span><span class="identifier">level</span><span class="special">&gt;</span><span class="identifier">_CLOSE_FRACTION</span></code></a>
104            </li>
105<li class="listitem">
106              <a class="link" href="../../testing_tools/extended_comparison/floating_point/floating_points_comparison_theory.html" title="Theory behind floating point comparisons">Floating
107              point comparison algorithms</a>
108            </li>
109</ul></div>
110</div>
111<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
112<td align="left"></td>
113<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p>
114        Distributed under the Boost Software License, Version 1.0. (See accompanying
115        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>)
116      </p>
117</div></td>
118</tr></table>
119<hr>
120<div class="spirit-nav">
121<a accesskey="p" href="assertion_boost_level_exception.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../testing_tool_ref.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_case_expected_failure.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
122</div>
123</body>
124</html>
125