I'm using the BoostTest Framework (version 1.57.0) with Turtle as mock libary (version 1.3.0). I'm able to access public and private functions in a test case, but I can't access protected functions. I'm able to mock these protected functions with MOCK_BASE_CLASS from Turtle. Example:
RealClass.hpp
class RealClass
{
public:
void publicFunction();
protected:
void protectedFunction();
private:
void privateFunction();
};
RealClass_UnitTest.hpp
BOOST_AUTO_TEST_SUITE( RealClass_UnitTest );
BOOST_AUTO_TEST_CASE( RealClass_publicFunction)
{
RealClass RealObject;
RealObject.publicFunction() // Can be accessed and tested
}
BOOST_AUTO_TEST_CASE( RealClass_protectedFunction)
{
RealClass RealObject;
RealObject.protectedFunction() // Error: realClass::protectedFunction() is protected
}
BOOST_AUTO_TEST_CASE( RealClass_privateFunction)
{
RealClass RealObject;
RealObject.privateFunction() // Can be accessed and tested
}
BOOST_AUTO_TEST_SUITE_END();
I don't understand why I can access RealObject.privateFunction(), but not RealObject.protectedFunction().
I didn't setup the testing framework, but I can't find any place where BoostTest is allowed to access private members.