Re: [Cppunit-devel] macros and templates
Brought to you by:
blep
From: Bastiaan B. <bas...@li...> - 2001-06-05 00:16:00
|
"Steve M. Robbins" wrote: > 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>. > > At the moment, the assertion_traits class requires string streams, > which does not exist in GCC before version 2.95.3. If you have any > bright ideas about workarounds for missing <sstream>, I'm all ears. In the log4cpp library we encountered the same problem. There we use but ostringstream, I guess in CppUnit that's all we need too. The current workaround is that we have an OstringStream class within the log4cpp namespace which is derived from either ostringstream (for g++ >= 2.95.3) or ostrstream (for g++ < 2.95.3), based on the HAVE_SSTREAM macro. The ostrstream version overrides the str() method in the following way: std::string OstringStream::str() { (*this) << '\0'; std::string msg(ostrstream::str()); ostrstream::freeze(false); //unfreeze stream return msg; } Yes, this means the str() method modifies the strstream, but because we don't call str() more than one time we can get away with it :-) The choice for a separate OstringStream class has probably more to do with the fact that it also aggregates a vform() method rather than with the missing sstream. Alternatively we could leave the ostringstream using code as is and add an ostringstream class based on the above to namespace 'std' to provide a workaround. Neither option is really elegant, if someone has a better workaround, I'm interested to hear it! Bastiaan > > > All the old CU_* got renamed to CPPUNIT_*. > I did this with a global string replace. This changes some of the > MSVC files. I hope they still work. Let me know. > > -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 |