[Cppunit-devel] CPPUNIT_ASSERT_THROW double handling of STL std::exception
Brought to you by:
blep
From: CppUnit d. m. l. <cpp...@li...> - 2007-03-13 17:09:37
|
Hi, I'm new to CppUnit, so I hope this is not a frivolous post. I would like to use CPPUNIT_ASSERT_THROW to ensure that a function throws an STL std::exception for specific input conditions. However, this triggers a compiler error (C2312 for Microsoft's Visual C++ 2005 Express Edition), which has to do with having two handlers for the same exception. I'm using CppUnit version 1.12, but saw an item in the release notes of version 1.11.4 which indicates that this is indeed the case, and that CPPUNIT_ASSERT_THROW will not (or should not) compile if used with std::exception as the exception type. The link to the release notes for 1.11.4 is here: https://sourceforge.net/project/shownotes.php?group_id=11795&release_id=369052 This behaviour could possibly be altered by minor modifications to the definition of CPPUNIT_ASSERT_THROW_MESSAGE in testassert.h by using typeid to check the identity of the "ExceptionType" prior to the try-catch block. I do not know how many users would want such functionality (as the problem is easy to work around), but believe it would be an improvement to CppUnit if the macro performs as advertised in the documentation, even for the special case of checking std::exception throws. Would such a change be considered for an upcoming release? Thanks Robert |