[Cppunit-devel] equality of const objects
Brought to you by:
blep
|
From: Steve M. R. <ste...@vi...> - 2001-09-25 14:33:15
|
On Tue, Sep 25, 2001 at 02:56:55PM +0200, Baptiste Lepilleur wrote:
> I'm not saying to change CppUnit as a whole. The only thing I want
> to change is those part of CppUnit that would impose on the
> "user" policy:
>
> struct assertion_traits
> {
> static bool equal( const T& x, const T& y )
> => change to
> static bool equal( T& x, T& y )
>
> and
> template <class T>
> void assertEquals( const T& expected,
> const T& actual,
> => change to:
> template <class T>
> void assertEquals( T& expected,
> T& actual,
>
> The change is invisible for user that apply the "const" policy, and allow
> user who don't to use the assertEquals without having to do const_cast.
Sorry Baptiste, I do not understand. Why do you say that using const
references makes writing equal() black magic? Can you give us a short
example of a class that is problematic for equal(const&,const&)?
I'm worried about making the change you propose. I use const a lot,
and I'm sure that I have CppUnit tests in functions that are
passed const references:
foo( const T& x )
{
T y(blahblah);
CPPUNIT_ASSERT_EQUAL(x,y);
}
I think your proposed change would break my code, wouldn't it?
Thanks,
-Steve
--
by Rocket to the Moon,
by Airplane to the Rocket,
by Taxi to the Airport,
by Frontdoor to the Taxi,
by throwing back the blanket and laying down the legs ...
- They Might Be Giants
|