📄 rcunit__proc_8c-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=gb2312"><title>RCUnit: src/rcunit_proc.c源文件</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- 制作者 Doxygen 1.4.2 --><div class="qindex"><a class="qindex" href="index.html">首页</a> | <a class="qindex" href="modules.html">模块</a> | <a class="qindex" href="annotated.html">数据结构</a> | <a class="qindex" href="dirs.html">目录</a> | <a class="qindex" href="files.html">文件列表</a> | <a class="qindex" href="functions.html">数据字段</a> | <a class="qindex" href="globals.html">全局定义</a> | <a class="qindex" href="pages.html">相关页面</a></div><div class="nav"><a class="el" href="dir_000002.html">src</a></div><h1>rcunit_proc.c</h1><a href="rcunit__proc_8c.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment">00001 00006 <span class="preprocessor">#ifdef __cplusplus</span>00007 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {00008 <span class="preprocessor">#endif</span>00009 <span class="preprocessor"></span>00010 <span class="preprocessor">#include <stdio.h></span>00011 <span class="preprocessor">#include <string.h></span>00012 <span class="preprocessor">#include <malloc.h></span>00013 <span class="preprocessor">#include <stdlib.h></span>00014 <span class="preprocessor">#include <stdarg.h></span>00015 00016 <span class="preprocessor">#include "../include/rcunit/rcunit.h"</span>00017 <span class="preprocessor">#include "../include/rcunit/rcunit_mem.h"</span>00018 00019 <a class="code" href="struct____tagCUnitTestSuiteListNode.html">__CUNIT_TEST_SUITE_LIST_NODE_S</a> _CUNIT_TEST_SUITE_LIST_NAME = {0};00020 <a name="l00028"></a><a class="code" href="rcunit__func_8h.html#a0">00028</a> <span class="keywordtype">void</span> <a class="code" href="rcunit__proc_8c.html#a1">_CUnit_RunAllTest</a>()00029 {00030 <a class="code" href="struct____tagCUnitTestSuiteListNode.html">__CUNIT_TEST_SUITE_LIST_NODE_S</a> *pSuiteList = _CUNIT_TEST_SUITE_LIST_NAME.<a class="code" href="struct____tagCUnitTestSuiteListNode.html#o0">next</a>;00031 <a class="code" href="struct____tagCUnitTestCaseListNode.html">__CUNIT_TEST_CASE_LIST_NODE_S</a> *pCaseList = NULL;00032 <a class="code" href="struct____tagCUnitTestCaseFailedMsg.html">__CUNIT_TEST_CASE_FAILED_MSG_S</a> *pErrMsgHead = NULL;00033 <a class="code" href="struct____tagCUnitTestCaseFailedMsg.html">__CUNIT_TEST_CASE_FAILED_MSG_S</a> *pErrMsgTail = NULL;00034 <span class="keywordtype">int</span> nTotalSuiteCnt = 0;00035 <span class="keywordtype">long</span> nTotalCaseCnt = 0;00036 <span class="keywordtype">long</span> oldCnt = 0;00037 00038 <a class="code" href="rcunit__asserter_8c.html#a8">_CUnit_ResetBlockedCaseCount</a>();00039 00040 <span class="comment">/* 遍历所有的Suite */</span>00041 <span class="keywordflow">while</span> (pSuiteList)00042 {00043 nTotalSuiteCnt++;00044 pCaseList = pSuiteList-><a class="code" href="struct____tagCUnitTestSuiteListNode.html#o1">suite</a>-><a class="code" href="struct____tagCUnitTestSuite.html#o0">head</a>;00045 00046 <span class="comment">/* 遍历Suite下所有的测试用例 */</span>00047 <span class="keywordflow">while</span> (pCaseList)00048 {00049 nTotalCaseCnt++;00050 oldCnt = <a class="code" href="rcunit__asserter_8c.html#a7">_CUnit_GetBlockedCaseCount</a>();00051 00052 <span class="comment">/* 执行测试用例 */</span>00053 pSuiteList-><a class="code" href="struct____tagCUnitTestSuiteListNode.html#o1">suite</a>-><a class="code" href="struct____tagCUnitTestSuite.html#o2">setUp</a>();00054 pCaseList->func();00055 pSuiteList-><a class="code" href="struct____tagCUnitTestSuiteListNode.html#o1">suite</a>-><a class="code" href="struct____tagCUnitTestSuite.html#o3">tearDown</a>();00056 00057 <span class="comment">/* 如果用例并没有失败 */</span>00058 <span class="keywordflow">if</span> (oldCnt == <a class="code" href="rcunit__asserter_8c.html#a7">_CUnit_GetBlockedCaseCount</a>())00059 {00060 _CUNIT_OUTPUT(<span class="stringliteral">"."</span>);00061 }00062 <span class="keywordflow">else</span> <span class="comment">/* 如果用例失败了 */</span>00063 {00064 <span class="comment">/* 记录失败信息 */</span>00065 <span class="keywordtype">char</span> *msg = <a class="code" href="rcunit__mem_8h.html#a0">_CUNIT_MALLOC</a>(strlen(<a class="code" href="rcunit__asserter_8c.html#a9">_CUnit_GetErrorMsg</a>()) + 1);00066 <a class="code" href="struct____tagCUnitTestCaseFailedMsg.html">__CUNIT_TEST_CASE_FAILED_MSG_S</a> *pErrMsg = (<a class="code" href="struct____tagCUnitTestCaseFailedMsg.html">__CUNIT_TEST_CASE_FAILED_MSG_S</a>*)<a class="code" href="rcunit__mem_8h.html#a0">_CUNIT_MALLOC</a>(<span class="keyword">sizeof</span>(<a class="code" href="struct____tagCUnitTestCaseFailedMsg.html">__CUNIT_TEST_CASE_FAILED_MSG_S</a>));00067 00068 <span class="keywordflow">if</span> (!msg || !pErrMsg)00069 {00070 _CUNIT_OUTPUT(<span class="stringliteral">"\r\nFatal Error: Can not malloc enough memory!\r\n"</span>);00071 exit(<a class="code" href="rcunit__def_8h.html#a1">CUNIT_RET_FAILED</a>);00072 }00073 00074 strcpy(msg, <a class="code" href="rcunit__asserter_8c.html#a9">_CUnit_GetErrorMsg</a>());00075 pErrMsg-><a class="code" href="struct____tagCUnitTestCaseFailedMsg.html#o1">msg</a> = msg;00076 pErrMsg-><a class="code" href="struct____tagCUnitTestCaseFailedMsg.html#o0">next</a> = NULL;00077 00078 <span class="comment">/* 如果是第一次失败,那么更新头结点 */</span>00079 <span class="keywordflow">if</span> (!pErrMsgHead)00080 {00081 pErrMsgHead = pErrMsg;00082 }00083 <span class="keywordflow">else</span> <span class="comment">/* 如果不是,则挂在尾结点后面 */</span>00084 {00085 pErrMsgTail-><a class="code" href="struct____tagCUnitTestCaseFailedMsg.html#o0">next</a> = pErrMsg;00086 }00087 00088 pErrMsgTail = pErrMsg;00089 pSuiteList-><a class="code" href="struct____tagCUnitTestSuiteListNode.html#o2">isFailed</a> = 1;00090 _CUNIT_OUTPUT(<span class="stringliteral">"F"</span>);00091 }00092 00093 pCaseList = pCaseList->next;00094 }00095 00096 pSuiteList = pSuiteList-><a class="code" href="struct____tagCUnitTestSuiteListNode.html#o0">next</a>;00097 }00098 00099 _CUNIT_OUTPUT(<span class="stringliteral">"\r\n"</span>);00100 00101 <span class="comment">/* 如果有用例失败了 */</span>00102 <span class="keywordflow">if</span> (<a class="code" href="rcunit__asserter_8c.html#a7">_CUnit_GetBlockedCaseCount</a>())00103 {00104 <a class="code" href="struct____tagCUnitTestCaseFailedMsg.html">__CUNIT_TEST_CASE_FAILED_MSG_S</a> *pErrMsgTemp = pErrMsgHead;00105 00106 <span class="comment">/* 遍历错误信息表 */</span>00107 <span class="keywordflow">while</span> (pErrMsgHead)00108 {00109 pErrMsgTemp = pErrMsgHead-><a class="code" href="struct____tagCUnitTestCaseFailedMsg.html#o0">next</a>;00110 _CUNIT_OUTPUT(pErrMsgHead-><a class="code" href="struct____tagCUnitTestCaseFailedMsg.html#o1">msg</a>);00111 <a class="code" href="rcunit__mem_8h.html#a1">_CUNIT_FREE</a>(pErrMsgHead-><a class="code" href="struct____tagCUnitTestCaseFailedMsg.html#o1">msg</a>);00112 <a class="code" href="rcunit__mem_8h.html#a1">_CUNIT_FREE</a>(pErrMsgHead);00113 pErrMsgHead = pErrMsgTemp;00114 }00115 00116 pErrMsgHead = NULL;00117 pErrMsgTail = NULL;00118 00119 _CUNIT_OUTPUT(<span class="stringliteral">"\r\nTotal Suite: %d"</span>, nTotalSuiteCnt);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -