![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
gtest/gmock
文章平均质量分 58
kouei_memo
这个作者很懒,什么都没留下…
展开
-
<gtest/gmock> 编译时如何把private属性变成public?
本文转载自: https://blog.csdn.net/qq910894904/article/details/38583593 在做一些已经写好的代码的单元测试的时候,有时候需要使用到类私有的成员方法或变量。我们不想改动原来的代码,但是又能访问这些私有或者受保护的方法,遇到这种情况怎么办? 1.手工替换 在原有代码中将private手工替换成public,将protected手工替换成public. 这种方法是我们最不想用的方法,因为这需要改变原来的代码。 2.宏替换 这种方法比较讨巧,但也很好用,我们转载 2021-04-12 16:44:42 · 1266 阅读 · 0 评论 -
<gtest/gmock> 一个例子gtest
func.h #ifndef FUNC_C #define FUNC_C #ifdef __cplusplus extern "C" { #endif int fac(int nInput); #ifdef __cplusplus } #endif #endif // FUNC_C ```\ func.c ```c #include "func.h" int fac(int nInput) { if(nInput < 0) { return -1; } in转载 2021-04-12 16:25:23 · 165 阅读 · 0 评论 -
<gtest/gmock> 编译安装
1 下载 从官网https://github.com/google/googletest/releases 下载,如googletest-1.10.x.zip 2 解压到一个目录 unzip googletest-1.10.x.zip 3 创建编译目录 mkdir googletest-1.10.x_building 4 创建安装目录 mkdir googletest-1.10.x_build 5 进入编译目录 cd googletest-1.10.x_building cmake …/googletest原创 2021-04-11 23:17:48 · 339 阅读 · 0 评论