• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            xyjzsh

            first demo for gtest

            1.  首先給出第一個(gè)運(yùn)用gtest的demo
            #include "stdafx.h"
            #include 
            "gmock/gmock-actions.h"

            using namespace testing;

            class Calculate
            {
            public:
                Calculate()
            {}
                
            long add(long a,long b){return a+b;}
            }
            ;

            class CalculateMock:public Calculate
            {
            public:
                CalculateMock():Calculate()
            {}
                MOCK_METHOD2(add,
            long(long a,long b));
            }
            ;

            long testFun(Calculate& cal)
            {
                
            return cal.add(2,3);
            }

            TEST(testMock,testAdd)
            {
                CalculateMock obj;
                
            long len = 10;
                ON_CALL(obj,add(
            2,3)).WillByDefault(Return(len)); 
                EXPECT_CALL(obj,add(
            2,3)).Times(1);
                
            //obj.add(2,3);
                EXPECT_EQ(10, obj.add(2,3));
            }


            int _tmain(int argc, _TCHAR* argv[])
            {
                testing::InitGoogleMock(
            &argc, argv);  
                RUN_ALL_TESTS();
                
            return 0;
            }



            做第一個(gè)demo需要注意的事項(xiàng):
            1. 將用到的gtest,gmock,和你自己運(yùn)用的project用同樣的code generation 的形式一致,將 project property->C++->Code Generation: 設(shè)置為:Multi-threaded Debug(/MTd)
            2. 添加 using namespace testing, 否則會(huì)出現(xiàn)‘Return’Identifier not found.這樣的錯(cuò)誤

            So excited to make it work after so much confusion, anxiety.
            Fighting!!

            posted @ 2013-02-06 17:14 呆人 閱讀(478) | 評(píng)論 (0)編輯 收藏

            Failed to retrieve paths under VSTemplate for the specified registry hive[轉(zhuǎn)載]

            最近更換開(kāi)發(fā)機(jī)的環(huán)境,從Windows XP換到Windows 7,結(jié)果以前在XP下的一個(gè)VS2008的一個(gè)插件項(xiàng)目在新環(huán)境中編譯老是出錯(cuò):

            AnswerFailed to retrieve paths under VSTemplate for the specified registry hive

            在網(wǎng)上搜索了一番,終于找到一篇文章介紹的解決方案:

            運(yùn)行Vs2008 SDK-〉Tools-〉Reset the Microsoft Visual Studio 2008 SP1 Experimental hive

            然后重新編譯就OK了。

            http://www.cnblogs.com/tubo/archive/2009/09/14/1566654.html

            posted @ 2012-04-26 11:13 呆人 閱讀(345) | 評(píng)論 (0)編輯 收藏

            在VS中 build 和rebuild的區(qū)別

            Build只編譯工程中上次修改過(guò)的文件,并鏈接程序生成可執(zhí)行文件。
            如果以前沒(méi)有作過(guò)編譯,它會(huì)自動(dòng)調(diào)用Rebuild操作,依次編譯資源文件、源程序文件等;
            Rebuild不管文件是否作過(guò)修改,都會(huì)編譯工程中的所有源文件。
            Visual Studio的智能性還不夠,它有時(shí)不能非常準(zhǔn)確地判斷出都有哪些文件需要重新編譯。
            于是,當(dāng)你Build時(shí),它僅僅把它認(rèn)為需要重新編譯的重新編譯一下,而有時(shí)候它的判斷實(shí)際是不夠的。
            但Rebuild就不同了,它把所有的東西都重新編譯,不管改過(guò)的,沒(méi)改過(guò)的;還是它認(rèn)為有依賴(lài)的,沒(méi)依賴(lài)的,統(tǒng)統(tǒng)重來(lái)。

            posted @ 2012-02-20 10:54 呆人 閱讀(1379) | 評(píng)論 (0)編輯 收藏

            用TortoiseGit第一次checkout

            首先安裝msysgit,然后安裝TortoiseGit。
            可以在程序中看到GitGUI和TortoiseGit。
            使用GitGUI進(jìn)行checkout。
            步驟為:
            1. 在電腦上create folder,命名為demo.
            2.選中demo。在菜單中選擇git clone.
            就可以checkout下來(lái)代碼。

            posted @ 2011-12-29 17:26 呆人 閱讀(2998) | 評(píng)論 (0)編輯 收藏

            sqlserver2008里面的游標(biāo)

             SQL是一種基于集合的語(yǔ)言(a set-based language) ,他更擅長(zhǎng)操作和提出一組數(shù)據(jù),而不是對(duì)
             數(shù)據(jù)進(jìn)行一行一行的處理。
             SQL is a set-based language ,meaning that is excels at mantipulating and retrieving
             set of rows ,rather than performing single row-by-row processing.
             如果你的程序里一定要一條一條的執(zhí)行,那么一定要先考慮使用如while循環(huán),子查詢(xún),
             臨時(shí)表,表變量等等,如果這些都不能滿足要求,在考慮使用游標(biāo)。
             
             T-SQL中游標(biāo)的生存周期:
             1.用返回一個(gè)有效結(jié)果集的sql語(yǔ)句來(lái)定義一個(gè)游標(biāo)。
              a cursor is defined via a SQL statement that returns a valid result set.
             2. 打開(kāi)游標(biāo)
             3. 一旦游標(biāo)被打開(kāi)就可以從游標(biāo)中每次取出一行數(shù)據(jù),要根據(jù)游標(biāo)的定義可以向前去數(shù)據(jù)或
             向后取數(shù)據(jù)
             the rows can be fetched moving forword or backword ,depending on the original cursor definition.
             4. 根據(jù)游標(biāo)的類(lèi)型,數(shù)據(jù)可以被修改或者只能讀。
             5.最后,用完游標(biāo)后,必須被顯示的關(guān)閉,并且從內(nèi)存中移除。
             
             游標(biāo)定義格式:
             declare cursor_name cursor
             [local|global]
             [forword_only|scroll]
             [static|keyset|dynamic|fast_forword]
             [read_only| scroll_locks|optimistic]
             [type_warning]
             for select_statement[for update [of column[,...]]]
             
            The select_statement argument is the query used to define the data within the cursor. Avoid
            using a query that hasmore columns and rows than will actually be used, because cursors, while
            open, are kept inmemory. The UPDATE [OF column_name [,...n]] is used to specify those columns
            that are allowed to be updated by the cursor.
             

            posted @ 2011-11-03 16:28 呆人 閱讀(1688) | 評(píng)論 (0)編輯 收藏

            sqlserver2008 條件循環(huán)

            條件處理:condtional processing
            1.case函數(shù)以一個(gè)表達(dá)式作為輸入,一個(gè)值作為輸出
            格式:case 后面有輸入表達(dá)式,when后面的的每一個(gè)表達(dá)式都會(huì)和case后面的輸入表達(dá)式進(jìn)行比較運(yùn)算
            如果相等,則返回,否則返回else后面的表達(dá)式,如果沒(méi)有else則返回NULL。
            case input_expression
                 when when_expression then result_expression
                 [...n]
                 [else else_result_expression]
            end

            case的第二種情況:
            case后面沒(méi)有表達(dá)式,when后面跟的是bool表達(dá)式。返回第一個(gè)when后面計(jì)算為true的表達(dá)式
            格式為:
            case
             when bool_expression then result_expression
             [...n]
             else result_expression
            end

            2. if....else...的格式
            if bool_expression
            {sql_statement|sql_block}
            [else
            {sql_statement|sql_block}
            ]

            3.begin ....end 相當(dāng)于c++中的{...}用來(lái)形成一個(gè)代碼塊

            4.條件循環(huán)
            return,while,goto,waitfor

            return
            return 用于結(jié)束當(dāng)前的sql塊,查詢(xún),存儲(chǔ)過(guò)程。
            類(lèi)似于c++中的return。
            return 可以返回一個(gè)數(shù)字

            while 類(lèi)似c++中的while,同樣支持break,continue,break來(lái)結(jié)束當(dāng)前內(nèi)層循環(huán),continue繼續(xù)當(dāng)前循環(huán)

            waitfor格式
            waitfor
             delay 'time_to_pass'//執(zhí)行前等待的時(shí)間:格式為00:00:00小時(shí):分鐘:秒
             |time 'time_to_execute'//設(shè)置實(shí)際執(zhí)行的時(shí)間
             |(receive_statement)[,TimeOUT timeout]
             可以利用waitfor將某些復(fù)雜的執(zhí)行設(shè)定為在相對(duì)空閑的時(shí)間內(nèi)進(jìn)行。

            posted @ 2011-11-03 16:27 呆人 閱讀(1942) | 評(píng)論 (0)編輯 收藏

            printf 輸出int64

            __int64 long a=10;
            printf("%i64u",a);

            posted @ 2011-11-01 14:29 呆人 閱讀(458) | 評(píng)論 (0)編輯 收藏

            sqlserver2008中數(shù)據(jù)類(lèi)型的優(yōu)先級(jí)

            當(dāng)兩個(gè)不同數(shù)據(jù)類(lèi)型的表達(dá)式用運(yùn)算符組合后,數(shù)據(jù)類(lèi)型優(yōu)先級(jí)規(guī)則指定將優(yōu)先級(jí)較低的數(shù)據(jù)類(lèi)型轉(zhuǎn)換為優(yōu)先級(jí)較高的數(shù)據(jù)類(lèi)型。如果此轉(zhuǎn)換不是所支持的隱式轉(zhuǎn)換,則返回錯(cuò)誤。當(dāng)兩個(gè)操作數(shù)表達(dá)式具有相同的數(shù)據(jù)類(lèi)型時(shí),運(yùn)算的結(jié)果便為該數(shù)據(jù)類(lèi)型。

            SQL Server 對(duì)數(shù)據(jù)類(lèi)型使用以下優(yōu)先級(jí)順序:

            1. 用戶(hù)定義數(shù)據(jù)類(lèi)型(最高)

            2. sql_variant

            3. xml

            4. datetimeoffset

            5. datetime2

            6. datetime

            7. smalldatetime

            8. date

            9. time

            10. float

            11. real

            12. decimal

            13. money

            14. smallmoney

            15. bigint

            16. int

            17. smallint

            18. tinyint

            19. bit

            20. ntext

            21. text

            22. image

            23. timestamp

            24. uniqueidentifier

            25. nvarchar(包括 nvarchar(max)

            26. nchar

            27. varchar(包括 varchar(max)

            28. char

            29. varbinary(包括 varbinary(max)

            30. binary(最低)

            posted @ 2011-10-31 11:25 呆人 閱讀(426) | 評(píng)論 (0)編輯 收藏

            一種類(lèi)型的字符拷貝函數(shù)

            1.函數(shù)原型:
            LPTSTR lstrcpyn(     

                LPTSTR lpString1,
                LPCTSTR lpString2,//指向一個(gè)以NULL結(jié)束的字符串
                int iMaxLength   //從lpString2拷貝到lpString1的字符串個(gè)數(shù),包括NULL字符
            );
            成功返回指向lpString1的指針,否則返回NULL。

            如果lpString2的長(zhǎng)度大于iMaxLength,該方法實(shí)際上是將lpString2中的前iMaxLength-1個(gè)字符一個(gè)NULL字符拷貝到lpString1中。
            如果該方法成功,則lpString1一定是以NULL結(jié)束的字符串。

            2._tcsncpy是一個(gè)宏,考慮在unicode的情況下
            define _tcsncpy wcsncpy

            wchar_t *wcsncpy(
               wchar_t *strDest,
               const wchar_t *strSource,
               size_t count
            );

            Parameters
            strDest

            Destination string.

            strSource

            Source string.

            count

            Number of characters to be copied.

            Return Value

            Returns strDest. No return value is reserved to indicate an error.
            不能保證NULL結(jié)束,將count個(gè)字符拷貝到strDest中。




            posted @ 2011-08-10 14:02 呆人 閱讀(417) | 評(píng)論 (0)編輯 收藏

            重載標(biāo)準(zhǔn)輸出符號(hào)operator<<

            CString是我自己定義的一個(gè)類(lèi)
            為了實(shí)現(xiàn):
            CString str("123abvc");
            cout<<str<<endl;


            聲明:
             ostream& operator<<(ostream& os,const CString& str);
            實(shí)現(xiàn):

            ostream& operator<<(ostream& os,const CString& str)
            {
             long multiBytes = WideCharToMultiByte(CP_ACP,0,str._pData,-1,NULL,0,NULL,NULL);//獲得將寬字節(jié)轉(zhuǎn)換成多自己時(shí),所需要的字節(jié)個(gè)數(shù),注意藍(lán)色部分
             char *lpMultiBytes = new char[multiBytes+10];//分配多字節(jié)時(shí)所需要的內(nèi)存
             memset(lpMultiBytes,0,multiBytes+10);

             WideCharToMultiByte(CP_ACP,0,str._pData,-1,lpMultiBytes,multiBytes+10,NULL,NULL);//調(diào)用win32api函數(shù)將寬字節(jié)的表示轉(zhuǎn)換成為多字節(jié)的表示,注意藍(lán)色部分

             os<<lpMultiBytes;

             return os;//注意返回值
            }

            posted @ 2011-08-10 13:43 呆人 閱讀(524) | 評(píng)論 (0)編輯 收藏

            僅列出標(biāo)題
            共6頁(yè): 1 2 3 4 5 6 
            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(1)

            隨筆分類(lèi)

            隨筆檔案

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久精品免费观看| 天天久久狠狠色综合| 情人伊人久久综合亚洲| 亚洲va久久久噜噜噜久久狠狠| 亚洲国产日韩综合久久精品| 四虎国产精品免费久久久| 久久精品国产99国产精偷| 久久国产精品视频| 精品久久久久一区二区三区 | 成人久久综合网| 久久午夜福利电影| 三上悠亚久久精品| 久久国产成人午夜aⅴ影院| 久久久WWW成人免费精品| 亚洲第一极品精品无码久久| 久久青青草原精品影院| 国产亚洲精久久久久久无码77777| 97热久久免费频精品99| 久久婷婷国产剧情内射白浆 | 久久综合狠狠综合久久| 国内精品伊人久久久久网站| 人妻精品久久久久中文字幕69| 国产亚州精品女人久久久久久 | 欧美亚洲国产精品久久| 精品999久久久久久中文字幕| 中文字幕精品无码久久久久久3D日动漫 | 久久精品一区二区三区中文字幕 | 中文字幕久久精品| 精品久久人人做人人爽综合| 久久精品国产亚洲精品2020| 久久久国产99久久国产一| 老司机午夜网站国内精品久久久久久久久| 国产99精品久久| 久久久一本精品99久久精品88| 久久久一本精品99久久精品88| 亚洲&#228;v永久无码精品天堂久久| 久久青青草原国产精品免费 | 久久精品国产乱子伦| 亚洲精品成人网久久久久久| 婷婷久久综合九色综合九七| 99久久免费只有精品国产|