?? class_protector.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>Protector Class Reference</h1>Protects one or more test case run. <a href="#_details">More...</a><p><code>#include <<a class="el" href="_protector_8h-source.html">Protector.h</a>></code><p><p>Inheritance diagram for Protector:<p><center><img src="class_protector.png" usemap="#Protector_map" border="0" alt=""></center><map name="Protector_map"><area href="class_default_protector.html" alt="DefaultProtector" shape="rect" coords="0,56,104,80"><area href="class_protector_chain.html" alt="ProtectorChain" shape="rect" coords="114,56,218,80"></map><a href="class_protector-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>virtual </td><td class="memItemRight" valign=bottom><a class="el" href="class_protector.html#a0">~Protector</a> ()</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>virtual bool </td><td class="memItemRight" valign=bottom><a class="el" href="class_protector.html#a1">protect</a> (const <a class="el" href="class_functor.html">Functor</a> &functor, const <a class="el" href="class_protector_context.html">ProtectorContext</a> &context)=0</td></tr><tr><td colspan=2><br><h2>Protected Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="class_protector.html#b0">reportError</a> (const <a class="el" href="class_protector_context.html">ProtectorContext</a> &context, const <a class="el" href="class_exception.html">Exception</a> &error) const</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="class_protector.html#b1">reportError</a> (const <a class="el" href="class_protector_context.html">ProtectorContext</a> &context, const <a class="el" href="class_message.html">Message</a> &message, const <a class="el" href="class_source_line.html">SourceLine</a> &sourceLine=<a class="el" href="class_source_line.html">SourceLine</a>()) const</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="class_protector.html#b2">reportFailure</a> (const <a class="el" href="class_protector_context.html">ProtectorContext</a> &context, const <a class="el" href="class_exception.html">Exception</a> &failure) const</td></tr><tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="class_message.html">Message</a> </td><td class="memItemRight" valign=bottom><a class="el" href="class_protector.html#b3">actualMessage</a> (const <a class="el" href="class_message.html">Message</a> &message, const <a class="el" href="class_protector_context.html">ProtectorContext</a> &context) const</td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>Protects one or more test case run. <p>Protector are used to globably 'decorate' a test case. The most common usage of Protector is to catch exception that do not subclass std::exception, such as MFC CException class or Rogue Wave RWXMsg class, and capture the message associated to the exception. In fact, CppUnit capture message from <a class="el" href="class_exception.html">Exception</a> and std::exception using a Protector.<p>Protector are chained. When you add a Protector using TestResult::pushProtector(), your protector is in fact passed as a <a class="el" href="class_functor.html">Functor</a> to the first protector of the chain.<p><a class="el" href="class_test_case.html">TestCase</a> protects call to setUp(), runTest() and tearDown() by calling TestResult::protect().<p>Because the protector chain is handled by <a class="el" href="class_test_result.html">TestResult</a>, a protector can be active for a single test, or a complete test run.<p>Here are some possible usages:<ul><li>run all test case in a separate thread and assumes the test failed if it did not finish in a given time (infinite loop work around)</li><li>performance tracing : time only the runTest() time. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="class_test_result.html">TestResult</a>, <a class="el" href="class_test_case.html">TestCase</a>, <a class="el" href="class_test_listener.html">TestListener</a>. </dd></dl></li></ul><p><hr><h2>Constructor & Destructor Documentation</h2><a class="anchor" name="a0" doxytag="Protector::~Protector" ></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"> Protector::~<a class="el" href="class_protector.html">Protector</a> </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><hr><h2>Member Function Documentation</h2><a class="anchor" name="b3" doxytag="Protector::actualMessage" ></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"> <a class="el" href="class_message.html">Message</a> Protector::actualMessage </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="class_message.html">Message</a> & </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_protector_context.html">ProtectorContext</a> & </td> <td class="mdname" nowrap> <em>context</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"> const<code> [protected]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a class="anchor" name="a1" doxytag="Protector::protect" ></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"> virtual bool Protector::protect </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="class_functor.html">Functor</a> & </td> <td class="mdname" nowrap> <em>functor</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const <a class="el" href="class_protector_context.html">ProtectorContext</a> & </td> <td class="mdname" nowrap> <em>context</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [pure virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p><p>Implemented in <a class="el" href="class_default_protector.html#a0">DefaultProtector</a>, and <a class="el" href="class_protector_chain.html#a4">ProtectorChain</a>. </td> </tr></table><a class="anchor" name="b1" doxytag="Protector::reportError" ></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 Protector::reportError </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="class_protector_context.html">ProtectorContext</a> & </td> <td class="mdname" nowrap> <em>context</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> & </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> & </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">) </td> <td class="md" colspan="2"> const<code> [protected]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a class="anchor" name="b0" doxytag="Protector::reportError" ></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 Protector::reportError </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="class_protector_context.html">ProtectorContext</a> & </td> <td class="mdname" nowrap> <em>context</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const <a class="el" href="class_exception.html">Exception</a> & </td> <td class="mdname" nowrap> <em>error</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"> const<code> [protected]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a class="anchor" name="b2" doxytag="Protector::reportFailure" ></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 Protector::reportFailure </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="class_protector_context.html">ProtectorContext</a> & </td> <td class="mdname" nowrap> <em>context</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>const <a class="el" href="class_exception.html">Exception</a> & </td> <td class="mdname" nowrap> <em>failure</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"> const<code> [protected]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><hr>The documentation for this class was generated from the following files:<ul><li><a class="el" href="_protector_8h-source.html">Protector.h</a><li><a class="el" href="_protector_8cpp.html">Protector.cpp</a></ul><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 + -