RE: [Cppunit-devel] assert* macros, revisited
Brought to you by:
blep
From: Townsend, G. <gto...@sh...> - 2001-05-25 22:00:21
|
I was just thinking the same thing this morning. It was starting to bug me that a standard C++ name like assert() was being taken over, and I might get a conflict if I really wanted the standard. It takes away from the flexibility to use the library in any way desired. There doesn't seem to be any good reason for it, and it is easily changed. In the readme.html of CppUnit 1.5 was the following paragraph: ------------- Note: If you use the C++ macro "assert ()" in your code, or include assert.h, you may have a name clash with CppUnit's assert macro. This can be remedied by changing the name of the macro to "cu_assert ()" in TestCase.h. ------------ So at least cu_assert() has been mentioned, and maybe some people have used it. Still a simple search and replace on existing test files though, so the "breakage" of existing code would be minor. Doesn't really matter to me one way or the other what the prefix is. But I sure agree that it should have one. Conflicts with the C++ standard are certainly a Bad Idea. However, I don't see the point about assertEquals, as it is really CppUnit::TestAssert::assertEquals(). No global namespace polution here. There are the two macros assertDoublesEqual() and assertLongsEqual, but I'm not aware of conflicts with those names. Still, they should probably have prefixes too. Any macros in CppUnit will pollute the global namespace, and thus should use a prefix. Guy -----Original Message----- From: Steve M. Robbins [mailto:ste...@vi...] Sent: Wednesday, May 23, 2001 6:34 AM To: cpp...@li... Subject: [Cppunit-devel] assert* macros, revisited Hi, I have come to the conclusion that grabbing global name space with assert(), assertEqual(), etc, is a Bad Idea. Besides clashing with the standard C assert() macro, it is just plain rude. ;-) Other libraries prefix their macros with a standard identifier. CGAL, for one <www.cgal.org> uses CGAL_assert(). In that tradition, I wonder if CppUnit should move to CppUnit_assert()? I should hasten to add that I only suggest to do this gradually. One plan I came up with is to #define the CppUnit_assert version, and use #define assert(cond) CppUnit_assert(cond) for backwards compatibility. In fact, we could make it a configure option (--with-toplevel-assert ?). Those who wish to make sure they are writing "clean" test cases will be able to disable the old macro names ("./configure --without-toplevel-assert"). Comments? I see now that there are some other macros with a "CU_" prefix. If that is the desired prefix for CppUnit, then we'd go with CU_assert() and CU_assertEqual(). -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 _______________________________________________ Cppunit-devel mailing list Cpp...@li... http://lists.sourceforge.net/lists/listinfo/cppunit-devel |