I am trying to learn google test framework, and I came across an example here. I have something similar to "accepted solution", but I wanted to test it while having class methods as protected.
class GTEST_static_class {
protected:
virtual void display() { std::cout << "inside the GTEST_static_class:: display\n"; }
virtual ~GTEST_static_class() {}
};
class GTest_static_example : public ::testing::Test {
public:
void call_display(GTEST_static_class *instance) {
instance->display();
std::cout << "display called from GTest_static_example\n";
}
};
How do I modify that piece of code (accepted solution) to make it work while having class like mentioned above?
CodePudding user response:
Add a friend class GTest_static_example
:
class GTEST_static_class {
protected:
virtual void display() { std::cout << "inside the GTEST_static_class:: display\n"; }
virtual ~GTEST_static_class() {}
friend class GTest_static_example;
};