Re: [Cppunit-devel] templatized assertions
Brought to you by:
blep
From: Baptiste L. <gai...@fr...> - 2001-05-17 13:03:10
|
Quoting "Steve M. Robbins" <ste...@vi...>: > On Wed, May 16, 2001 at 09:28:06PM +0200, Baptiste Lepilleur wrote: > > I would use a trait to add the object to the stream. The trait generic > > implementation would use '<<', but could be specialized when needed. > > That sounds like a reasonable idea. I'm not terribly experienced in > traits; what would be a good name for the function? Some of CppUnit > already uses "toString", which seems reasonable enough, yes? It looks good to me. > > Also, since it is a template member, if should be protected with a > define. > > VC++ 5.0 (and many other compiler I guess) does not support template > member > > for example (though it a static member so I'm not sure). > > I'm not very knowledgable about the state of support for various > features > of the language. What is the workaround for compilers that don't > support > template static members? I don't really know, but I can think of a few dirty things (make it a templatized function which take the class instance as parameter). The clean way would probably to add the "expected" template instantiation as method (such as the current assertEquals). > > Actually: why does TestAssert need to be a class at all? There are no > data members, so why not just make it a namespace with a bunch of > templatized functions? The idea was to inherit that class when you wanted to use assertion. But this is of no use since we use macro to capture source file & line number and those macro are global. Using namespace should indeed solve the template member problem. I can see the following impact: - remove inheritance of TestAssert in TestCase - update the sample to use assert macro instead of assertImplementation (I wonder why it's doing that anyway) Removing inheritance would require people to explicitly use the namespace for assertion if they disabled the assert macro. Anybody see a problem with that ? Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Language: English, French |