📄 _exception_test_case_decorator_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>ExceptionTestCaseDecorator.h</h1><a href="_exception_test_case_decorator_8h.html">Go to the documentation of this file.</a><pre class="fragment"><div>00001 <span class="preprocessor">#ifndef CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H</span>00002 <span class="preprocessor"></span><span class="preprocessor">#define CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_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="_test_case_decorator_8h.html">cppunit/extensions/TestCaseDecorator.h</a>></span>00007 00008 <a class="code" href="_portability_8h.html#a6">CPPUNIT_NS_BEGIN</a>00009 00010 00043 <span class="keyword">template</span><<span class="keyword">class</span> ExpectedException><a name="l00044"></a><a class="code" href="class_exception_test_case_decorator.html">00044</a> <span class="keyword">class </span><a class="code" href="class_exception_test_case_decorator.html">ExceptionTestCaseDecorator</a> : <span class="keyword">public</span> <a class="code" href="class_test_case_decorator.html">TestCaseDecorator</a>00045 {00046 <span class="keyword">public</span>:<a name="l00047"></a><a class="code" href="class_exception_test_case_decorator.html#w0">00047</a> <span class="keyword">typedef</span> ExpectedException <a class="code" href="class_exception_test_case_decorator.html#w0">ExpectedExceptionType</a>;00048 <a name="l00052"></a><a class="code" href="class_exception_test_case_decorator.html#a0">00052</a> <a class="code" href="class_exception_test_case_decorator.html">ExceptionTestCaseDecorator</a>( <a class="code" href="class_test_case.html">TestCase</a> *test )00053 : <a class="code" href="class_test_case_decorator.html">TestCaseDecorator</a>( test )00054 {00055 }00056 <a name="l00065"></a><a class="code" href="class_exception_test_case_decorator.html#a1">00065</a> <span class="keywordtype">void</span> <a class="code" href="class_exception_test_case_decorator.html#a1">runTest</a>()00066 {00067 <span class="keywordflow">try</span>00068 {00069 <a class="code" href="class_test_case_decorator.html#a5">TestCaseDecorator::runTest</a>();00070 }00071 <span class="keywordflow">catch</span> ( <a class="code" href="class_exception_test_case_decorator.html#w0">ExpectedExceptionType</a> &e )00072 {00073 <a class="code" href="class_exception_test_case_decorator.html#d0">checkException</a>( e );00074 <span class="keywordflow">return</span>;00075 }00076 00077 <span class="comment">// Moved outside the try{} statement to handle the case where the</span>00078 <span class="comment">// expected exception type is Exception (expecting assertion failure).</span>00079 <span class="preprocessor">#if CPPUNIT_USE_TYPEINFO_NAME</span>00080 <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>(00081 <span class="stringliteral">"expected exception not thrown"</span>,00082 <span class="stringliteral">"Expected exception type: "</span> + 00083 TypeInfoHelper::getClassName( 00084 <span class="keyword">typeid</span>( <a class="code" href="class_exception_test_case_decorator.html#w0">ExpectedExceptionType</a> ) ) ) );00085 <span class="preprocessor">#else</span>00086 <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>(<span class="stringliteral">"expected exception not thrown"</span>) );00087 <span class="preprocessor">#endif</span>00088 <span class="preprocessor"></span> }00089 00090 <span class="keyword">private</span>:<a name="l00095"></a><a class="code" href="class_exception_test_case_decorator.html#d0">00095</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_exception_test_case_decorator.html#d0">checkException</a>( ExpectedExceptionType &e )00096 {00097 }00098 };00099 00100 00101 <a class="code" href="_portability_8h.html#a7">CPPUNIT_NS_END</a>00102 00103 <span class="preprocessor">#endif // CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H</span>00104 <span class="preprocessor"></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 + -