⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _test_assert_8h-source.html

📁 c++开发的一个不错的工具
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><title>CppUnit - The Unit Testing Library</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"> <table width="100%">  <tr>    <td width="40%" align="left" valign="center">      <a href="http://sourceforge.net/projects/cppunit">      CppUnit project page      </a>    </td>    <td>      <a href="FAQ">FAQ</a>    </td>    <td width="40%" align="right" valign="center">      <a href="http://cppunit.sourceforge.net">CppUnit home page</a>    </td>  </tr></table><hr><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div><h1>TestAssert.h</h1><a href="_test_assert_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="preprocessor">#ifndef CPPUNIT_TESTASSERT_H</span>00002 <span class="preprocessor"></span><span class="preprocessor">#define CPPUNIT_TESTASSERT_H</span>00003 <span class="preprocessor"></span>00004 <span class="preprocessor">#include &lt;<a class="code" href="_portability_8h.html">cppunit/Portability.h</a>&gt;</span>00005 <span class="preprocessor">#include &lt;<a class="code" href="_exception_8h.html">cppunit/Exception.h</a>&gt;</span>00006 <span class="preprocessor">#include &lt;<a class="code" href="_asserter_8h.html">cppunit/Asserter.h</a>&gt;</span>00007 00008 00009 <a class="code" href="_portability_8h.html#a6">CPPUNIT_NS_BEGIN</a>00010 00011 00035 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;<a name="l00036"></a><a class="code" href="structassertion__traits.html">00036</a> <span class="keyword">struct </span><a class="code" href="structassertion__traits.html">assertion_traits</a> 00037 {  <a name="l00038"></a><a class="code" href="structassertion__traits.html#e0">00038</a>     <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="structassertion__traits.html#e0">equal</a>( <span class="keyword">const</span> T&amp; x, <span class="keyword">const</span> T&amp; y )00039     {00040         <span class="keywordflow">return</span> x == y;00041     }00042 <a name="l00043"></a><a class="code" href="structassertion__traits.html#e1">00043</a>     <span class="keyword">static</span> std::string <a class="code" href="structassertion__traits.html#e1">toString</a>( <span class="keyword">const</span> T&amp; x )00044     {00045         OStringStream ost;00046         ost &lt;&lt; x;00047         <span class="keywordflow">return</span> ost.str();00048     }00049 };00050 00051 00056 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;<a name="l00057"></a><a class="code" href="_test_assert_8h.html#a11">00057</a> <span class="keywordtype">void</span> <a class="code" href="_test_assert_8h.html#a11">assertEquals</a>( <span class="keyword">const</span> T&amp; expected,00058                    <span class="keyword">const</span> T&amp; actual,00059                    <a class="code" href="class_source_line.html">SourceLine</a> sourceLine,00060                    <span class="keyword">const</span> std::string &amp;message )00061 {00062   <span class="keywordflow">if</span> ( !<a class="code" href="structassertion__traits.html">assertion_traits&lt;T&gt;::equal</a>(expected,actual) ) <span class="comment">// lazy toString conversion...</span>00063   {00064     Asserter::failNotEqual( <a class="code" href="structassertion__traits.html">assertion_traits&lt;T&gt;</a>::toString(expected),00065                             <a class="code" href="structassertion__traits.html">assertion_traits&lt;T&gt;</a>::toString(actual),00066                             sourceLine,00067                             message );00068   }00069 }00070 00075 <span class="keywordtype">void</span> CPPUNIT_API <a class="code" href="_test_assert_8cpp.html#a0">assertDoubleEquals</a>( <span class="keywordtype">double</span> expected,00076                                      <span class="keywordtype">double</span> actual,00077                                      <span class="keywordtype">double</span> delta,00078                                      <a class="code" href="class_source_line.html">SourceLine</a> sourceLine );00079 00080 00081 <span class="comment">/* A set of macros which allow us to get the line number</span>00082 <span class="comment"> * and file name at the point of an error.</span>00083 <span class="comment"> * Just goes to show that preprocessors do have some</span>00084 <span class="comment"> * redeeming qualities.</span>00085 <span class="comment"> */</span>00086 <span class="preprocessor">#if CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION</span>00087 <span class="preprocessor"></span><a name="l00090"></a><a class="code" href="group___assertions.html#ga0">00090</a> <span class="preprocessor">#define CPPUNIT_ASSERT(condition)                                                 \</span>00091 <span class="preprocessor">  ( CPPUNIT_NS::Asserter::failIf( !(condition),                                   \</span>00092 <span class="preprocessor">                                 CPPUNIT_NS::Message( "assertion failed",         \</span>00093 <span class="preprocessor">                                                      "Expression: " #condition), \</span>00094 <span class="preprocessor">                                 CPPUNIT_SOURCELINE() ) )</span>00095 <span class="preprocessor"></span><span class="preprocessor">#else</span>00096 <span class="preprocessor"></span><span class="preprocessor">#define CPPUNIT_ASSERT(condition)                                            \</span>00097 <span class="preprocessor">  ( CPPUNIT_NS::Asserter::failIf( !(condition),                              \</span>00098 <span class="preprocessor">                                  CPPUNIT_NS::Message( "assertion failed" ), \</span>00099 <span class="preprocessor">                                  CPPUNIT_SOURCELINE() ) )</span>00100 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00101 <span class="preprocessor"></span><a name="l00109"></a><a class="code" href="group___assertions.html#ga1">00109</a> <span class="preprocessor">#define CPPUNIT_ASSERT_MESSAGE(message,condition)          \</span>00110 <span class="preprocessor">  ( CPPUNIT_NS::Asserter::failIf( !(condition),            \</span>00111 <span class="preprocessor">                                  (message),               \</span>00112 <span class="preprocessor">                                  CPPUNIT_SOURCELINE() ) )</span>00113 <span class="preprocessor"></span><a name="l00118"></a><a class="code" href="group___assertions.html#ga2">00118</a> <span class="preprocessor">#define CPPUNIT_FAIL( message )                                         \</span>00119 <span class="preprocessor">  ( CPPUNIT_NS::Asserter::fail( CPPUNIT_NS::Message( "forced failure",  \</span>00120 <span class="preprocessor">                                                     message ),         \</span>00121 <span class="preprocessor">                                CPPUNIT_SOURCELINE() ) )</span>00122 <span class="preprocessor"></span>00123 <span class="preprocessor">#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED</span>00124 <span class="preprocessor"></span>00125 <span class="preprocessor">#define CPPUNIT_ASSERT_EQUAL(expected,actual)                     \</span>00126 <span class="preprocessor">  ( CPPUNIT_NS::assertEquals( (expected),             \</span>00127 <span class="preprocessor">                              (actual),               \</span>00128 <span class="preprocessor">                              __LINE__, __FILE__ ) )</span>00129 <span class="preprocessor"></span><span class="preprocessor">#else</span>00130 <span class="preprocessor"></span>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -