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

📄 _test_caller_8h-source.html

📁 c++开发的一个不错的工具
💻 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&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>TestCaller.h</h1><a href="_test_caller_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="preprocessor">#ifndef CPPUNIT_TESTCALLER_H    // -*- C++ -*-</span>00002 <span class="preprocessor"></span><span class="preprocessor">#define CPPUNIT_TESTCALLER_H</span>00003 <span class="preprocessor"></span>00004 <span class="preprocessor">#include &lt;<a class="code" href="_exception_8h.html">cppunit/Exception.h</a>&gt;</span>00005 <span class="preprocessor">#include &lt;<a class="code" href="_test_case_8h.html">cppunit/TestCase.h</a>&gt;</span>00006 00007 00008 <span class="preprocessor">#if CPPUNIT_USE_TYPEINFO_NAME</span>00009 <span class="preprocessor"></span><span class="preprocessor">#  include &lt;<a class="code" href="_type_info_helper_8h.html">cppunit/extensions/TypeInfoHelper.h</a>&gt;</span>00010 <span class="preprocessor">#endif</span>00011 <span class="preprocessor"></span>00012 00013 <a class="code" href="_portability_8h.html#a6">CPPUNIT_NS_BEGIN</a>00014 00015 <span class="preprocessor">#if 0</span>00016 <span class="preprocessor"></span>00019 <span class="keyword">class </span>CPPUNIT_API NoExceptionExpected00020 {00021 <span class="keyword">private</span>:00023   NoExceptionExpected();00024 };00025 00026 00031 <span class="keyword">template</span>&lt;<span class="keyword">class</span> ExceptionType&gt;00032 <span class="keyword">struct </span>ExpectedExceptionTraits00033 {00034   <span class="keyword">static</span> <span class="keywordtype">void</span> expectedException()00035   {00036 <span class="preprocessor">#if CPPUNIT_USE_TYPEINFO_NAME</span>00037 <span class="preprocessor"></span>    <span class="keywordflow">throw</span> <a class="code" href="class_exception.html">Exception</a>( <a class="code" href="class_message.html">Message</a>(00038                          <span class="stringliteral">"expected exception not thrown"</span>,00039                          <span class="stringliteral">"Expected exception type: "</span> + 00040                            TypeInfoHelper::getClassName( <span class="keyword">typeid</span>( ExceptionType ) ) ) );00041 <span class="preprocessor">#else</span>00042 <span class="preprocessor"></span>    <span class="keywordflow">throw</span> <a class="code" href="class_exception.html">Exception</a>( <span class="stringliteral">"expected exception not thrown"</span> );00043 <span class="preprocessor">#endif</span>00044 <span class="preprocessor"></span>  }00045 };00046 00047 00053 <span class="keyword">template</span>&lt;&gt;00054 <span class="keyword">struct </span>ExpectedExceptionTraits&lt;NoExceptionExpected&gt;00055 {00056   <span class="keyword">static</span> <span class="keywordtype">void</span> expectedException()00057   {00058   }00059 };00060 00061 00062 <span class="preprocessor">#endif</span>00063 <span class="preprocessor"></span>00064 <span class="comment">//*** FIXME: rework this when class Fixture is implemented. ***//</span>00065 00066 00103 <span class="keyword">template</span> &lt;<span class="keyword">class</span> Fixture&gt;<a name="l00104"></a><a class="code" href="class_test_caller.html">00104</a> <span class="keyword">class </span><a class="code" href="class_test_caller.html">TestCaller</a> : <span class="keyword">public</span> <a class="code" href="class_test_case.html">TestCase</a>00105 { <a name="l00106"></a><a class="code" href="class_test_caller.html#y0">00106</a>   <span class="keyword">typedef</span> void (Fixture::*TestMethod)();00107     00108 <span class="keyword">public</span>:<a name="l00115"></a><a class="code" href="class_test_caller.html#a0">00115</a>   <a class="code" href="class_test_caller.html">TestCaller</a>( std::string name, TestMethod test ) :00116             <a class="code" href="class_test_case.html">TestCase</a>( name ), 00117             <a class="code" href="class_test_caller.html#r0">m_ownFixture</a>( true ),00118             <a class="code" href="class_test_caller.html#r1">m_fixture</a>( new Fixture() ),00119             <a class="code" href="class_test_caller.html#r2">m_test</a>( test )00120   {00121   }00122 <a name="l00132"></a><a class="code" href="class_test_caller.html#a1">00132</a>   <a class="code" href="class_test_caller.html">TestCaller</a>(std::string name, TestMethod test, Fixture&amp; fixture) :00133             <a class="code" href="class_test_case.html">TestCase</a>( name ), 00134             <a class="code" href="class_test_caller.html#r0">m_ownFixture</a>( false ),00135             <a class="code" href="class_test_caller.html#r1">m_fixture</a>( &amp;fixture ),00136             <a class="code" href="class_test_caller.html#r2">m_test</a>( test )00137   {00138   }00139     <a name="l00149"></a><a class="code" href="class_test_caller.html#a2">00149</a>   <a class="code" href="class_test_caller.html">TestCaller</a>(std::string name, TestMethod test, Fixture* fixture) :00150             <a class="code" href="class_test_case.html">TestCase</a>( name ), 00151             <a class="code" href="class_test_caller.html#r0">m_ownFixture</a>( true ),00152             <a class="code" href="class_test_caller.html#r1">m_fixture</a>( fixture ),00153             <a class="code" href="class_test_caller.html#r2">m_test</a>( test )00154   {00155   }00156     <a name="l00157"></a><a class="code" href="class_test_caller.html#a3">00157</a>   <a class="code" href="class_test_caller.html#a3">~TestCaller</a>() 00158   {00159     <span class="keywordflow">if</span> (<a class="code" href="class_test_caller.html#r0">m_ownFixture</a>)00160       <span class="keyword">delete</span> <a class="code" href="class_test_caller.html#r1">m_fixture</a>;00161   }00162 <a name="l00163"></a><a class="code" href="class_test_caller.html#a4">00163</a>   <span class="keywordtype">void</span> <a class="code" href="class_test_caller.html#a4">runTest</a>()00164   { 00165 <span class="comment">//        try {</span>00166             (<a class="code" href="class_test_caller.html#r1">m_fixture</a>-&gt;*<a class="code" href="class_test_caller.html#r2">m_test</a>)();00167 <span class="comment">//        }</span>00168 <span class="comment">//        catch ( ExpectedException &amp; ) {</span>00169 <span class="comment">//          return;</span>00170 <span class="comment">//        }</span>00171 00172 <span class="comment">//      ExpectedExceptionTraits&lt;ExpectedException&gt;::expectedException();</span>00173   }  00174 <a name="l00175"></a><a class="code" href="class_test_caller.html#a5">00175</a>   <span class="keywordtype">void</span> <a class="code" href="class_test_caller.html#a5">setUp</a>()00176   { 00177         <a class="code" href="class_test_caller.html#r1">m_fixture</a>-&gt;setUp (); 00178   }00179 <a name="l00180"></a><a class="code" href="class_test_caller.html#a6">00180</a>   <span class="keywordtype">void</span> <a class="code" href="class_test_caller.html#a6">tearDown</a>()00181   { 00182           <a class="code" href="class_test_caller.html#r1">m_fixture</a>-&gt;tearDown (); 00183   }00184 <a name="l00185"></a><a class="code" href="class_test_caller.html#a7">00185</a>   std::string <a class="code" href="class_test_caller.html#a7">toString</a>()<span class="keyword"> const</span>00186 <span class="keyword">  </span>{ 00187         <span class="keywordflow">return</span> <span class="stringliteral">"TestCaller "</span> + <a class="code" href="class_test_case.html#a4">getName</a>(); 00188   }00189 00190 <span class="keyword">private</span>: 00191   <a class="code" href="class_test_caller.html">TestCaller</a>( <span class="keyword">const</span> <a class="code" href="class_test_caller.html">TestCaller</a> &amp;other ); 00192   <a class="code" href="class_test_caller.html">TestCaller</a> &amp;operator =( <span class="keyword">const</span> <a class="code" href="class_test_caller.html">TestCaller</a> &amp;other );00193 00194 <span class="keyword">private</span>:<a name="l00195"></a><a class="code" href="class_test_caller.html#r0">00195</a>   <span class="keywordtype">bool</span> <a class="code" href="class_test_caller.html#r0">m_ownFixture</a>;<a name="l00196"></a><a class="code" href="class_test_caller.html#r1">00196</a>   Fixture *<a class="code" href="class_test_caller.html#r1">m_fixture</a>;<a name="l00197"></a><a class="code" href="class_test_caller.html#r2">00197</a>   <a class="code" href="class_test_caller.html#y0">TestMethod</a> <a class="code" href="class_test_caller.html#r2">m_test</a>;00198 };00199 00200 00201 00202 <a class="code" href="_portability_8h.html#a7">CPPUNIT_NS_END</a>00203 00204 <span class="preprocessor">#endif // CPPUNIT_TESTCALLER_H</span></div></pre><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 + -