-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
The "Sample usage of class mocking" example on the wiki fails, with the error "Function called without expectation!".
Is it possible to mock some methods of a class and leave the rest untouched? If not, the wiki needs to updated.
Here's the code I used:
class CFoo {
public:
bool Func1() {
bool ret = false;
if (Func2()) {
//do something
ret = true;
}
else {
//do something else
}
return ret;
}
bool Func2() {
return true;
}
};
TEST_CASE("Hippomocks example", "[sanity]") {
MockRepository mocks;
CFoo* pFoo = mocks.Mock<CFoo>();
mocks.ExpectCall(pFoo, CFoo::Func2).Return(true);
REQUIRE(pFoo->Func1() == true);
mocks.ExpectCall(pFoo, CFoo::Func2).Return(false);
REQUIRE(pFoo->Func1() == false);
}
Metadata
Metadata
Assignees
Labels
No labels