はじめに
概要
- 公開用ヘッダファイルとソースファイル、テストファイルのディレクトリを分離する
- テストにGoogleTestを使用する
動作環境
- Ubuntu18.04(NativeあるいはWSL)
ディレクトリ構成
Directory | Note |
---|---|
include/${PROJECT_NAME} | 公開ヘッダファイル |
src | ソースコード, 非公開ヘッダファイル |
test | テスト記述 |
GoogleTestのインストール
- release-1.10.0を~/local/gtest-1.10.0にインストール
git clone https://github.com/google/googletest.git -b release-1.10.0 --depth=1 cd googletest mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/local/gtest-1.10.0 .. make -j 8 install
プロジェクトのビルドと実行
git clone https://github.com/taksei/googletest_sample.git cd googletest_sample mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_TEST=ON make -j 8 # Run all tests make test # Run specified test ./test/test_sample