??xml version="1.0" encoding="utf-8" standalone="yes"?>99久久国产综合精品麻豆,99久久精品无码一区二区毛片,精品久久久久久中文字幕人妻最新http://www.shnenglu.com/volant/category/10539.htmlzh-cnFri, 16 Aug 2013 17:29:18 GMTFri, 16 Aug 2013 17:29:18 GMT60regex——正则表辑ּ中用方括号http://www.shnenglu.com/volant/archive/2010/04/12/112314.htmlMon, 12 Apr 2010 05:14:00 GMThttp://www.shnenglu.com/volant/archive/2010/04/12/112314.htmlhttp://www.shnenglu.com/volant/comments/112314.htmlhttp://www.shnenglu.com/volant/archive/2010/04/12/112314.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/112314.htmlhttp://www.shnenglu.com/volant/services/trackbacks/112314.html工作中经帔R要在正则表达式中使用ҎP比如匚wLinuxpȝ命o行提C符“[root@localhost ~]# ”。在python中,可以使用正则表达?#8220;[\[][^\[\]]*[\]][#|$] ”q行匚wQ但在regex中此正则表达式无法正匹配?br>׃man手册中缺对Ҏ可{义的介绍Q本文对regex中方括号的用进行测试,试E序如下Q?/p>
#include <stdio.h>
#include 
<string.h>

#include 
<sys/types.h>
#include 
<regex.h>

int main(int argc, char** argv)
{
        
char * pattern, *mstr;
        
int x, z, lno = 0, cflags = REG_EXTENDED;
        
char ebuf[128], lbuf[256], format[32];
        regex_t reg;
        regmatch_t pm[
10];
        
const size_t nmatch = 10;

        pattern 
= argv[1];
        z 
= regcomp(&reg, pattern, cflags);

        
if (z != 0)
        
{
                regerror(z, 
&reg, ebuf, sizeof(ebuf));
                fprintf(stderr, 
"%s: pattern '%s' \n",ebuf, pattern);
                regfree(
&reg);
                
return 1;
        }


        
while(fgets(lbuf, sizeof(lbuf), stdin))
        
{
                
++lno;
                
if ((z = strlen(lbuf)) > 0 && lbuf[z-1]== '\n') lbuf[z - 1= 0;

                z 
= regexec(&reg, lbuf, nmatch, pm, 0);
                
if (z == REG_NOMATCH)
                
{
                        printf(
"not match\n");
                        
continue;
                }

                
else if (z != 0)
                
{
                        regerror(z, 
&reg, ebuf, sizeof(ebuf));
                        fprintf(stderr, 
"%s: regcom('%s')\n",
                                        ebuf, lbuf);
                        
return 2;
                }


                
if (pm[0].rm_so!=-1)
                        printf(
"%04d: %s\n", lno, lbuf);
                
for (x = 0; x < nmatch && pm[x].rm_so != -1++ x)
                
{
                        mstr 
= strndup(lbuf + pm[x].rm_so, pm[x].rm_eo-pm[x].rm_so);
                        printf(
" $%d: %s\n", x, mstr);
                        free(mstr);
                }

                fflush(stdout);

        }


        regfree(
&reg);
        
return 0;
}
下面是对正则表达?#8220;[\[][^\[\]]*[\]][#|$] ” 的测试,昄不符合要求?
./testreg "[\[][^\[\]]*[\]][#|$] "  
[root@localhost bin]# 
not match
[a\]# 
0005: [a\]# 
 $
0: [a\]# 
从简单的开始先试左括?#8220;[”的匹配:
./testreg "[\[]+"
a
not match
[
0002: [
 $
0: [
[root@localhost bin]# 
0003: [root@localhost bin]# 
 $
0: [
再测试右括号“]”Q?
./testreg "[\]]+"
]
not match
\]  
0002: \]
 $
0: \]
-----------------
.
/testreg "[]]+"
]]
0001: ]]
 $
0: ]]
两个单的正则表达式可以看出:regex中左Ҏ号需要{义,x括号不需要{义?br>下面我们再来试匚w一下Q意非Ҏ号字W:
./testreg "[^\[]]+" //对[转义Q不对]转义
[abc]
0001: [abc]
 $
0: c]
.
/testreg "[^\[\]]+" //对[和]转义
[abc]
0001: [abc]
 $
0: c]
.
/testreg "[^]\[]+" //对[转义Q不对]转义Q且把]攑֜^后]不与前面的[匚w
[abc]
0001: [abc]
 $
0: abc
通过上面试可以得出正确的正则表辑ּ来匹配Linux命o行提C符—?#8220;[\[][^]\[]*[]][#$] ”?#8220;\[[^]\[]*][#$] ”?

2010-04-12 13:14 发表评论
]]>
[导入]标准C函数Qstrncpyhttp://www.shnenglu.com/volant/archive/2009/06/18/87973.htmlThu, 18 Jun 2009 06:38:00 GMThttp://www.shnenglu.com/volant/archive/2009/06/18/87973.htmlhttp://www.shnenglu.com/volant/comments/87973.htmlhttp://www.shnenglu.com/volant/archive/2009/06/18/87973.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/87973.htmlhttp://www.shnenglu.com/volant/services/trackbacks/87973.html
文章来源:http://blog.csdn.net/volant_hoo/archive/2009/05/11/4167919.aspx

2009-06-18 14:38 发表评论
]]>
[导入]GCC C语言扩展Q?Q?/title><link>http://www.shnenglu.com/volant/archive/2009/06/18/87972.html</link><dc:creator>夜</dc:creator><author>夜</author><pubDate>Thu, 18 Jun 2009 06:38:00 GMT</pubDate><guid>http://www.shnenglu.com/volant/archive/2009/06/18/87972.html</guid><wfw:comment>http://www.shnenglu.com/volant/comments/87972.html</wfw:comment><comments>http://www.shnenglu.com/volant/archive/2009/06/18/87972.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/volant/comments/commentRss/87972.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/volant/services/trackbacks/87972.html</trackback:ping><description><![CDATA[ 看开源的代码中发C一些静态函数声明后有如下内容:__attribute__ ((constructor))q是gcc的扩展属性?img src="http://blog.csdn.net/volant_hoo/aggbug/4169081.aspx" width="1" height="1"><br>文章来源:<a >http://blog.csdn.net/volant_hoo/archive/2009/05/11/4169081.aspx</a><img src ="http://www.shnenglu.com/volant/aggbug/87972.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/volant/" target="_blank">夜</a> 2009-06-18 14:38 <a href="http://www.shnenglu.com/volant/archive/2009/06/18/87972.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]从一到面试题谈vhttp://www.shnenglu.com/volant/archive/2009/06/18/87970.htmlThu, 18 Jun 2009 06:38:00 GMThttp://www.shnenglu.com/volant/archive/2009/06/18/87970.htmlhttp://www.shnenglu.com/volant/comments/87970.htmlhttp://www.shnenglu.com/volant/archive/2009/06/18/87970.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/87970.htmlhttp://www.shnenglu.com/volant/services/trackbacks/87970.html
文章来源:http://blog.csdn.net/volant_hoo/archive/2009/05/11/4169108.aspx

2009-06-18 14:38 发表评论
]]>
[导入]׃n内存http://www.shnenglu.com/volant/archive/2009/06/18/87971.htmlThu, 18 Jun 2009 06:38:00 GMThttp://www.shnenglu.com/volant/archive/2009/06/18/87971.htmlhttp://www.shnenglu.com/volant/comments/87971.htmlhttp://www.shnenglu.com/volant/archive/2009/06/18/87971.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/87971.htmlhttp://www.shnenglu.com/volant/services/trackbacks/87971.html
文章来源:http://blog.csdn.net/volant_hoo/archive/2009/05/11/4169093.aspx

2009-06-18 14:38 发表评论
]]>
gtest的一个简单扩展(q行旉试Q的实例http://www.shnenglu.com/volant/archive/2008/08/27/60203.htmlWed, 27 Aug 2008 15:34:00 GMThttp://www.shnenglu.com/volant/archive/2008/08/27/60203.htmlhttp://www.shnenglu.com/volant/comments/60203.htmlhttp://www.shnenglu.com/volant/archive/2008/08/27/60203.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/60203.htmlhttp://www.shnenglu.com/volant/services/trackbacks/60203.html上一中对gtestq行了一个简单的扩展Q本文通过实例试q介l这个扩展的用法?/p>

首先实现两个Fibonacci函数Q然后对q两个函数进行测试:

Fibonacci_1Q用@环实玎ͼ

unsigned int Fibonacci_1(unsigned int n)
{
    unsigned 
int i;
    unsigned 
int f0 = 1, f1 = 1, f2;
    
for (i = 1; i < n; i++)
    
{
        f2 
= f0 + f1;
        f0 
= f1;
        f1 
= f2;
    }

    
return f1;
}


Fibonacci_2Q用递归实现Q?/p>

unsigned int Fibonacci_2(unsigned int n)
{
    
switch (n)
    
{
        
case 0:
            
return 1;
        
case 1:
            
return 1;
        
default:
            
return Fibonacci_2(n - 1+ Fibonacci_2(n - 2);
    }

}


试用例Q?/p>

TEST_T(Fibonacci_Recursive, 30)
{
    Fibonacci_2(
30);
    ASSERT_TIME(
0.1);
}


TEST_T(Fibonacci_Loop, 
30)
{
    Fibonacci_1(
30);
    ASSERT_TIME(
0.1);
}


TEST_T(Fibonacci_Recursive, 
40)
{
    TEST_T_SHOWTIME();
    Fibonacci_2(
40);
    EXCEPT_TIME(
0.1);
    ASSERT_TIME(
1<< "\nUsed too long time!";
}


TEST_T(Fibonacci_Loop, 
40)
{
    TEST_T_SHOWTIME();
    Fibonacci_1(
40);
    EXCEPT_TIME(
0.1);
    ASSERT_TIME(
1<< "\nUsed too long time!";
}


试l果Q?/p>

 

[==========] Running 4 tests from 2 test cases.
[
----------] Global test environment set-up.
[
----------2 tests from TIME_Fibonacci_Recursive
[ RUN      ] TIME_Fibonacci_Recursive.
30
[       OK ] TIME_Fibonacci_Recursive.
30
[ RUN      ] TIME_Fibonacci_Recursive.
40
FibonacciTest.cpp:
47: Failure
Failed
Time: running 
2.9995(s) > 0.1(s)
FibonacciTest.cpp:
48: Failure
Failed
Time: running 
2.9995(s) > 1(s)
Used too 
long time!
[   TIME   ] used time: 
2.9995(s)
[  FAILED  ] TIME_Fibonacci_Recursive.
40
[
----------2 tests from TIME_Fibonacci_Loop
[ RUN      ] TIME_Fibonacci_Loop.
30
[       OK ] TIME_Fibonacci_Loop.
30
[ RUN      ] TIME_Fibonacci_Loop.
40
[   TIME   ] used time: 
0(s)
[       OK ] TIME_Fibonacci_Loop.
40
[
----------] Global test environment tear-down
[
==========4 tests from 2 test cases ran.
[  PASSED  ] 
3 tests.
[  FAILED  ] 
1 test, listed below:
[  FAILED  ] TIME_Fibonacci_Recursive.
40

 

实例中测试了四个试用例Q分别测试了两个函数分别计算Fibonacci(30)和Fibonacci(40)所p的时间。测试用??比较单,仅有一个ASSERT_TIME断言用于试q行到此该测试用例花费的旉。测试用??Q增加了两条语句QTEST_T_SHOWTIME()Q测试用例结束后打印执行旉QEXCEPT_TIME断言Q这里只是测试以下EXCEPT_TIME和ASSERT_TIME的区别,前者l执行后l语句,后者则l束当前的测试用例?img src ="http://www.shnenglu.com/volant/aggbug/60203.html" width = "1" height = "1" />

2008-08-27 23:34 发表评论
]]>
gtest的一个简单扩?/title><link>http://www.shnenglu.com/volant/archive/2008/08/27/60201.html</link><dc:creator>夜</dc:creator><author>夜</author><pubDate>Wed, 27 Aug 2008 15:14:00 GMT</pubDate><guid>http://www.shnenglu.com/volant/archive/2008/08/27/60201.html</guid><wfw:comment>http://www.shnenglu.com/volant/comments/60201.html</wfw:comment><comments>http://www.shnenglu.com/volant/archive/2008/08/27/60201.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/volant/comments/commentRss/60201.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/volant/services/trackbacks/60201.html</trackback:ping><description><![CDATA[<p>看了gtest的一个simpleQ其中有试q行旉的方法,但用v来稍微负责,因此做了一个简单的扩展?/p> <p>扩展内容Q?br />1. TEST_T(test_case_name, test_name)Q用于定义运行时间测试用例?br />2. TEST_T_SHOWTIME()Q打开打印试用例q行旉打印开兟?br />3. EXCEPT_TIME(second)和ASSERT_TIME(second)Q断aQsecond为doublecdQ测试运行时间是否小于second?/p> <p>使用说明Q?br />向正怋用一P只是在需要时间测试时include “gtest_e.h”卛_Q当然也得把相应的库链接到执行文件中?/p> <p>具体实现Q?br />源文件gtest_e.h----</p> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img id="Codehighlighter1_0_19_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_19_Open_Text.style.display='none'; Codehighlighter1_0_19_Closed_Image.style.display='inline'; Codehighlighter1_0_19_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_0_19_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_0_19_Closed_Text.style.display='none'; Codehighlighter1_0_19_Open_Image.style.display='inline'; Codehighlighter1_0_19_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"><span id="Codehighlighter1_0_19_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_0_19_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000">*<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /> * gtest_e.h<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" /> </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />#ifndef GTEST_E_H_<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000"> GTEST_E_H_</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />#include </span><span style="color: #000000">"</span><span style="color: #000000">gtest_time.h</span><span style="color: #000000">"</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000"> TEST_T(test_case_name, test_name)\</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />    GTEST_TEST(TIME_##test_case_name, test_name, ::TimeTest)<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000"> TEST_T_SHOWTIME() TimeTest_setShowFlag(1)</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000"> ASSERT_TIME(time) if(TimeTest_setTimePoint() - time > 0) \</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />    FAIL() </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">Time: running </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> TimeTest_getTime() </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">(s) > </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> time </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">(s)</span><span style="color: #000000">"</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000"> EXCEPT_TIME(time) if(TimeTest_setTimePoint() - time > 0) \</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />    ADD_FAILURE() </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">Time: running </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> TimeTest_getTime() </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">(s) > </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> time </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">(s)</span><span style="color: #000000">"</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#endif</span><span style="color: #000000"> /* GTEST_E_H_ */</span></div> 源文件gtest_time.h----<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img id="Codehighlighter1_0_22_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_22_Open_Text.style.display='none'; Codehighlighter1_0_22_Closed_Image.style.display='inline'; Codehighlighter1_0_22_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_0_22_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_0_22_Closed_Text.style.display='none'; Codehighlighter1_0_22_Open_Image.style.display='inline'; Codehighlighter1_0_22_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"><span id="Codehighlighter1_0_22_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_0_22_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000">*<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /> * gtest_time.h<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" /> </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />#ifndef GTEST_TIME_H_<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#define</span><span style="color: #000000"> GTEST_TIME_H_</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />#include </span><span style="color: #000000"><</span><span style="color: #000000">gtest</span><span style="color: #000000">/</span><span style="color: #000000">gtest.h</span><span style="color: #000000">></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">class</span><span style="color: #000000"> TimeTest: </span><span style="color: #0000ff">public</span><span style="color: #000000"> testing::Test<br /><img id="Codehighlighter1_133_490_Open_Image" onclick="this.style.display='none'; Codehighlighter1_133_490_Open_Text.style.display='none'; Codehighlighter1_133_490_Closed_Image.style.display='inline'; Codehighlighter1_133_490_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_133_490_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_133_490_Closed_Text.style.display='none'; Codehighlighter1_133_490_Open_Image.style.display='inline'; Codehighlighter1_133_490_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_133_490_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_133_490_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">public</span><span style="color: #000000">:<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    inline </span><span style="color: #0000ff">void</span><span style="color: #000000"> TimeTest_setShowFlag(</span><span style="color: #0000ff">int</span><span style="color: #000000"> flag)<br /><img id="Codehighlighter1_194_227_Open_Image" onclick="this.style.display='none'; Codehighlighter1_194_227_Open_Text.style.display='none'; Codehighlighter1_194_227_Closed_Image.style.display='inline'; Codehighlighter1_194_227_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_194_227_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_194_227_Closed_Text.style.display='none'; Codehighlighter1_194_227_Open_Image.style.display='inline'; Codehighlighter1_194_227_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top">    </span><span id="Codehighlighter1_194_227_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_194_227_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />        show_time_ </span><span style="color: #000000">=</span><span style="color: #000000"> flag;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    inline </span><span style="color: #0000ff">double</span><span style="color: #000000"> TimeTest_getTime()<br /><img id="Codehighlighter1_271_317_Open_Image" onclick="this.style.display='none'; Codehighlighter1_271_317_Open_Text.style.display='none'; Codehighlighter1_271_317_Closed_Image.style.display='inline'; Codehighlighter1_271_317_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_271_317_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_271_317_Closed_Text.style.display='none'; Codehighlighter1_271_317_Open_Image.style.display='inline'; Codehighlighter1_271_317_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top">    </span><span id="Codehighlighter1_271_317_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_271_317_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">return</span><span style="color: #000000"> end_time_ </span><span style="color: #000000">-</span><span style="color: #000000"> start_time_;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">double</span><span style="color: #000000"> TimeTest_setTimePoint();<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /></span><span style="color: #0000ff">protected</span><span style="color: #000000">:<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">double</span><span style="color: #000000"> start_time_;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">double</span><span style="color: #000000"> end_time_;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">int</span><span style="color: #000000"> show_time_;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">virtual</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> SetUp();<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">virtual</span><span style="color: #000000"> </span><span style="color: #0000ff">void</span><span style="color: #000000"> TearDown();<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000">;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#endif</span><span style="color: #000000"> /* GTEST_TIME_H_ */</span></div> 源文件gtest_time.cpp----<br /> <div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><img id="Codehighlighter1_0_24_Open_Image" onclick="this.style.display='none'; Codehighlighter1_0_24_Open_Text.style.display='none'; Codehighlighter1_0_24_Closed_Image.style.display='inline'; Codehighlighter1_0_24_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_0_24_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_0_24_Closed_Text.style.display='none'; Codehighlighter1_0_24_Open_Image.style.display='inline'; Codehighlighter1_0_24_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"><span id="Codehighlighter1_0_24_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff">/**/</span><span id="Codehighlighter1_0_24_Open_Text"><span style="color: #008000">/*</span><span style="color: #008000">*<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" /> * gtest_time.cpp<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" /> </span><span style="color: #008000">*/</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />#include </span><span style="color: #000000"><</span><span style="color: #000000">iostream</span><span style="color: #000000">></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />#include </span><span style="color: #000000">"</span><span style="color: #000000">gtest_time.h</span><span style="color: #000000">"</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">using</span><span style="color: #000000"> </span><span style="color: #0000ff">namespace</span><span style="color: #000000"> std;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#if</span><span style="color: #000000"> defined(WIN32)</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" />#include </span><span style="color: #000000"><</span><span style="color: #000000">sys</span><span style="color: #000000">/</span><span style="color: #000000">timeb.h</span><span style="color: #000000">></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">double</span><span style="color: #000000"> now()<br /><img id="Codehighlighter1_149_275_Open_Image" onclick="this.style.display='none'; Codehighlighter1_149_275_Open_Text.style.display='none'; Codehighlighter1_149_275_Closed_Image.style.display='inline'; Codehighlighter1_149_275_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_149_275_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_149_275_Closed_Text.style.display='none'; Codehighlighter1_149_275_Open_Image.style.display='inline'; Codehighlighter1_149_275_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_149_275_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_149_275_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">struct</span><span style="color: #000000"> _timeb current;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    _ftime(</span><span style="color: #000000">&</span><span style="color: #000000">current);<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">return</span><span style="color: #000000"> (((</span><span style="color: #0000ff">double</span><span style="color: #000000">) current.time) </span><span style="color: #000000">+</span><span style="color: #000000"> (</span><span style="color: #000000">1.0</span><span style="color: #000000"> </span><span style="color: #000000">*</span><span style="color: #000000"> current.millitm) </span><span style="color: #000000">*</span><span style="color: #000000"> </span><span style="color: #000000">0.000001</span><span style="color: #000000">);<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#else</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">double</span><span style="color: #000000"> now()<br /><img id="Codehighlighter1_296_438_Open_Image" onclick="this.style.display='none'; Codehighlighter1_296_438_Open_Text.style.display='none'; Codehighlighter1_296_438_Closed_Image.style.display='inline'; Codehighlighter1_296_438_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_296_438_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_296_438_Closed_Text.style.display='none'; Codehighlighter1_296_438_Open_Image.style.display='inline'; Codehighlighter1_296_438_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_296_438_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_296_438_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">struct</span><span style="color: #000000"> timeval current;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    gettimeofday(</span><span style="color: #000000">&</span><span style="color: #000000">current, NULL);<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">return</span><span style="color: #000000"> (((</span><span style="color: #0000ff">double</span><span style="color: #000000">) current.tv_sec) </span><span style="color: #000000">+</span><span style="color: #000000"> </span><span style="color: #000000">1.0e-6</span><span style="color: #000000"> </span><span style="color: #000000">*</span><span style="color: #000000"> ((</span><span style="color: #0000ff">double</span><span style="color: #000000">) current.tv_usec));<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">#endif</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000"> TimeTest::SetUp()<br /><img id="Codehighlighter1_471_546_Open_Image" onclick="this.style.display='none'; Codehighlighter1_471_546_Open_Text.style.display='none'; Codehighlighter1_471_546_Closed_Image.style.display='inline'; Codehighlighter1_471_546_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_471_546_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_471_546_Closed_Text.style.display='none'; Codehighlighter1_471_546_Open_Image.style.display='inline'; Codehighlighter1_471_546_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_471_546_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_471_546_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    start_time_ </span><span style="color: #000000">=</span><span style="color: #000000"> now();<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    end_time_ </span><span style="color: #000000">=</span><span style="color: #000000"> </span><span style="color: #000000">0</span><span style="color: #000000">;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    TimeTest_setShowFlag(</span><span style="color: #000000">0</span><span style="color: #000000">);<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">void</span><span style="color: #000000"> TimeTest::TearDown()<br /><img id="Codehighlighter1_575_751_Open_Image" onclick="this.style.display='none'; Codehighlighter1_575_751_Open_Text.style.display='none'; Codehighlighter1_575_751_Closed_Image.style.display='inline'; Codehighlighter1_575_751_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_575_751_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_575_751_Closed_Text.style.display='none'; Codehighlighter1_575_751_Open_Image.style.display='inline'; Codehighlighter1_575_751_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_575_751_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_575_751_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (show_time_)<br /><img id="Codehighlighter1_601_749_Open_Image" onclick="this.style.display='none'; Codehighlighter1_601_749_Open_Text.style.display='none'; Codehighlighter1_601_749_Closed_Image.style.display='inline'; Codehighlighter1_601_749_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top"><img id="Codehighlighter1_601_749_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_601_749_Closed_Text.style.display='none'; Codehighlighter1_601_749_Open_Image.style.display='inline'; Codehighlighter1_601_749_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align="top">    </span><span id="Codehighlighter1_601_749_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_601_749_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />        </span><span style="color: #0000ff">double</span><span style="color: #000000"> used_time </span><span style="color: #000000">=</span><span style="color: #000000"> TimeTest_setTimePoint();<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />        cout </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">[   TIME   ] used time: </span><span style="color: #000000">"</span><span style="color: #000000"> </span><span style="color: #000000"><<</span><span style="color: #000000"> used_time </span><span style="color: #000000"><<</span><span style="color: #000000"> </span><span style="color: #000000">"</span><span style="color: #000000">(s)</span><span style="color: #000000">"</span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />                </span><span style="color: #000000"><<</span><span style="color: #000000"> endl;<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" alt="" />    }</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span><span style="color: #0000ff">double</span><span style="color: #000000"> TimeTest::TimeTest_setTimePoint()<br /><img id="Codehighlighter1_795_851_Open_Image" onclick="this.style.display='none'; Codehighlighter1_795_851_Open_Text.style.display='none'; Codehighlighter1_795_851_Closed_Image.style.display='inline'; Codehighlighter1_795_851_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_795_851_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_795_851_Closed_Text.style.display='none'; Codehighlighter1_795_851_Open_Image.style.display='inline'; Codehighlighter1_795_851_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align="top"></span><span id="Codehighlighter1_795_851_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif" alt="" /></span><span id="Codehighlighter1_795_851_Open_Text"><span style="color: #000000">{<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    end_time_ </span><span style="color: #000000">=</span><span style="color: #000000"> now();<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align="top" alt="" />    </span><span style="color: #0000ff">return</span><span style="color: #000000"> TimeTest_getTime();<br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" alt="" />}</span></span><span style="color: #000000"><br /><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align="top" alt="" /></span></div> <br />以上内容只是一个简单的实现Q没有过多的试Q且旉_ֺ不够Q误差较大?img src ="http://www.shnenglu.com/volant/aggbug/60201.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/volant/" target="_blank">夜</a> 2008-08-27 23:14 <a href="http://www.shnenglu.com/volant/archive/2008/08/27/60201.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gtestQgoogle的c++单元试Q试?/title><link>http://www.shnenglu.com/volant/archive/2008/07/31/57620.html</link><dc:creator>夜</dc:creator><author>夜</author><pubDate>Thu, 31 Jul 2008 04:52:00 GMT</pubDate><guid>http://www.shnenglu.com/volant/archive/2008/07/31/57620.html</guid><wfw:comment>http://www.shnenglu.com/volant/comments/57620.html</wfw:comment><comments>http://www.shnenglu.com/volant/archive/2008/07/31/57620.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/volant/comments/commentRss/57620.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/volant/services/trackbacks/57620.html</trackback:ping><description><![CDATA[google开源了c++单元试框架Q真让h兴奋。安装的q程比较单,在eclipse+mingw+cygwin下很easy搞定了。用也很容易,按照sample不用看文也能很快上手。过E就不多了Q记点东西备忘?br /><br />断言Q?br />ASSERT_TRUE(condition); EXPECT_TRUE(condition); condition为真<br />ASSERT_FALSE(condition);    EXPECT_FALSE(condition);    condition为假<br /><br />ASSERT_EQ(expected, actual);    EXPECT_EQ(expected, actual);    expected == actual<br />ASSERT_NE(val1, val2);  EXPECT_NE(val1, val2);  val1 != val2<br />ASSERT_LT(val1, val2);  EXPECT_LT(val1, val2);  val1 < val2<br />ASSERT_LE(val1, val2);  EXPECT_LE(val1, val2);  val1 <= val2<br />ASSERT_GT(val1, val2);  EXPECT_GT(val1, val2);  val1 > val2<br />ASSERT_GE(val1, val2);  EXPECT_GE(val1, val2);  val1 >= val2<br /><br />ASSERT_STREQ(expected_str, actual_str); EXPECT_STREQ(expected_str, actual_str); 两个C字符串有相同的内?br />ASSERT_STRNE(str1, str2);   EXPECT_STRNE(str1, str2); 两个C字符串有不同的内?br />ASSERT_STRCASEEQ(expected_str, actual_str); EXPECT_STRCASEEQ(expected_str, actual_str); 两个C字符串有相同的内容,忽略大小?br />ASSERT_STRCASENE(str1, str2);   EXPECT_STRCASENE(str1, str2);   两个C字符串有不同的内容,忽略大小?br /><br />头文Ӟ<br />#include <gtest/gtest.h><br /><br />mainQ?br />    testing::InitGoogleTest(&argc, argv);<br />    return RUN_ALL_TESTS();<br /><br />库:<br />    -lgtest<br /><br /><img src ="http://www.shnenglu.com/volant/aggbug/57620.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/volant/" target="_blank">夜</a> 2008-07-31 12:52 <a href="http://www.shnenglu.com/volant/archive/2008/07/31/57620.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[导入]搭徏cppunit单元试环境http://www.shnenglu.com/volant/archive/2008/06/02/57611.htmlMon, 02 Jun 2008 10:30:00 GMThttp://www.shnenglu.com/volant/archive/2008/06/02/57611.htmlhttp://www.shnenglu.com/volant/comments/57611.htmlhttp://www.shnenglu.com/volant/archive/2008/06/02/57611.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/57611.htmlhttp://www.shnenglu.com/volant/services/trackbacks/57611.html
文章来源:http://blog.csdn.net/volant_hoo/archive/2008/06/02/2502339.aspx

2008-06-02 18:30 发表评论
]]>
[导入]l典法——求最大子序列?2) http://www.shnenglu.com/volant/archive/2008/04/07/57614.htmlMon, 07 Apr 2008 12:16:00 GMThttp://www.shnenglu.com/volant/archive/2008/04/07/57614.htmlhttp://www.shnenglu.com/volant/comments/57614.htmlhttp://www.shnenglu.com/volant/archive/2008/04/07/57614.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/57614.htmlhttp://www.shnenglu.com/volant/services/trackbacks/57614.html
文章来源:http://blog.csdn.net/volant_hoo/archive/2008/04/07/2256611.aspx

2008-04-07 20:16 发表评论
]]>
[导入]l典法——求最大子序列?1)http://www.shnenglu.com/volant/archive/2008/04/05/57615.htmlFri, 04 Apr 2008 23:54:00 GMThttp://www.shnenglu.com/volant/archive/2008/04/05/57615.htmlhttp://www.shnenglu.com/volant/comments/57615.htmlhttp://www.shnenglu.com/volant/archive/2008/04/05/57615.html#Feedback0http://www.shnenglu.com/volant/comments/commentRss/57615.htmlhttp://www.shnenglu.com/volant/services/trackbacks/57615.html
文章来源:http://blog.csdn.net/volant_hoo/archive/2008/04/04/2252490.aspx

2008-04-05 07:54 发表评论
]]>
Ʒ99þò| þü޾Ʒ?V| ɫþAVۺ| þþþƷ鶹| Ʒþþþþ| ۺϾþþƷ| պƷþþþþ| þþþ18| 99ƷȾþ޶| ۺϾþĻ| www.þ| þۺϳ| 777þµַ| պŷþ| 69ۺϾþþƷ| þ޹Ʒ123| һþ㽶߿ۿ | ˾þۺӰԺ| Ʒþþþþר| ɫþ| 99þþƷþþþþ崿| þۺϺݺۺϾþ| ɫۺϾþ| ҹƷþþþþžŵӰ| Ļþۺ| þþƷһպ| 7777þĻ| ɫ͵͵88888ŷƷþþ| 99þѹƷػ| þAVԴվ| þþžžþƷֱ| þŷձƷ| þþƷavӰԺ| ŷսþþþþþþ| ݺɫþۺ| 2021þþƷѹۿ| þþžžþƷֱ| ŷ˾þþƷ| ޾Ʒþþþþ| 鶹һ99þþþ| þùȾƷҰAV|