
On Thu, Dec 22, 2011 at 3:05 PM, Mathias Gaunard
On 12/22/2011 12:25 AM, Chris Cleeland wrote:
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.
Thoughts/suggestions?
There are tricks to access private/protected members of a class without being a friend or anything like that.
http://bloglitb.blogspot.com/2010/07/access-to-private-members-thats-easy.ht...
Maybe that would be useful to you (haven't found a use for that yet)
That's a nifty, though convoluted, trick! So far nothing I've tried has been as straightforward as #define private public I do like the idea proposed in one of the comments on that blog where somebody suggested having a public_cast<> operator to cast away protections. -- Chris Cleeland