• <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

            2013年2月6日

            first demo for gtest

            1.  首先給出第一個運用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;
            }



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

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

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

            2012年4月26日

            Failed to retrieve paths under VSTemplate for the specified registry hive[轉載]

            最近更換開發機的環境,從Windows XP換到Windows 7,結果以前在XP下的一個VS2008的一個插件項目在新環境中編譯老是出錯:

            AnswerFailed to retrieve paths under VSTemplate for the specified registry hive

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

            運行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 呆人 閱讀(340) | 評論 (0)編輯 收藏

            2012年2月20日

            在VS中 build 和rebuild的區別

            Build只編譯工程中上次修改過的文件,并鏈接程序生成可執行文件。
            如果以前沒有作過編譯,它會自動調用Rebuild操作,依次編譯資源文件、源程序文件等;
            Rebuild不管文件是否作過修改,都會編譯工程中的所有源文件。
            Visual Studio的智能性還不夠,它有時不能非常準確地判斷出都有哪些文件需要重新編譯。
            于是,當你Build時,它僅僅把它認為需要重新編譯的重新編譯一下,而有時候它的判斷實際是不夠的。
            但Rebuild就不同了,它把所有的東西都重新編譯,不管改過的,沒改過的;還是它認為有依賴的,沒依賴的,統統重來。

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

            2011年12月29日

            用TortoiseGit第一次checkout

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

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

            2011年11月3日

            sqlserver2008里面的游標

             SQL是一種基于集合的語言(a set-based language) ,他更擅長操作和提出一組數據,而不是對
             數據進行一行一行的處理。
             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.
             如果你的程序里一定要一條一條的執行,那么一定要先考慮使用如while循環,子查詢,
             臨時表,表變量等等,如果這些都不能滿足要求,在考慮使用游標。
             
             T-SQL中游標的生存周期:
             1.用返回一個有效結果集的sql語句來定義一個游標。
              a cursor is defined via a SQL statement that returns a valid result set.
             2. 打開游標
             3. 一旦游標被打開就可以從游標中每次取出一行數據,要根據游標的定義可以向前去數據或
             向后取數據
             the rows can be fetched moving forword or backword ,depending on the original cursor definition.
             4. 根據游標的類型,數據可以被修改或者只能讀。
             5.最后,用完游標后,必須被顯示的關閉,并且從內存中移除。
             
             游標定義格式:
             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 呆人 閱讀(1686) | 評論 (0)編輯 收藏

            sqlserver2008 條件循環

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

            case的第二種情況:
            case后面沒有表達式,when后面跟的是bool表達式。返回第一個when后面計算為true的表達式
            格式為:
            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 相當于c++中的{...}用來形成一個代碼塊

            4.條件循環
            return,while,goto,waitfor

            return
            return 用于結束當前的sql塊,查詢,存儲過程。
            類似于c++中的return。
            return 可以返回一個數字

            while 類似c++中的while,同樣支持break,continue,break來結束當前內層循環,continue繼續當前循環

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

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

            2011年11月1日

            printf 輸出int64

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

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

            2011年10月31日

            sqlserver2008中數據類型的優先級

            當兩個不同數據類型的表達式用運算符組合后,數據類型優先級規則指定將優先級較低的數據類型轉換為優先級較高的數據類型。如果此轉換不是所支持的隱式轉換,則返回錯誤。當兩個操作數表達式具有相同的數據類型時,運算的結果便為該數據類型。

            SQL Server 對數據類型使用以下優先級順序:

            1. 用戶定義數據類型(最高)

            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 呆人 閱讀(423) | 評論 (0)編輯 收藏

            2011年8月10日

            一種類型的字符拷貝函數

            1.函數原型:
            LPTSTR lstrcpyn(     

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

            如果lpString2的長度大于iMaxLength,該方法實際上是將lpString2中的前iMaxLength-1個字符一個NULL字符拷貝到lpString1中。
            如果該方法成功,則lpString1一定是以NULL結束的字符串。

            2._tcsncpy是一個宏,考慮在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結束,將count個字符拷貝到strDest中。




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

            重載標準輸出符號operator<<

            CString是我自己定義的一個類
            為了實現:
            CString str("123abvc");
            cout<<str<<endl;


            聲明:
             ostream& operator<<(ostream& os,const CString& str);
            實現:

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

             WideCharToMultiByte(CP_ACP,0,str._pData,-1,lpMultiBytes,multiBytes+10,NULL,NULL);//調用win32api函數將寬字節的表示轉換成為多字節的表示,注意藍色部分

             os<<lpMultiBytes;

             return os;//注意返回值
            }

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

            僅列出標題  下一頁
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            導航

            統計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久亚洲av无码专区导航 | 久久中文字幕人妻熟av女| 久久久WWW成人免费精品| 久久这里都是精品| 99久久精品国产麻豆| 久久精品二区| 国产成人久久精品激情| 欧美午夜A∨大片久久| 久久99国产精品尤物| 久久久受www免费人成| 97精品伊人久久大香线蕉app | 亚洲欧美日韩中文久久| 久久国产色AV免费观看| 久久人妻少妇嫩草AV无码蜜桃| 久久亚洲精品中文字幕| 久久久久九国产精品| 久久综合狠狠综合久久激情 | 久久精品成人欧美大片| 久久青青草原精品国产软件 | 中文字幕精品久久久久人妻| 91精品国产综合久久婷婷| 97精品依人久久久大香线蕉97| 国产午夜精品理论片久久| 91精品国产色综合久久| 亚洲国产精品无码久久SM| 伊人久久大香线蕉综合网站| 精品无码久久久久久国产| 91精品国产高清久久久久久91 | 午夜精品久久影院蜜桃| 国产ww久久久久久久久久| 精品国产一区二区三区久久| 97久久久精品综合88久久| 久久久久高潮毛片免费全部播放 | 国产成人精品综合久久久| 色综合久久天天综合| 国产情侣久久久久aⅴ免费| 久久精品毛片免费观看| 久久男人Av资源网站无码软件 | 欧美粉嫩小泬久久久久久久 | 一本色道久久综合狠狠躁篇| 一本大道久久香蕉成人网|