Hi cheol,
One way to do it is to define a mock class:
class MockKernel : public Kernel {
public:
// constructor etc.
MOCK_METHOD0(getsynch, int());
};
then use an instance of the MockKernel instead of the real Kernel. You
can create an instance of the MockKernel in your test case and set
expectations and return values as needed:
TEST(Test, Case) {
MockKernel mock_kernel;
EXPECT_CALL(mock_kernel, getsynch).WillOnce(Return(0));
EXPECT_CALL(mycode.loadsynch());
// mycode must use the mock kernel instance:
mycode.set_kernel(mock_kernel);
// execute code under test:
mycode.loadsynch();
}
hope this helps, Pavol
In addition, you would probably want to delegate to the real object
for the remaining methods (if you needed to and if you want to verify
the possible side-effects of the calls to Kernel's methods).
http://code.google.com/p/googlemock/wiki/CookBook#Delegating_Calls_to_a_Real_Object
--
Chris
chrish...@gmail.com
+65 9755 3292 (1 more week to Singapore!)
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?