Re: [Cppunit-devel] macros and templates
Brought to you by:
blep
From: Steve M. R. <ste...@vi...> - 2001-06-06 13:56:42
|
On Tue, Jun 05, 2001 at 11:50:17PM +0200, Baptiste Lepilleur wrote: > ----- Original Message ----- > From: "Steve M. Robbins" <ste...@vi...> > To: <cpp...@li...> > Sent: Sunday, June 03, 2001 1:49 AM > Subject: [Cppunit-devel] macros and templates > > > > I've added the generic TestAssert::assertEquals() method, > > along with the new macros CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, > > and CPPUNIT_ASSERT_DOUBLES_EQUAL. The old naked assert and > > friends are available by editing <cppunit/config.h>. > I've added a default config.h for VC++ (we don't have a configure script > ;-( ). Yeah. The lack of a configure script is really unfortunate. And it will only get worse. I expect that there will be an increasing number of HAVE_xxx type of macros defined in one header or another. > When other WIN32 compilers will be added, we can update it to detect > the compiler and set default accordingly. OK. But here's the problem. The file config.h is automatically generated (by configure) from config.h.in. So we don't ship with config.h. Can you write a small script (CONFIGURE.BAT?) for the benefit of WIN systems that don't run configure, that will copy config.h.in to config.h? At the moment, there are in fact, TWO config.h files. That's pretty confusing, I agree. They should have different names. The two files serve different needs. The original config.h is the standard header that autoconf generates. It is intended to contain stuff needed for build-time portability. The symbol HAVE_DLFCN_H is defined, for example, for the benefit of libtool in creating dynamic libraries. The other header, <cppunit/config.h>, is intended to be installed along with the rest of the CppUnit header files. It contains symbol definitions, like CPPUNIT_USE_TYPEINFO, that are used in the other CppUnit headers. Some of these symbols are detected automatically at configure time. So, again, this file does not ship. For systems that can't use the configure script, alternate arrangements are needed. > I think we should add a CPPUNIT_ASSERT_MESSAGE macro, which take a > boolean and a string which is added to the error message. This would allow > the user to create new assertions. For example, you need to compare complex > numbers with a tolerance. > > What do you think ? I think assert-with-message can be useful. For the example you give, an alternative is for the user to write an assertion_traits class for complex numbers that provides a toleranced "equals" method. In fact, one could go the same route for doubles, so I considered the idea of removing CPPUNIT_ASSERT_DOUBLES_EQUAL. Bad idea? -- 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 |