我正在尝试在我的cpp单元测试用例中模拟第三方API调用。为此,我使用VS2013中的Nuget pakage manager在我的项目中安装了gmock 1.7.0。它在我的测试项目中添加了gmock-all.cc和gtest-all.cc。一旦我遵守它是好的。只要我添加#include" gmock \ gmock.h"在我的cppunit测试用例中,它给了我以下错误 -
2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(893):错误C2065:' lhs&# 39; :未声明的标识符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(893):错误C2988:无法识别的模板声明/定义 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(893):error C2059:语法错误:' const&# 39; 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(901):错误C2143:语法错误:缺少&#39 ;; '之前' {' 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(901):错误C2447:' {' :缺少函数头(旧式正式列表?) 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(933):错误C2065:'来自' :未声明的标识符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(933):错误C2065:' L' :未声明的标识符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(933):错误C2065:'到' :未声明的标识符 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):错误C2182:' CopyArray' :非法使用类型' void' 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):错误C2433:' CopyArray' :'内联'数据声明不允许 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):错误C2365:' testing :: internal: :CopyArray' :重新定义;以前的定义是'功能' 2> c:\ tfs2013 \ main \ source \ packages \ gmock.1.7.0 \ lib \ native \ include \ gtest \ internal \ gtest-internal.h(935):错误C2998:' int testing :: internal :: CopyArray' :不能是模板定义
你能帮我摆脱这个吗?
答案 0 :(得分:0)
我正在使用cpprest和gmock。两者都存在冲突,因为它会产生这些错误。要摆脱这种情况,我们需要包含_TURN_OFF_PLATFORM_STRING预处理器指令。
有关详细信息,您可以按照以下讨论进行操作 Issue with CPP Rest and gmock