I'm trying to get a working googletest test that compares two vectors. For this I'm using google mock with its matchers but I get a C3861 error saying "ContainerEq identifier not found" and also C2512 saying "testing::AssertionResult has not a proper default constructor available". Why?
TEST(MyTestSuite, MyTest)
{
std::vector<int> test1;
std::vector<int> test2;
...
EXPECT_THAT(test1, ContainerEq(test2));
}
EXPECT_CALL not only defines the behavior, but also sets an expectation that the method will be called with the given arguments, for the given number of times (and in the given order when you specify the order too).
A matcher matches a single argument. You can use it inside ON_CALL() or EXPECT_CALL() , or use it to validate a value directly using two macros: Macro.
You must always put a mock method definition ( MOCK_METHOD ) in a public: section of the mock class, regardless of the method being mocked being public , protected , or private in the base class.
gMock is a library (sometimes we also call it a “framework” to make it sound cool) for creating mock classes and using them. It does to C++ what jMock/EasyMock does to Java (well, more or less).
You're just missing gtest's testing
namespace qualifier:
EXPECT_THAT(test1, ::testing::ContainerEq(test2));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With