?? group___assertions.html
字號:
<td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> #define CPPUNIT_ASSERT_EQUAL_MESSAGE </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">message, <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>expected, <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>actual </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><b>Value:</b><pre class="fragment"><div>( <a class="code" href="_test_assert_8h.html#a11">CPPUNIT_NS::assertEquals</a>( (expected), \ (actual), \ <a class="code" href="group___creating_new_assertions.html#ga0">CPPUNIT_SOURCELINE</a>(), \ (message) ) )</div></pre>Asserts that two values are equals, provides additional messafe on failure. <p>Equality and string representation can be defined with an appropriate <a class="el" href="structassertion__traits.html">assertion_traits</a> class.<p>A diagnostic is printed if actual and expected values disagree. The message is printed in addition to the expected and actual value to provide additional information.<p>Requirement for <em>expected</em> and <em>actual</em> parameters:<ul><li>They are exactly of the same type</li><li>They are serializable into a std::strstream using operator <<.</li><li>They can be compared using operator ==.</li></ul><p>The last two requirements (serialization and comparison) can be removed by specializing the CppUnit::assertion_traits. </td> </tr></table><a class="anchor" name="ga1" doxytag="TestAssert.h::CPPUNIT_ASSERT_MESSAGE" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> #define CPPUNIT_ASSERT_MESSAGE </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">message, <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>condition </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><b>Value:</b><pre class="fragment"><div>( CPPUNIT_NS::Asserter::failIf( !(condition), \ (message), \ <a class="code" href="group___creating_new_assertions.html#ga0">CPPUNIT_SOURCELINE</a>() ) )</div></pre>Assertion with a user specified message. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>message</em> </td><td><a class="el" href="class_message.html">Message</a> reported in diagnostic if <em>condition</em> evaluates to <code>false</code>. </td></tr> <tr><td></td><td valign=top><em>condition</em> </td><td>If this condition evaluates to <code>false</code> then the test failed. </td></tr> </table></dl> </td> </tr></table><a class="anchor" name="ga7" doxytag="TestAssert.h::CPPUNIT_ASSERT_NO_THROW" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> #define CPPUNIT_ASSERT_NO_THROW </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">expression </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><b>Value:</b><pre class="fragment"><div><span class="keywordflow">try</span> { \ expression; \ } <span class="keywordflow">catch</span> ( <span class="keyword">const</span> std::exception &e ) { \ CPPUNIT_NS::Message message( <span class="stringliteral">"Unexpected exception caught"</span> ); \ message.addDetail( <span class="stringliteral">"Type: "</span> + \ <a class="code" href="_test_assert_8h.html#a7">CPPUNIT_EXTRACT_EXCEPTION_TYPE_</a>( e, \ <span class="stringliteral">"std::exception or derived"</span> ) ); \ message.addDetail( std::string(<span class="stringliteral">"What: "</span>) + e.what() ); \ CPPUNIT_NS::Asserter::fail( message, \ <a class="code" href="group___creating_new_assertions.html#ga0">CPPUNIT_SOURCELINE</a>() ); \ } <span class="keywordflow">catch</span> ( ... ) { \ CPPUNIT_NS::Asserter::fail( <span class="stringliteral">"Unexpected exception caught"</span>, \ <a class="code" href="group___creating_new_assertions.html#ga0">CPPUNIT_SOURCELINE</a>() ); \ }</div></pre>Asserts that the given expression does not throw any exceptions. <p>Example of usage: <pre><div class="fragment"> std::vector<int> v; v.push_back( 10 ); <a class="code" href="group___assertions.html#ga7">CPPUNIT_ASSERT_NO_THROW</a>( v.at( 0 ) );</div></pre> </td> </tr></table><a class="anchor" name="ga6" doxytag="TestAssert.h::CPPUNIT_ASSERT_THROW" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> #define CPPUNIT_ASSERT_THROW </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">expression, <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>ExceptionType </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><b>Value:</b><pre class="fragment"><div><span class="keywordflow">do</span> { \ <span class="keywordtype">bool</span> cpputExceptionThrown_ = <span class="keyword">false</span>; \ <span class="keywordflow">try</span> { \ expression; \ } <span class="keywordflow">catch</span> ( <span class="keyword">const</span> ExceptionType & ) { \ cpputExceptionThrown_ = <span class="keyword">true</span>; \ } \ \ <span class="keywordflow">if</span> ( cpputExceptionThrown_ ) \ <span class="keywordflow">break</span>; \ \ CPPUNIT_NS::Asserter::fail( \ <span class="stringliteral">"Expected exception: "</span> #ExceptionType \ <span class="stringliteral">" not thrown."</span>, \ <a class="code" href="group___creating_new_assertions.html#ga0">CPPUNIT_SOURCELINE</a>() ); \ } <span class="keywordflow">while</span> ( <span class="keyword">false</span> )</div></pre>Asserts that the given expression throws an exception of the specified type. <p>Example of usage: <pre><div class="fragment"> std::vector<int> v; <a class="code" href="group___assertions.html#ga6">CPPUNIT_ASSERT_THROW</a>( v.at( 50 ), std::out_of_range );</div></pre> </td> </tr></table><a class="anchor" name="ga2" doxytag="TestAssert.h::CPPUNIT_FAIL" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> #define CPPUNIT_FAIL </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">message </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><b>Value:</b><pre class="fragment"><div>( CPPUNIT_NS::Asserter::fail( CPPUNIT_NS::Message( <span class="stringliteral">"forced failure"</span>, \ message ), \ <a class="code" href="group___creating_new_assertions.html#ga0">CPPUNIT_SOURCELINE</a>() ) )</div></pre>Fails with the specified message. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>message</em> </td><td><a class="el" href="class_message.html">Message</a> reported in diagnostic. </td></tr> </table></dl> </td> </tr></table><hr><table width="100%"> <tr> <td width="10%" align="left" valign="center"> <a href="http://sourceforge.net"> <img src="http://sourceforge.net/sflogo.php?group_id=11795" width="88" height="31" border="0" alt="SourceForge Logo"></a> </td> <td width="20%" align="left" valign="center"> hosts this site. </td> <td> </td> <td align="right" valign="center"> Send comments to:<br> <a href="mailto:cppunit-devel@lists.sourceforge.net">CppUnit Developers</a> </td> </tr></table></body> </html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -