googletest 简单例子
https://github.com/bast/gtest-demo.git
环境搭建
- demo文件目录
[sxy@DESKTOP-SXY gtest-demo_new]$ tree
.
└── gtest-demo
├── cmake #测试环境构建
│ ├── googletest.cmake
│ └── googletest-download.cmake
├── CMakeLists.txt
├── LICENSE
├── README.md
├── src #待测试的模块
│ ├── CMakeLists.txt
│ ├── example.cpp
│ └── example.h
└── test #测试代码
├── CMakeLists.txt
├── example_add.cpp
├── example_subtract.cpp
└── main.cpp
- cmake理解
- GNUInstallDirs:gnu安装目录
- include:获取某一文件中的cmake代码
- macro(<name> [arg1 [arg2 [arg3 ...]]]):定义一个宏,后面是宏名和参数
- configure_file:复制input文件中的内容到output,复制过程中替换某些值
- execute_process:执行进程,指定WORKING_DIRECTORY后在该子目录下执行命令
- add_library
更改demo的目录结构
root_dir
- lib
- sublib0
- sublib2
- src
- test_module
- application
- doc
- gtest_demo
- build
- scripts to build application
- scripts to all