GoogleMock发出用Eclipse构建C 的简单代码
GoogleMock issue building C++ simple code with Eclipse
in mobiletest.h我有:
#include <gtest/gtest.h>
#include <gmock/gmock.h>
using ::testing::Return;
#include "Mobile.h"
class MockedCamera : public Camera {
public:
MOCK_METHOD0(ON, bool());
MOCK_METHOD0(OFF,bool());
};
Mobile.h代码:
#ifndef __MOBILE_H__
#define __MOBILE_H__
#include <iostream>
using namespace std;
#include "Camera.h"
class Mobile {
private:
Camera *pCamera;
public:
Mobile();
Mobile(Camera *pCamera);
bool powerOn();
bool powerOff();
virtual ~Mobile(){};
};
#endif /* __MOBILE_H__ */
camera.h头文件
#ifndef __CAMERA_H__
#define __CAMERA_H__
#include <iostream>
using namespace std;
class Camera {
public:
Camera();
virtual bool ON();
virtual bool OFF();
virtual ~Camera(){};
};
#endif /* __CAMERA_H__ */
这是Udemy C 课程的简单代码,但是使用Eclipse构建时会给我错误,没有移动测试。
Symbol 'ArgumentCount' could not be resolved
The type 'testing::internal::FunctionMocker' must implement the inherited pure virtual method 'testing::internal::UntypedFunctionMockerBase::UntypedPerformAction'
这是项目的制作费,当我尝试使用make命令时,它给了我很多错误的GTEST:
SRC = $(wildcard src/*.cpp test/*.cpp)
OBJS = $(SRC:.cpp=.o)
CXXFLAGS = -std=c++14
LIBS = -pthread libgtest.a
INC = -I googletest/googletest
-I googletest/googletest/include
-I googlemock/googlemock
-I googlemock/googlemock/include
-I src
-I test
EXE = mobileTest.exe
all: $(OBJS)
cp -f $(OBJS) .
g++-7 -o $(EXE) $(CXXFLAGS) $(OBJS) $(LIBS) $(INC)
rm -f $(OBJS)
%.o: %.cpp
g++-7 -c $(CXXFLAGS) $(INC) $< -o $@
.PHONY: clean
clean:
rm -f *.o *.exe
建议?
我将gtest和gmock用作库。
GTEST库的项目文件包含以下源文件
SOURCES += ../googletest/src/gtest.cc
../googletest/src/gtest-death-test.cc
../googletest/src/gtest-filepath.cc
../googletest/src/gtest-port.cc
../googletest/src/gtest-printers.cc
../googletest/src/gtest-test-part.cc
../googletest/src/gtest-typed-test.cc
gmock库的项目文件包含以下源文件
SOURCES += ../googlemock/src/gmock-cardinalities.cc
../googlemock/src/gmock-internal-utils.cc
../googlemock/src/gmock-matchers.cc
../googlemock/src/gmock-spec-builders.cc
../googlemock/src/gmock.cc
相关文章:
- boost::spirit--试图编译大多数简单代码的编译器错误
- 奇怪的 G++ 错误,带有关于左值和赋值的简单代码
- 为什么 for 循环只接受这个简单代码中的最后一个字符串?
- SFML C 为什么在屏幕上没有绘制?(简单代码)
- GoogleMock发出用Eclipse构建C 的简单代码
- 为什么我的简单代码在C++中不起作用?
- PQXX简单代码崩溃了
- 此简单代码的正统代码
- 我在C++文件中的简单代码块上有 2 个错误。错误 C2059:语法错误:"?"。第二智能感知:预期表达式。怎么了?
- 用谷歌基准测试简单代码的问题
- 简单代码给出C 错误C4430和C2143
- 这个带有向量的简单代码有什么问题?
- 优化项目Euler 16的简单代码
- 如何重写此 C++ 简单代码
- 是否有Visual c++编译器在线,以及如何在c++和vs简单代码之间转换
- 简单代码问题-未定义标识符
- OpenCV简单代码编译成功,但在运行时崩溃
- 如何在另一个类中构造一个类?(简单代码)
- 验证给定C++编译器是否将源代码读取为 C++11 的快速简单代码是什么?
- 带有类的 C++ 简单代码