source: NonGTP/FCollada/Documentation/_f_u_test_bed_8h-source.html @ 964

Revision 964, 9.7 KB checked in by igarcia, 18 years ago (diff)
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3<title>FCollada: FUtils/FUTestBed.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.4.6-NO -->
8<div class="tabs">
9  <ul>
10    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11    <li><a href="modules.html"><span>Modules</span></a></li>
12    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
13    <li><a href="classes.html"><span>Classes</span></a></li>
14    <li id="current"><a href="files.html"><span>Files</span></a></li>
15    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
16  </ul></div>
17<div class="tabs">
18  <ul>
19    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
20    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
21  </ul></div>
22<h1>FUtils/FUTestBed.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
23<a name="l00002"></a>00002 <span class="comment">    Copyright (C) 2005-2006 Feeling Software Inc.</span>
24<a name="l00003"></a>00003 <span class="comment">    MIT License: http://www.opensource.org/licenses/mit-license.php</span>
25<a name="l00004"></a>00004 <span class="comment">*/</span>
26<a name="l00005"></a>00005
27<a name="l00006"></a>00006 <span class="preprocessor">#ifndef _FU_TESTBED_H_</span>
28<a name="l00007"></a>00007 <span class="preprocessor"></span><span class="preprocessor">#define _FU_TESTBED_H_</span>
29<a name="l00008"></a>00008 <span class="preprocessor"></span>
30<a name="l00009"></a>00009 <span class="preprocessor">#include "FUtils/FULogFile.h"</span>
31<a name="l00010"></a>00010
32<a name="l00011"></a>00011 <span class="keyword">class </span>FUTestSuite;
33<a name="l00012"></a>00012
34<a name="l00014"></a>00014 <span class="comment">// QTestBed class</span>
35<a name="l00015"></a>00015 <span class="comment">//</span>
36<a name="l00016"></a>00016 <span class="keyword">class </span>FUTestBed
37<a name="l00017"></a>00017 {
38<a name="l00018"></a>00018 <span class="keyword">private</span>:
39<a name="l00019"></a>00019     size_t testPassed, testFailed;
40<a name="l00020"></a>00020     FULogFile fileOut;
41<a name="l00021"></a>00021     string filename;
42<a name="l00022"></a>00022 <span class="keywordtype">bool</span> isVerbose;
43<a name="l00023"></a>00023
44<a name="l00024"></a>00024 <span class="keyword">public</span>:
45<a name="l00025"></a>00025 FUTestBed(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename, <span class="keywordtype">bool</span> isVerbose);
46<a name="l00026"></a>00026
47<a name="l00027"></a>00027 <span class="keyword">inline</span> <span class="keywordtype">bool</span> IsVerbose()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> isVerbose; }
48<a name="l00028"></a>00028
49<a name="l00029"></a>00029 <span class="keywordtype">bool</span> RunTestbed(FUTestSuite* headTestSuite);
50<a name="l00030"></a>00030 <span class="keywordtype">void</span> RunTestSuite(FUTestSuite* testSuite);
51<a name="l00031"></a>00031 };
52<a name="l00032"></a>00032
53<a name="l00034"></a>00034 <span class="comment">// QTestSuite class</span>
54<a name="l00035"></a>00035 <span class="comment">//</span>
55<a name="l00036"></a>00036 <span class="keyword">class </span>FUTestSuite
56<a name="l00037"></a>00037 {
57<a name="l00038"></a>00038 <span class="keyword">public</span>:
58<a name="l00039"></a>00039 <span class="keyword">virtual</span> size_t GetTestCount() = 0;
59<a name="l00040"></a>00040 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> RunTest(FUTestBed&amp; testBed, FULogFile&amp; fileOut, size_t testIndex) = 0;
60<a name="l00041"></a>00041 };
61<a name="l00042"></a>00042
62<a name="l00044"></a>00044 <span class="comment">// Helpful Macros</span>
63<a name="l00045"></a>00045 <span class="comment">//</span>
64<a name="l00046"></a>00046 <span class="preprocessor">#if defined(_FU_ASSERT_H_) &amp;&amp; defined(_DEBUG)</span>
65<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#define FailIf(a) \</span>
66<a name="l00048"></a>00048 <span class="preprocessor">    if ((a)) { \</span>
67<a name="l00049"></a>00049 <span class="preprocessor">        fileOut.WriteLine(__FILE__, __LINE__, " Test('%s') failed: %s.", szTestName, #a); \</span>
68<a name="l00050"></a>00050 <span class="preprocessor">        extern bool skipAsserts; \</span>
69<a name="l00051"></a>00051 <span class="preprocessor">        if (!skipAsserts) { \</span>
70<a name="l00052"></a>00052 <span class="preprocessor">            __DEBUGGER_BREAK; \</span>
71<a name="l00053"></a>00053 <span class="preprocessor">            skipAsserts = ignoreAssert; } \</span>
72<a name="l00054"></a>00054 <span class="preprocessor">        return false; }</span>
73<a name="l00055"></a>00055 <span class="preprocessor"></span>
74<a name="l00056"></a>00056 <span class="preprocessor">#else // _FU_ASSERT_H_ &amp;&amp; _DEBUG</span>
75<a name="l00057"></a>00057 <span class="preprocessor"></span>
76<a name="l00058"></a>00058 <span class="preprocessor">#define FailIf(a) \</span>
77<a name="l00059"></a>00059 <span class="preprocessor">    if ((a)) { \</span>
78<a name="l00060"></a>00060 <span class="preprocessor">        fileOut.WriteLine(__FILE__, __LINE__, " Test('%s') failed: %s.", szTestName, #a); \</span>
79<a name="l00061"></a>00061 <span class="preprocessor">        return false; }</span>
80<a name="l00062"></a>00062 <span class="preprocessor"></span>
81<a name="l00063"></a>00063 <span class="preprocessor">#endif // _FU_ASSERT_H_</span>
82<a name="l00064"></a>00064 <span class="preprocessor"></span>
83<a name="l00065"></a>00065 <span class="preprocessor">#define PassIf(a) FailIf(!(a))</span>
84<a name="l00066"></a>00066 <span class="preprocessor"></span>
85<a name="l00067"></a>00067 <span class="preprocessor">#define Fail { bool b = true; FailIf(b); }</span>
86<a name="l00068"></a>00068 <span class="preprocessor"></span>
87<a name="l00069"></a>00069 <span class="preprocessor">#define TESTSUITE_START(suiteName) \</span>
88<a name="l00070"></a>00070 <span class="preprocessor">FUTestSuite* _test##suiteName; \</span>
89<a name="l00071"></a>00071 <span class="preprocessor">class FUTestSuite##suiteName : public FUTestSuite \</span>
90<a name="l00072"></a>00072 <span class="preprocessor">{ \</span>
91<a name="l00073"></a>00073 <span class="preprocessor">public: \</span>
92<a name="l00074"></a>00074 <span class="preprocessor">    FUTestSuite##suiteName() : FUTestSuite() { _test##suiteName = this; } \</span>
93<a name="l00075"></a>00075 <span class="preprocessor">    bool RunTest(FUTestBed&amp; testBed, FULogFile&amp; fileOut, size_t testIndex) \</span>
94<a name="l00076"></a>00076 <span class="preprocessor">    { \</span>
95<a name="l00077"></a>00077 <span class="preprocessor">        switch (testIndex) { \</span>
96<a name="l00078"></a>00078 <span class="preprocessor">            case ~0u : { \</span>
97<a name="l00079"></a>00079 <span class="preprocessor">                if (testBed.IsVerbose()) { \</span>
98<a name="l00080"></a>00080 <span class="preprocessor">                    fileOut.WriteLine("Running %s...", #suiteName); \</span>
99<a name="l00081"></a>00081 <span class="preprocessor">                }</span>
100<a name="l00082"></a>00082 <span class="preprocessor"></span>
101<a name="l00083"></a>00083 <span class="preprocessor">#define TESTSUITE_TEST(test_name) \</span>
102<a name="l00084"></a>00084 <span class="preprocessor">            } return true; \</span>
103<a name="l00085"></a>00085 <span class="preprocessor">        case (__COUNTER__): { \</span>
104<a name="l00086"></a>00086 <span class="preprocessor">            static const char* szTestName = #test_name;</span>
105<a name="l00087"></a>00087 <span class="preprocessor"></span>
106<a name="l00088"></a>00088 <span class="preprocessor">#define TESTSUITE_END \</span>
107<a name="l00089"></a>00089 <span class="preprocessor">            } return true; \</span>
108<a name="l00090"></a>00090 <span class="preprocessor">        } \</span>
109<a name="l00091"></a>00091 <span class="preprocessor">        fileOut.WriteLine(__FILE__, __LINE__, " Test suite implementation error."); \</span>
110<a name="l00092"></a>00092 <span class="preprocessor">        return false; \</span>
111<a name="l00093"></a>00093 <span class="preprocessor">    } \</span>
112<a name="l00094"></a>00094 <span class="preprocessor">    size_t GetTestCount() { return __COUNTER__; } \</span>
113<a name="l00095"></a>00095 <span class="preprocessor">} __testSuite;</span>
114<a name="l00096"></a>00096 <span class="preprocessor"></span>
115<a name="l00097"></a>00097 <span class="preprocessor">#define RUN_TESTSUITE(suiteName) \</span>
116<a name="l00098"></a>00098 <span class="preprocessor">    extern FUTestSuite* _test##suiteName; \</span>
117<a name="l00099"></a>00099 <span class="preprocessor">    testBed.RunTestSuite(_test##suiteName);</span>
118<a name="l00100"></a>00100 <span class="preprocessor"></span>
119<a name="l00101"></a>00101 <span class="preprocessor">#define RUN_TESTBED(szTestSuiteHead, testPassed) { \</span>
120<a name="l00102"></a>00102 <span class="preprocessor">    FUTestBed testBed; \</span>
121<a name="l00103"></a>00103 <span class="preprocessor">    extern FUTestSuite* _test##szTestSuiteHead; \</span>
122<a name="l00104"></a>00104 <span class="preprocessor">    testPassed = testBed.RunTestbed(_test##szTestSuiteHead); }</span>
123<a name="l00105"></a>00105 <span class="preprocessor"></span>
124<a name="l00106"></a>00106 <span class="preprocessor">#endif // _FU_TESTBED_H_</span>
125</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 12 16:44:39 2006 for FCollada by&nbsp;
126<a href="http://www.doxygen.org/index.html">
127<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6-NO </small></address>
128</body>
129</html>
Note: See TracBrowser for help on using the repository browser.