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

📄 struct_asserter.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>Asserter Struct Reference<br><small>[<a class="el" href="group___creating_new_assertions.html">Creating custom assertions</a>]</small></h1>A set of functions to help writing assertion macros.  <a href="#_details">More...</a><p><code>#include &lt;<a class="el" href="_asserter_8h-source.html">Asserter.h</a>&gt;</code><p><a href="struct_asserter-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e0">fail</a> (const <a class="el" href="class_message.html">Message</a> &amp;message, const <a class="el" href="class_source_line.html">SourceLine</a> &amp;sourceLine=<a class="el" href="class_source_line.html">SourceLine</a>())</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location.  <a href="#e0"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e1">fail</a> (std::string message, const <a class="el" href="class_source_line.html">SourceLine</a> &amp;sourceLine=<a class="el" href="class_source_line.html">SourceLine</a>())</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location.  <a href="#e1"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e2">failIf</a> (bool shouldFail, const <a class="el" href="class_message.html">Message</a> &amp;message, const <a class="el" href="class_source_line.html">SourceLine</a> &amp;sourceLine=<a class="el" href="class_source_line.html">SourceLine</a>())</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location.  <a href="#e2"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e3">failIf</a> (bool shouldFail, std::string message, const <a class="el" href="class_source_line.html">SourceLine</a> &amp;sourceLine=<a class="el" href="class_source_line.html">SourceLine</a>())</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location.  <a href="#e3"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>std::string CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e4">makeExpected</a> (const std::string &amp;expectedValue)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns a expected value string for a message. Typically used to create 'not equal' message, or to check that a message contains the expected content when writing unit tests for your custom assertions.  <a href="#e4"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>std::string CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e5">makeActual</a> (const std::string &amp;actualValue)</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Returns an actual value string for a message. Typically used to create 'not equal' message, or to check that a message contains the expected content when writing unit tests for your custom assertions.  <a href="#e5"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="class_message.html">Message</a> CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e6">makeNotEqualMessage</a> (const std::string &amp;expectedValue, const std::string &amp;actualValue, const <a class="el" href="class_additional_message.html">AdditionalMessage</a> &amp;additionalMessage=<a class="el" href="class_additional_message.html">AdditionalMessage</a>(), const std::string &amp;shortDescription="equality assertion failed")</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e7">failNotEqual</a> (std::string expected, std::string actual, const <a class="el" href="class_source_line.html">SourceLine</a> &amp;sourceLine, const <a class="el" href="class_additional_message.html">AdditionalMessage</a> &amp;additionalMessage=<a class="el" href="class_additional_message.html">AdditionalMessage</a>(), std::string shortDescription="equality assertion failed")</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Throws an <a class="el" href="class_exception.html">Exception</a> with the specified message and location.  <a href="#e7"></a><br><br></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void CPPUNIT_API&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="struct_asserter.html#e8">failNotEqualIf</a> (bool shouldFail, std::string expected, std::string actual, const <a class="el" href="class_source_line.html">SourceLine</a> &amp;sourceLine, const <a class="el" href="class_additional_message.html">AdditionalMessage</a> &amp;additionalMessage=<a class="el" href="class_additional_message.html">AdditionalMessage</a>(), std::string shortDescription="equality assertion failed")</td></tr><tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Throws an <a class="el" href="class_exception.html">Exception</a> with the specified message and location.  <a href="#e8"></a><br><br></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>A set of functions to help writing assertion macros. <p>Here is an example of assertion, a simplified version of the actual assertion implemented in examples/cppunittest/XmlUniformiser.h: <pre><div class="fragment"><span class="preprocessor"> #include &lt;<a class="code" href="_source_line_8h.html">cppunit/SourceLine.h</a>&gt;</span><span class="preprocessor"> #include &lt;<a class="code" href="_test_assert_8h.html">cppunit/TestAssert.h</a>&gt;</span>  <span class="keywordtype">void</span>  checkXmlEqual( std::string expectedXml,                std::string actualXml,                CppUnit::SourceLine sourceLine ) {   std::string expected = XmlUniformiser( expectedXml ).stripped();   std::string actual = XmlUniformiser( actualXml ).stripped();    <span class="keywordflow">if</span> ( expected == actual )     <span class="keywordflow">return</span>;    ::CppUnit::Asserter::failNotEqual( expected,                                      actual,                                      sourceLine ); } <span class="preprocessor"> #define CPPUNITTEST_ASSERT_XML_EQUAL( expected, actual ) \</span><span class="preprocessor">     checkXmlEqual( expected, actual,                     \</span><span class="preprocessor">                    CPPUNIT_SOURCELINE() )</span></div></pre><p><hr><h2>Member Function Documentation</h2><a class="anchor" name="e1" doxytag="Asserter::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"> CPPUNIT_NS_BEGIN void Asserter::fail           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">std::string&nbsp;</td>          <td class="mdname" nowrap> <em>message</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="class_source_line.html">SourceLine</a> &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>sourceLine</em> = <code><a class="el" href="class_source_line.html">SourceLine</a>()</code></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location. <p><dl compact><dt><b><a class="el" href="deprecated.html#_deprecated000006">Deprecated:</a></b></dt><dd>Use <a class="el" href="struct_asserter.html#e0">fail( Message, SourceLine )</a> instead. </dd></dl>    </td>  </tr></table><a class="anchor" name="e0" doxytag="Asserter::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"> void Asserter::fail           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">const <a class="el" href="class_message.html">Message</a> &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>message</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="class_source_line.html">SourceLine</a> &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>sourceLine</em> = <code><a class="el" href="class_source_line.html">SourceLine</a>()</code></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location. <p>    </td>  </tr></table><a class="anchor" name="e3" doxytag="Asserter::failIf" ></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"> void Asserter::failIf           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">bool&nbsp;</td>          <td class="mdname" nowrap> <em>shouldFail</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>std::string&nbsp;</td>          <td class="mdname" nowrap> <em>message</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="class_source_line.html">SourceLine</a> &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>sourceLine</em> = <code><a class="el" href="class_source_line.html">SourceLine</a>()</code></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location. <p><dl compact><dt><b><a class="el" href="deprecated.html#_deprecated000007">Deprecated:</a></b></dt><dd>Use <a class="el" href="struct_asserter.html#e2">failIf( bool, Message, SourceLine )</a> instead.</dd></dl><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>shouldFail</em>&nbsp;</td><td>if <code>true</code> then the exception is thrown. Otherwise nothing happen. </td></tr>    <tr><td></td><td valign=top><em>message</em>&nbsp;</td><td><a class="el" href="class_message.html">Message</a> explaining the assertion failiure. </td></tr>    <tr><td></td><td valign=top><em>sourceLine</em>&nbsp;</td><td>Location of the assertion. </td></tr>  </table></dl>    </td>  </tr></table><a class="anchor" name="e2" doxytag="Asserter::failIf" ></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"> void Asserter::failIf           </td>          <td class="md" valign="top">(&nbsp;</td>          <td class="md" nowrap valign="top">bool&nbsp;</td>          <td class="mdname" nowrap> <em>shouldFail</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="class_message.html">Message</a> &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>message</em>, </td>        </tr>        <tr>          <td class="md" nowrap align="right"></td>          <td></td>          <td class="md" nowrap>const <a class="el" href="class_source_line.html">SourceLine</a> &amp;&nbsp;</td>          <td class="mdname" nowrap> <em>sourceLine</em> = <code><a class="el" href="class_source_line.html">SourceLine</a>()</code></td>        </tr>        <tr>          <td></td>          <td class="md">)&nbsp;</td>          <td class="md" colspan="2"><code> [static]</code></td>        </tr>      </table>    </td>  </tr></table><table cellspacing=5 cellpadding=0 border=0>  <tr>    <td>      &nbsp;    </td>    <td><p>Throws a <a class="el" href="class_exception.html">Exception</a> with the specified message and location. <p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td></td><td valign=top><em>shouldFail</em>&nbsp;</td><td>if <code>true</code> then the exception is thrown. Otherwise nothing happen. </td></tr>    <tr><td></td><td valign=top><em>message</em>&nbsp;</td><td><a class="el" href="class_message.html">Message</a> explaining the assertion failiure. </td></tr>    <tr><td></td><td valign=top><em>sourceLine</em>&nbsp;</td><td>Location of the assertion. </td></tr>  </table></dl>    </td>  </tr></table><a class="anchor" name="e7" doxytag="Asserter::failNotEqual" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0">  <tr>    <td class="mdRow">      <table cellpadding="0" cellspacing="0" border="0">

⌨️ 快捷键说明

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