原创 Accessing static Data and Functions in Legacy C

http://www.renaissancesoftware.net/blog/archives/430 http://www.renaissancesoftware.net/blog/archives/450 It’s a new

原创 C++實現設計模式:Builder Pattern

注:爲了更清楚的解釋,類的成員函數均採用inline。 #ifndef _BUILDER_H #define _BUILDER_H #include "Product.h" #include <iostream> using

原创 2 new improvements of cpputest updated from 3.4 to 3.5

1. 提供了更加清晰合理的函數名: 2. 修復了一個3.4版本存在的bug: 概述:引用一下頭文件可以使得UT檢測是否有資源泄露:#include "CppUTest/MemoryLeakDetectorNewMacros.

原创 How to write the better Makefile for cpputest

最近給其他幾個團隊培訓UT工具cpputest。自己沒有寫PPT,而是從網上找了一份比較不錯的CppUTest課件,這份課件來自於一家叫Odd-e的敏捷諮詢公司。 裏面的內容比較基礎,也很清晰,非常適合幫助初學者較快的入門。 由於我

原创 C++實現設計模式:Observer Pattern

This example demonstrates creating three separate observer classes and subscribes them for different combinations of th

原创 關於sizeof的誤用問題

編程練習寫選擇排序算法的時候,居然把sizeof函數使用錯了,感覺還是有必要在這裏寫博客記錄一下自己犯的這個低級錯誤,以警示自己編碼: 下面是具體代碼: #include <iostream> #define CountOfArray(

原创 C++實現設計模式:Decorator Pattern

有時我們希望給某個對象而不是整個類添加一些功能。例如,一個圖形用戶界面工具箱允許你對任意一個用戶界面組件添加一些特性,例如邊框,或是一些行爲,例如窗口滾動。(GoF) 下面請看示例程序: #ifndef _COMPONENT_H

原创 How to mock the function with output parameter by cppumock?

Question: How to mock the function with output parameter with cppumock? My solution is through one global parameter to

原创 C++實現設計模式:Bridge Pattern

注:爲了簡要說明,類的成員函數均採用inline。 #ifndef _DRIVE_GAME_H_ #define _DRIVE_GAME_H_ #include "DriveGameImpl.h" #include <iost

原创 人人都來寫算法 之 移除字符串中重複的字符,時間複雜度要求O(n),空間複雜度O(1)

移除字符串中重複的字符,不能使用額外的緩存空間。字符串支持所有的ASCII碼字符。 注意:  時間複雜度要求O(n),空間複雜度O(1),可以使用額外的一個或幾個變量,但不允許額外再開一個數組拷貝。 分析: 1. 時間複雜度爲O(n)

原创 String class by C++

I spend three hours for this class today. It is a very interesting to consider the detail  about how to make it more e

原创 C++實現設計模式: PIMPL IDIOM

I learned this from the book Professional C++. And code this example to deepen the this practical pattern. The whole de

原创 RobotFramework: 設置Case執行的搜索路徑

在寫Robot Framework 的Case時,我們一般採用的都是相對路徑引用我們的lib以及其他資源文件,因此需要給Robot添加一個搜索路徑,但是採用命令行和RIDE還有一些差別。 這裏舉例簡單說明一下。 例如: Impor

原创 C++實現設計模式: An extensible Factory Pattern example

I have read the book Api Design For C++recently , and I must say that it is a masterpiece. There is a section to introd

原创 利用Shell腳本清除UT編譯的臨時文件

使用Cpputest編寫單元測試,會產生一些臨時文件,在Makefile中清除有的時候也有一些不太方便的地方,爲了解決這個問題,可以寫一個Shell腳本程序清除,在make之前清除UT的臨時文件或者build UT.(這個方法也是從同事