發表文章

目前顯示的是 7月, 2013的文章

使用 googletest & googlemock 做單元測試

svn checkout http://googlemock.googlecode.com/svn/trunk/ (已包含 googletest) 將來可以直接用 svn update 為了方便將這兩個 Framework 加入測試專案,將輸出目錄由 SolutionName 改為 SolutionDir ,避免附加到不同的 Solution 時造成名稱不一致 (後來發現一般  Project 都是用 SolutionDir,唯獨這兩個 Project 使用 SolutionName,怪哉!) 開啟 googlemock\gtest\msvc\gtest-md.sln,點選 gtest-md 的 Properties,選擇 All Configurations,將 General | Output Directory 由 $(SolutionName)/$(ConfigurationName) 改為  $(SolutionDir)/$(ConfigurationName) 開啟 googlemock\msvc\2005\gmock.sln 點選 gmock 的 Properties,選擇 All Configurations,將 General | Output Directory 由 $(SolutionName)/$(ConfigurationName) 改為  $(SolutionDir)/$(ConfigurationName) 選擇 Debug Configuration,將 C/C++ | Code Generation | Runtime Library 由 Multi-threaded Debug (/MTd) 改為 Multi-threaded Debug DLL (/MDd) 選擇 Release Configuration,將 C/C++ | Code Generation | Runtime Library 由 Multi-threaded (/MT) 改為 Multi-threaded DLL (/MD) 以上動作設定一次即可 PS : 如果 Project Runtime Library  使用 Multi-threaded (Debug) DLL,則 MFC 必須使用 Shared DLL;反之若使

scanf 兩三事

圖片
記得以前寫程式的時候,scanf 是很常用到的輸入功能。但寫 Windows 程式後就很少碰到它了,直到之前發生了一些靈異現像,才重新勾起對它的回憶。首先看看以下的程式碼吧 int _tmain(int argc, _TCHAR* argv[]) { short int i=0, j=0; _tprintf(_T("Please input number : ")); _tscanf_s(_T(" %d "),&i); _tprintf(_T("i = %d, j = %d\n"), i, j); return 0; }

[已解決] Static Library Project 的 MFC 不支援 template

最近為了用 Unit Test 而將一些程式碼放在 Static Library Project 中,但在使用 CArray template 時卻出現 Compiler error C2976: 'CArray' : too few template arguments 經比對一般的 MFC Project 才發現 stdafx.h 未加入 #include <afxtempl.h> 加入後就一切正常了 Test project 也要加入,而且設定使用 Shared DLL MFC 才能正常測試