Boost logo

Boost Users :

Subject: Re: [Boost-users] whitebox testing with boost unit test framework?
From: Richard (legalize+jeeves_at_[hidden])
Date: 2011-12-22 18:25:05


[Please do not mail me a copy of your followup]

boost-users_at_[hidden] spake the secret code
<CAABBKK=ufLL2oABCinGZwfzrKVFJ8UOXtjEXQ+1N5zhiAXs4cg_at_[hidden]> thusly:

>I have found this to cause unnecessary methods having to be virtualized in
>order to replace concrete objects with test objects in a class being
>tested, which ended up getting quite messy at times, so I essentially had
>to settle for the "friend" solution.

In C++ you can either use static polymorphism or dynamic polymorphism
to get substitutability of test doubles for real collaborators. I've
done both, depending on the situation.

If I had to choose between which I like least: virtual functions or
"friend", I choose friend. I generally consider "friend" declarations
a code smell that indicates poor class design.

-- 
"The Direct3D Graphics Pipeline" -- DirectX 9 version available for download
 <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
      Legalize Adulthood! <http://legalizeadulthood.wordpress.com>

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