Re: [Cppunit-devel] equality of const objects
Brought to you by:
blep
From: Baptiste L. <gai...@fr...> - 2001-10-02 12:20:28
|
Quoting "Steve M. Robbins" <ste...@vi...>: > On Mon, Oct 01, 2001 at 12:45:40PM -0700, Duane Murphy wrote: > > > I would also make the argument (FWIW) that const is all that is > needed. > > Comparison operators should not be mutating. (Caches are caches and > > should be marked mutable.) > > I happen to agree with you. If it were my decision alone, I'd just > leave things as-is and let the folks who can't compare const objects > to suffer for their sins. ;-) > > > > This is also where you want to make the change for comparing > equivalent > > objects (not the same type). The change would be thus: > > > > template <class TExepect, TActual> > > void assertEquals( const TExepect & expected, > > const TActual & actual, ... ) > > I'm fairly skeptical that we want to allow this. > > I seem to recall changing my local copy of CppUnit some months ago to > allow assertEquals() on two different types. And I seem to recall > running into problems because the compiler likes to promote types > and use implicit conversions and all the other good stuff. > Sorry to not be more specific at this point... Euhh, I don't get it. We can perfectly control implicit conversion by defining one argument constructor explicit. Implicit conversion of basic type is something I (we?) want (unsigned int => int..., const char * => std::string)... It would make the test much easier to read... If unwanted implicit conversion occurs, wouldn't that point out a 'bug' ? Or was the problem, the compiler raising conflict because many conversions were possible ? Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Language: English, French |