CPPUNIT_ASSERT_THROW double handling of STL std::exception

View: New views
1 Messages — Rating Filter:   Alert me  

CPPUNIT_ASSERT_THROW double handling of STL std::exception

by cppunit-devel mailing list :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Cppunit-devel mailing list
Cppunit-devel@...
https://lists.sourceforge.net/lists/listinfo/cppunit-devel