?? _test_assert_8h-source.html
字號:
<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 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 Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related 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 <<a class="code" href="_portability_8h.html">cppunit/Portability.h</a>></span>00005 <span class="preprocessor">#include <<a class="code" href="_exception_8h.html">cppunit/Exception.h</a>></span>00006 <span class="preprocessor">#include <<a class="code" href="_asserter_8h.html">cppunit/Asserter.h</a>></span>00007 00008 00009 <a class="code" href="_portability_8h.html#a6">CPPUNIT_NS_BEGIN</a>00010 00011 00035 <span class="keyword">template</span> <<span class="keyword">class</span> T><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& x, <span class="keyword">const</span> T& 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& x )00044 {00045 OStringStream ost;00046 ost << x;00047 <span class="keywordflow">return</span> ost.str();00048 }00049 };00050 00051 00056 <span class="keyword">template</span> <<span class="keyword">class</span> T><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& expected,00058 <span class="keyword">const</span> T& actual,00059 <a class="code" href="class_source_line.html">SourceLine</a> sourceLine,00060 <span class="keyword">const</span> std::string &message )00061 {00062 <span class="keywordflow">if</span> ( !<a class="code" href="structassertion__traits.html">assertion_traits<T>::equal</a>(expected,actual) ) <span class="comment">// lazy toString conversion...</span>00063 {00064 Asserter::failNotEqual( <a class="code" href="structassertion__traits.html">assertion_traits<T></a>::toString(expected),00065 <a class="code" href="structassertion__traits.html">assertion_traits<T></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 + -