Boost logo

Boost Users :

Subject: Re: [Boost-users] [Test] How to Access Private Data from a Test
From: Merrill Cornish (merrill.cornish_at_[hidden])
Date: 2015-06-25 17:02:10


On 6/25/2015 3:52 PM, Jürgen Hunold wrote:
> In my opinion, a test should never access private data. But there are times
> and legacy code where I had no other choice, too.
The classes I am testing use the PIMPL idiom. Therefore, at a bare
minimum, the tests have to access the private pointer in the public
class that points to the accompanying private class. Since all of the
class's data is inside the private class, it make it extremely difficult
to write unit tests that determine if the class state is correct. I
see no value in the purist notion that I should have to jump through
hundreds of hoops deducing the internal state /just/ so I can say my
test never accessed any private data.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net