In MobileTest.hi have:
#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 code:
#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 header file
#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__ */
This is a simple code of Udemy C++ Course but when building with eclipse it gives me errors no mobile test.h MOCK_METHOD0 macro call:
Symbol 'ArgumentCount' could not be resolved
The type 'testing::internal::FunctionMocker' must implement the inherited pure virtual method 'testing::internal::UntypedFunctionMockerBase::UntypedPerformAction'
This is the makefile of the project and it gives me lots of error gtest related when i try to use make command:
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
Suggestions?
I use gtest and gmock as library.
The project file of gtest library contains the following source files
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
The project file of gmock library contains the following source files
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.