
Chris Cleeland
I'm using the boost unit test framework to implement unit tests for code. I'm wondering if there is a best-practice for doing white-box testing/internal state inspection of types under test. My hack right now is to strip out "protected" and "private" from the header, but I hold my nose as I do that.
I don't use private members in the header file and put a subclass in the test implementation that makes the parent class' protected API public. So you get, in the header, something like: class A { public: // protected: int i; }; and then in the test implementation file #include "A.hpp" class A_test : A { public: using i; }; so that in the tests you can access i without any problem. Hope this helps, -- Olaf Meeuwissen, LPIC-2 FLOSS Engineer -- AVASYS CORPORATION FSF Associate Member #1962 Help support software freedom http://www.fsf.org/jf?referrer=1962