1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>BOOST_<level>_EQUAL</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_bitwise_eq.html" title="BOOST_<level>_BITWISE_EQUAL"> 10<link rel="next" href="assertion_boost_level_eq_collections.html" title="BOOST_<level>_EQUAL_COLLECTIONS"> 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_bitwise_eq.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="assertion_boost_level_eq_collections.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_eq"></a><a class="link" href="assertion_boost_level_eq.html" title="BOOST_<level>_EQUAL"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span><span class="identifier">_EQUAL</span></code></a> 28</h4></div></div></div> 29<pre class="programlisting"><span class="identifier">BOOST_WARN_EQUAL</span><span class="special">(</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">right</span><span class="special">);</span> 30<span class="identifier">BOOST_CHECK_EQUAL</span><span class="special">(</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">right</span><span class="special">);</span> 31<span class="identifier">BOOST_REQUIRE_EQUAL</span><span class="special">(</span><span class="identifier">left</span><span class="special">,</span> <span class="identifier">right</span><span class="special">);</span> 32</pre> 33<p> 34 Check performed by these tools is the same as the one performed by <code class="computeroutput"><a class="link" href="assertion_boost_level.html" title="BOOST_<level>"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span></code></a><span class="special">(</span><span class="identifier">left</span> <span class="special">==</span> <span class="identifier">right</span><span class="special">)</span></code>. The difference is that the mismatched 35 values are reported as well. 36 </p> 37<div class="note"><table border="0" summary="Note"> 38<tr> 39<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td> 40<th align="left">Note</th> 41</tr> 42<tr><td align="left" valign="top"><p> 43 It is bad idea to use these tools to compare floating point values. Use 44 <a class="link" href="assertion_boost_level_close.html" title="BOOST_<level>_CLOSE"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span><span class="identifier">_CLOSE</span></code></a> or <a class="link" href="assertion_boost_level_close_fraction.html" title="BOOST_<level>_CLOSE_FRACTION"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span><span class="identifier">_CLOSE_FRACTION</span></code></a> tools instead. 45 </p></td></tr> 46</table></div> 47<h6> 48<a name="boost_test.utf_reference.testing_tool_ref.assertion_boost_level_eq.h0"></a> 49 <span class="phrase"><a name="boost_test.utf_reference.testing_tool_ref.assertion_boost_level_eq.example_descr"></a></span><a class="link" href="assertion_boost_level_eq.html#boost_test.utf_reference.testing_tool_ref.assertion_boost_level_eq.example_descr">Example: 50 BOOST_<level>_EQUAL usage</a> 51 </h6> 52<div class="informaltable"><table class="table"> 53<colgroup><col></colgroup> 54<thead><tr><th> 55 <p> 56 Code 57 </p> 58 </th></tr></thead> 59<tbody><tr><td> 60<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> 61<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> 62 63<span class="identifier">BOOST_AUTO_TEST_CASE</span><span class="special">(</span> <span class="identifier">test</span> <span class="special">)</span> 64<span class="special">{</span> 65 <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span> 66 <span class="keyword">int</span> <span class="identifier">j</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> 67 <span class="identifier">BOOST_REQUIRE_EQUAL</span><span class="special">(</span> <span class="identifier">i</span><span class="special">,</span> <span class="identifier">j</span> <span class="special">);</span> 68<span class="special">}</span> 69</pre> 70 </td></tr></tbody> 71</table></div> 72<div class="informaltable"><table class="table"> 73<colgroup><col></colgroup> 74<thead><tr><th> 75 <p> 76 Output 77 </p> 78 </th></tr></thead> 79<tbody><tr><td> 80<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> 81<span class="identifier">Running</span> <span class="number">1</span> <span class="identifier">test</span> <span class="keyword">case</span><span class="special">...</span> 82<span class="identifier">test</span><span class="special">.</span><span class="identifier">cpp</span><span class="special">(</span><span class="number">10</span><span class="special">):</span> <span class="identifier">fatal</span> <span class="identifier">error</span> <span class="identifier">in</span> <span class="string">"test"</span><span class="special">:</span> <span class="identifier">critical</span> <span class="identifier">check</span> <span class="identifier">i</span> <span class="special">==</span> <span class="identifier">j</span> <span class="identifier">has</span> <span class="identifier">failed</span> <span class="special">[</span><span class="number">2</span> <span class="special">!=</span> <span class="number">1</span><span class="special">]</span> 83 84<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> 85</pre> 86 </td></tr></tbody> 87</table></div> 88<p> 89 See also: 90 </p> 91<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 92<li class="listitem"> 93 <a class="link" href="assertion_boost_level.html" title="BOOST_<level>"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span></code></a> 94 </li> 95<li class="listitem"> 96 <a class="link" href="assertion_boost_level_close.html" title="BOOST_<level>_CLOSE"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span><span class="identifier">_CLOSE</span></code></a> 97 </li> 98<li class="listitem"> 99 <a class="link" href="assertion_boost_level_ne.html" title="BOOST_<level>_NE"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span><span class="identifier">_NE</span></code></a> 100 </li> 101<li class="listitem"> 102 <a class="link" href="assertion_boost_level_eq_collections.html" title="BOOST_<level>_EQUAL_COLLECTIONS"><code class="computeroutput"><span class="identifier">BOOST_</span><span class="special"><</span><span class="identifier">level</span><span class="special">></span><span class="identifier">_EQUAL_COLLECTIONS</span></code></a> 103 </li> 104</ul></div> 105</div> 106<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 107<td align="left"></td> 108<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p> 109 Distributed under the Boost Software License, Version 1.0. (See accompanying 110 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>) 111 </p> 112</div></td> 113</tr></table> 114<hr> 115<div class="spirit-nav"> 116<a accesskey="p" href="assertion_boost_level_bitwise_eq.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="assertion_boost_level_eq_collections.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 117</div> 118</body> 119</html> 120