Re: [Cppunit-devel] templatized assertions
Brought to you by:
blep
From: Steve M. R. <ste...@vi...> - 2001-05-17 20:25:05
|
On Thu, May 17, 2001 at 09:45:03PM +0200, Baptiste Lepilleur wrote: > > > If you look at the source you have: > > > /** A set of macros which allow us to get the line number > > > * and file name at the point of an error. > > > * Just goes to show that preprocessors do have some > > > * redeeming qualities. > > > */ > > > #define CPPUNIT_SOURCEANNOTATION > > > > > > #ifdef CPPUNIT_SOURCEANNOTATION > > > ... > > > > > > Which means if you removed the define, you must use the implementation > > > (TestAssert). > > > > Read a bit further; there is an #else clause! This symbol is used to > > choose between two different implementations of the assert macro. In > > both cases, you have a macro named "assert". > > Sorry. I wrote this from memory and it seems it's pretty messed up (that > what you get when you're playing with 3 differents versions of cppunit > ;-(. ) I understand. I think you're still suffering from source code overload, however. > Is CPPUNIT_SOURCEANNOTATION really required ? The only reason I can see for > it would be that some weird compiler does not support the __FILE__ & > __LINE__ macros. Have anobody hear of something like that ? No, but then __FILE__ and __LINE__ is not the difference between the two assert() macros. #ifdef CPPUNIT_SOURCEANNOTATION #undef assert #define assert(condition)\ (CppUnit::TestAssert::assertImplementation ((condition),(#condition),\ __LINE__, __FILE__)) #else #undef assert #define assert(condition)\ (CppUnit::TestAssert::assertImplementation ((condition),"",\ __LINE__, __FILE__)) #endif The difference is the use of (#condition) in the first. That seems to make "condition" into a string. It's the first time I've seen this, so it wouldn't surprise me that some preprocessors don't understand it. On the other hand, it wouldn't surprise me to learn this has been in the C standard for 10 years. I try to use the preprocessor as little as possible. :-/ -S -- 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 |